Speeduino
Loading...
Searching...
No Matches
Macros | Functions | Variables
decoders.cpp File Reference
#include <limits.h>
#include "globals.h"
#include "decoders.h"
#include "scheduledIO.h"
#include "scheduler.h"
#include "crankMaths.h"
#include "timers.h"
#include "schedule_calcs.h"

Macros

#define MJR   1
 
#define secondaryToothLastCount   checkSyncToothCount
 
#define renixSystemLastToothTime   toothLastToothRisingTime
 
#define renixSystemLastMinusOneToothTime   toothLastSecToothRisingTime
 

Functions

void nullTriggerHandler (void)
 
uint16_t nullGetRPM (void)
 
int nullGetCrankAngle (void)
 
static void triggerRoverMEMSCommon (void)
 Pointer to the triggerSetEndTeeth function of each decoder.
 
static void triggerRecordVVT1Angle (void)
 
static void addToothLogEntry (unsigned long toothTime, byte whichTooth)
 
void loggerPrimaryISR (void)
 
void loggerSecondaryISR (void)
 
void loggerTertiaryISR (void)
 
static uint16_t timeToAngleIntervalTooth (uint32_t time)
 
static bool IsCranking (const statuses &status)
 
static bool SetRevolutionTime (uint32_t revTime)
 
static bool UpdateRevolutionTimeFromTeeth (bool isCamTeeth)
 
static uint16_t clampRpm (uint16_t rpm)
 
static uint16_t RpmFromRevolutionTimeUs (uint32_t revTime)
 
static uint16_t stdGetRPM (bool isCamTeeth)
 
static void setFilter (unsigned long curGap)
 
static int crankingGetRPM (byte totalTeeth, bool isCamTeeth)
 
static void checkPerToothTiming (int16_t crankAngle, uint16_t currentTooth)
 
void triggerSetup_missingTooth (void)
 
void triggerPri_missingTooth (void)
 
void triggerSec_missingTooth (void)
 
void triggerThird_missingTooth (void)
 
uint16_t getRPM_missingTooth (void)
 
int getCrankAngle_missingTooth (void)
 
static uint16_t clampToToothCount (int16_t toothNum, uint8_t toothAdder)
 
static uint16_t clampToActualTeeth (uint16_t toothNum, uint8_t toothAdder)
 
static uint16_t calcEndTeeth_missingTooth (int endAngle, uint8_t toothAdder)
 
void triggerSetEndTeeth_missingTooth (void)
 
void triggerSetup_DualWheel (void)
 
void triggerPri_DualWheel (void)
 
void triggerSec_DualWheel (void)
 
uint16_t getRPM_DualWheel (void)
 
int getCrankAngle_DualWheel (void)
 
static uint16_t calcEndTeeth_DualWheel (int ignitionAngle, uint8_t toothAdder)
 
void triggerSetEndTeeth_DualWheel (void)
 
void triggerSetup_BasicDistributor (void)
 
void triggerPri_BasicDistributor (void)
 
void triggerSec_BasicDistributor (void)
 
uint16_t getRPM_BasicDistributor (void)
 
int getCrankAngle_BasicDistributor (void)
 
void triggerSetEndTeeth_BasicDistributor (void)
 
void triggerSetup_GM7X (void)
 
void triggerPri_GM7X (void)
 
void triggerSec_GM7X (void)
 
uint16_t getRPM_GM7X (void)
 
int getCrankAngle_GM7X (void)
 
void triggerSetEndTeeth_GM7X (void)
 
void triggerSetup_4G63 (void)
 
void triggerPri_4G63 (void)
 
void triggerSec_4G63 (void)
 
uint16_t getRPM_4G63 (void)
 
int getCrankAngle_4G63 (void)
 
void triggerSetEndTeeth_4G63 (void)
 
void triggerSetup_24X (void)
 
void triggerPri_24X (void)
 
void triggerSec_24X (void)
 
uint16_t getRPM_24X (void)
 
int getCrankAngle_24X (void)
 
void triggerSetEndTeeth_24X (void)
 
void triggerSetup_Jeep2000 (void)
 
void triggerPri_Jeep2000 (void)
 
void triggerSec_Jeep2000 (void)
 
uint16_t getRPM_Jeep2000 (void)
 
int getCrankAngle_Jeep2000 (void)
 
void triggerSetEndTeeth_Jeep2000 (void)
 
void triggerSetup_Audi135 (void)
 
void triggerPri_Audi135 (void)
 
void triggerSec_Audi135 (void)
 
uint16_t getRPM_Audi135 (void)
 
int getCrankAngle_Audi135 (void)
 
void triggerSetEndTeeth_Audi135 (void)
 
void triggerSetup_HondaD17 (void)
 
void triggerPri_HondaD17 (void)
 
void triggerSec_HondaD17 (void)
 
uint16_t getRPM_HondaD17 (void)
 
int getCrankAngle_HondaD17 (void)
 
void triggerSetEndTeeth_HondaD17 (void)
 
void triggerSetup_HondaJ32 (void)
 
void triggerPri_HondaJ32 (void)
 
void triggerSec_HondaJ32 (void)
 
uint16_t getRPM_HondaJ32 (void)
 
int getCrankAngle_HondaJ32 (void)
 
void triggerSetEndTeeth_HondaJ32 (void)
 
void triggerSetup_Miata9905 (void)
 
void triggerPri_Miata9905 (void)
 
void triggerSec_Miata9905 (void)
 
uint16_t getRPM_Miata9905 (void)
 
int getCrankAngle_Miata9905 (void)
 
int getCamAngle_Miata9905 (void)
 
void triggerSetEndTeeth_Miata9905 (void)
 
void triggerSetup_MazdaAU (void)
 
void triggerPri_MazdaAU (void)
 
void triggerSec_MazdaAU (void)
 
uint16_t getRPM_MazdaAU (void)
 
int getCrankAngle_MazdaAU (void)
 
void triggerSetEndTeeth_MazdaAU (void)
 
void triggerSetup_non360 (void)
 
void triggerPri_non360 (void)
 
void triggerSec_non360 (void)
 
uint16_t getRPM_non360 (void)
 
int getCrankAngle_non360 (void)
 
void triggerSetEndTeeth_non360 (void)
 
void triggerSetup_Nissan360 (void)
 
void triggerPri_Nissan360 (void)
 
void triggerSec_Nissan360 (void)
 
uint16_t getRPM_Nissan360 (void)
 
int getCrankAngle_Nissan360 (void)
 
void triggerSetEndTeeth_Nissan360 (void)
 
void triggerSetup_Subaru67 (void)
 
void triggerPri_Subaru67 (void)
 
void triggerSec_Subaru67 (void)
 
uint16_t getRPM_Subaru67 (void)
 
int getCrankAngle_Subaru67 (void)
 
void triggerSetEndTeeth_Subaru67 (void)
 
void triggerSetup_Daihatsu (void)
 
void triggerPri_Daihatsu (void)
 
void triggerSec_Daihatsu (void)
 
uint16_t getRPM_Daihatsu (void)
 
int getCrankAngle_Daihatsu (void)
 
void triggerSetEndTeeth_Daihatsu (void)
 
void triggerSetup_Harley (void)
 
void triggerPri_Harley (void)
 
void triggerSec_Harley (void)
 
uint16_t getRPM_Harley (void)
 
int getCrankAngle_Harley (void)
 
void triggerSetEndTeeth_Harley (void)
 
void triggerSetup_ThirtySixMinus222 (void)
 
void triggerPri_ThirtySixMinus222 (void)
 
void triggerSec_ThirtySixMinus222 (void)
 
uint16_t getRPM_ThirtySixMinus222 (void)
 
int getCrankAngle_ThirtySixMinus222 (void)
 
void triggerSetEndTeeth_ThirtySixMinus222 (void)
 
void triggerSetup_ThirtySixMinus21 (void)
 
void triggerPri_ThirtySixMinus21 (void)
 
void triggerSec_ThirtySixMinus21 (void)
 
uint16_t getRPM_ThirtySixMinus21 (void)
 
int getCrankAngle_ThirtySixMinus21 (void)
 
void triggerSetEndTeeth_ThirtySixMinus21 (void)
 
void triggerSetup_420a (void)
 
void triggerPri_420a (void)
 
void triggerSec_420a (void)
 
uint16_t getRPM_420a (void)
 
int getCrankAngle_420a (void)
 
void triggerSetEndTeeth_420a (void)
 
void triggerPri_Webber (void)
 
void triggerSec_Webber (void)
 
void triggerSetup_FordST170 (void)
 
void triggerSec_FordST170 (void)
 
uint16_t getRPM_FordST170 (void)
 
int getCrankAngle_FordST170 (void)
 
static uint16_t calcSetEndTeeth_FordST170 (int ignitionAngle, uint8_t toothAdder)
 
void triggerSetEndTeeth_FordST170 (void)
 
void triggerSetup_DRZ400 (void)
 
void triggerSec_DRZ400 (void)
 
void triggerSetup_NGC (void)
 
void triggerPri_NGC (void)
 
void triggerSec_NGC4 (void)
 
void triggerSec_NGC68 (void)
 
uint16_t getRPM_NGC (void)
 
static uint16_t calcSetEndTeeth_NGC_SkipMissing (uint16_t toothNum)
 
static uint16_t calcSetEndTeeth_NGC (int ignitionAngle, uint8_t toothAdder)
 
void triggerSetEndTeeth_NGC (void)
 
void triggerSetup_Vmax (void)
 
void triggerPri_Vmax (void)
 
void triggerSec_Vmax (void)
 
uint16_t getRPM_Vmax (void)
 
int getCrankAngle_Vmax (void)
 
void triggerSetEndTeeth_Vmax (void)
 
void triggerSetup_Renix (void)
 
void triggerPri_Renix (void)
 
static uint16_t calcEndTeeth_Renix (int ignitionAngle, uint8_t toothAdder)
 
void triggerSetEndTeeth_Renix (void)
 
void triggerSetup_RoverMEMS ()
 
void triggerPri_RoverMEMS ()
 
int getCrankAngle_RoverMEMS ()
 
void triggerSec_RoverMEMS ()
 
uint16_t getRPM_RoverMEMS ()
 
void triggerSetEndTeeth_RoverMEMS ()
 
void triggerSetup_SuzukiK6A (void)
 
void triggerPri_SuzukiK6A (void)
 
void triggerSec_SuzukiK6A (void)
 
uint16_t getRPM_SuzukiK6A (void)
 
int getCrankAngle_SuzukiK6A (void)
 
void triggerSetEndTeeth_SuzukiK6A (void)
 

Variables

void(* triggerHandler )(void) = nullTriggerHandler
 
void(* triggerSecondaryHandler )(void) = nullTriggerHandler
 Pointer for the trigger function (Gets pointed to the relevant decoder)
 
void(* triggerTertiaryHandler )(void) = nullTriggerHandler
 Pointer for the secondary trigger function (Gets pointed to the relevant decoder)
 
uint16_t(* getRPM )(void) = nullGetRPM
 Pointer for the tertiary trigger function (Gets pointed to the relevant decoder)
 
int(* getCrankAngle )(void) = nullGetCrankAngle
 Pointer to the getRPM function (Gets pointed to the relevant decoder)
 
void(* triggerSetEndTeeth )(void) = triggerSetEndTeeth_missingTooth
 Pointer to the getCrank Angle function (Gets pointed to the relevant decoder)
 
volatile unsigned long curTime
 
volatile unsigned long curGap
 
volatile unsigned long curTime2
 
volatile unsigned long curGap2
 
volatile unsigned long curTime3
 
volatile unsigned long curGap3
 
volatile unsigned long lastGap
 
volatile unsigned long targetGap
 
unsigned long MAX_STALL_TIME = MICROS_PER_SEC/2U
 
volatile uint16_t toothCurrentCount = 0
 
volatile byte toothSystemCount = 0
 
volatile unsigned long toothSystemLastToothTime = 0
 
volatile unsigned long toothLastToothTime = 0
 
volatile unsigned long toothLastSecToothTime = 0
 
volatile unsigned long toothLastThirdToothTime = 0
 
volatile unsigned long toothLastMinusOneToothTime = 0
 
volatile unsigned long toothLastMinusOneSecToothTime = 0
 
volatile unsigned long toothLastToothRisingTime = 0
 
volatile unsigned long toothLastSecToothRisingTime = 0
 
volatile unsigned long targetGap2
 
volatile unsigned long targetGap3
 
volatile unsigned long toothOneTime = 0
 
volatile unsigned long toothOneMinusOneTime = 0
 
volatile bool revolutionOne = 0
 
volatile bool revolutionLastOne = 0
 
volatile unsigned int secondaryToothCount
 
volatile unsigned int secondaryLastToothCount = 0
 
volatile unsigned long secondaryLastToothTime = 0
 
volatile unsigned long secondaryLastToothTime1 = 0
 
volatile unsigned int thirdToothCount
 
volatile unsigned long thirdLastToothTime = 0
 
volatile unsigned long thirdLastToothTime1 = 0
 
uint16_t triggerActualTeeth
 
volatile unsigned long triggerFilterTime
 
volatile unsigned long triggerSecFilterTime
 
volatile unsigned long triggerThirdFilterTime
 
volatile uint8_t decoderState = 0
 
unsigned int triggerSecFilterTime_duration
 
volatile uint16_t triggerToothAngle
 
byte checkSyncToothCount
 
unsigned long elapsedTime
 
unsigned long lastCrankAngleCalc
 
unsigned long lastVVTtime
 
uint16_t ignition1EndTooth = 0
 
uint16_t ignition2EndTooth = 0
 
uint16_t ignition3EndTooth = 0
 
uint16_t ignition4EndTooth = 0
 
uint16_t ignition5EndTooth = 0
 
uint16_t ignition6EndTooth = 0
 
uint16_t ignition7EndTooth = 0
 
uint16_t ignition8EndTooth = 0
 
int16_t toothAngles [24]
 
volatile unsigned long roverMEMSTeethSeen = 0
 

Detailed Description

Crank and Cam decoders

This file contains the various crank and cam wheel decoder functions. Each decoder must have the following 4 functions (Where xxxx is the decoder name):

Each decoder must utilise at least the following variables:

Macro Definition Documentation

◆ MJR

#define MJR   1

Function Documentation

◆ nullGetCrankAngle()

int nullGetCrankAngle ( void  )

◆ nullGetRPM()

uint16_t nullGetRPM ( void  )

◆ nullTriggerHandler()

void nullTriggerHandler ( void  )

◆ triggerSec_DRZ400()

void triggerSec_DRZ400 ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ triggerSetup_DRZ400()

void triggerSetup_DRZ400 ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ checkSyncToothCount

byte checkSyncToothCount

◆ curGap

◆ curGap2

◆ curGap3

◆ curTime

◆ curTime2

◆ curTime3

◆ decoderState

volatile uint8_t decoderState = 0

◆ elapsedTime

unsigned long elapsedTime

◆ getCrankAngle

int(* getCrankAngle) (void) ( void  ) = nullGetCrankAngle

Pointer to the getRPM function (Gets pointed to the relevant decoder)

◆ getRPM

uint16_t(* getRPM) (void) ( void  ) = nullGetRPM

Pointer for the tertiary trigger function (Gets pointed to the relevant decoder)

◆ ignition1EndTooth

uint16_t ignition1EndTooth = 0

◆ ignition2EndTooth

uint16_t ignition2EndTooth = 0

◆ ignition3EndTooth

uint16_t ignition3EndTooth = 0

◆ ignition4EndTooth

uint16_t ignition4EndTooth = 0

◆ ignition5EndTooth

uint16_t ignition5EndTooth = 0

◆ ignition6EndTooth

uint16_t ignition6EndTooth = 0

◆ ignition7EndTooth

uint16_t ignition7EndTooth = 0

◆ ignition8EndTooth

uint16_t ignition8EndTooth = 0

◆ lastCrankAngleCalc

unsigned long lastCrankAngleCalc

◆ lastGap

◆ lastVVTtime

unsigned long lastVVTtime

◆ MAX_STALL_TIME

unsigned long MAX_STALL_TIME = MICROS_PER_SEC/2U

◆ revolutionLastOne

volatile bool revolutionLastOne = 0

◆ revolutionOne

volatile bool revolutionOne = 0

◆ secondaryLastToothCount

volatile unsigned int secondaryLastToothCount = 0

◆ secondaryLastToothTime

volatile unsigned long secondaryLastToothTime = 0

◆ secondaryLastToothTime1

volatile unsigned long secondaryLastToothTime1 = 0

◆ secondaryToothCount

volatile unsigned int secondaryToothCount

◆ targetGap

volatile unsigned long targetGap

◆ targetGap2

volatile unsigned long targetGap2

◆ targetGap3

volatile unsigned long targetGap3

◆ thirdLastToothTime

volatile unsigned long thirdLastToothTime = 0

◆ thirdLastToothTime1

volatile unsigned long thirdLastToothTime1 = 0

◆ thirdToothCount

volatile unsigned int thirdToothCount

◆ toothAngles

int16_t toothAngles[24]

◆ toothCurrentCount

volatile uint16_t toothCurrentCount = 0

◆ toothLastMinusOneSecToothTime

volatile unsigned long toothLastMinusOneSecToothTime = 0

◆ toothLastMinusOneToothTime

volatile unsigned long toothLastMinusOneToothTime = 0

◆ toothLastSecToothRisingTime

volatile unsigned long toothLastSecToothRisingTime = 0

◆ toothLastSecToothTime

volatile unsigned long toothLastSecToothTime = 0

◆ toothLastThirdToothTime

volatile unsigned long toothLastThirdToothTime = 0

◆ toothLastToothRisingTime

volatile unsigned long toothLastToothRisingTime = 0

◆ toothLastToothTime

volatile unsigned long toothLastToothTime = 0

◆ toothOneMinusOneTime

volatile unsigned long toothOneMinusOneTime = 0

◆ toothOneTime

volatile unsigned long toothOneTime = 0

◆ toothSystemCount

volatile byte toothSystemCount = 0

◆ toothSystemLastToothTime

volatile unsigned long toothSystemLastToothTime = 0

◆ triggerActualTeeth

uint16_t triggerActualTeeth

◆ triggerFilterTime

volatile unsigned long triggerFilterTime

◆ triggerHandler

void(* triggerHandler) (void) ( void  ) = nullTriggerHandler

◆ triggerSecFilterTime

volatile unsigned long triggerSecFilterTime

◆ triggerSecFilterTime_duration

unsigned int triggerSecFilterTime_duration

◆ triggerSecondaryHandler

void(* triggerSecondaryHandler) (void) ( void  ) = nullTriggerHandler

Pointer for the trigger function (Gets pointed to the relevant decoder)

◆ triggerSetEndTeeth

void(* triggerSetEndTeeth) (void) ( void  ) = triggerSetEndTeeth_missingTooth

Pointer to the getCrank Angle function (Gets pointed to the relevant decoder)

◆ triggerTertiaryHandler

void(* triggerTertiaryHandler) (void) ( void  ) = nullTriggerHandler

Pointer for the secondary trigger function (Gets pointed to the relevant decoder)

◆ triggerThirdFilterTime

volatile unsigned long triggerThirdFilterTime

◆ triggerToothAngle

volatile uint16_t triggerToothAngle