Speeduino
Loading...
Searching...
No Matches
Macros | Functions | Variables
scheduler.cpp File Reference
#include "globals.h"
#include "scheduler.h"
#include "scheduledIO.h"
#include "timers.h"
#include "schedule_calcs.h"
#include "preprocessor.h"
#include "units.h"

Macros

#define DWELL_AVERAGE_ALPHA   30
 
#define DWELL_AVERAGE(input)   LOW_PASS_FILTER((input), DWELL_AVERAGE_ALPHA, currentStatus.actualDwell)
 

Functions

static void reset (Schedule &schedule)
 
static void reset (FuelSchedule &schedule)
 
static void reset (IgnitionSchedule &schedule)
 
void initialiseFuelSchedulers (void)
 
void initialiseIgnitionSchedulers (void)
 
void startIgnitionSchedulers (void)
 
void stopIgnitionSchedulers (void)
 
void startFuelSchedulers (void)
 
void stopFuelSchedulers (void)
 
void setCallbacks (Schedule &schedule, voidVoidCallback pStartCallback, voidVoidCallback pEndCallback)
 Set the schedule action start & end callbacks.
 
static uint16_t clipDuration (uint16_t duration)
 
static void setScheduleNext (Schedule &schedule, uint32_t delay, uint16_t duration)
 
static void setScheduleRunning (Schedule &schedule, uint32_t delay, uint16_t duration)
 
void setSchedule (Schedule &schedule, uint32_t delay, uint16_t duration, bool allowQueuedSchedule)
 Set the schedule action to run for a certain duration in the future.
 
void refreshIgnitionSchedule1 (unsigned long timeToEnd)
 
void beginInjectorPriming (void)
 
static void fuelScheduleISR (FuelSchedule &schedule)
 
void fuelSchedule1Interrupt ()
 
void fuelSchedule2Interrupt ()
 
void fuelSchedule3Interrupt ()
 
void fuelSchedule4Interrupt ()
 
static void ignitionScheduleISR (IgnitionSchedule &schedule)
 
void ignitionSchedule1Interrupt (void)
 
static void disableSchedule (Schedule &schedule)
 
void disableFuelSchedule (uint8_t channel)
 
void disableIgnSchedule (uint8_t channel)
 
void disableAllFuelSchedules (void)
 
void disableAllIgnSchedules (void)
 

Variables

FuelSchedule fuelSchedule1 (FUEL1_COUNTER, FUEL1_COMPARE)
 
FuelSchedule fuelSchedule2 (FUEL2_COUNTER, FUEL2_COMPARE)
 
FuelSchedule fuelSchedule3 (FUEL3_COUNTER, FUEL3_COMPARE)
 
FuelSchedule fuelSchedule4 (FUEL4_COUNTER, FUEL4_COMPARE)
 
IgnitionSchedule ignitionSchedule1 (IGN1_COUNTER, IGN1_COMPARE)
 
IgnitionSchedule ignitionSchedule2 (IGN2_COUNTER, IGN2_COMPARE)
 
IgnitionSchedule ignitionSchedule3 (IGN3_COUNTER, IGN3_COMPARE)
 
IgnitionSchedule ignitionSchedule4 (IGN4_COUNTER, IGN4_COMPARE)
 
IgnitionSchedule ignitionSchedule5 (IGN5_COUNTER, IGN5_COMPARE)
 
static table2D_u8_u8_4 PrimingPulseTableconfigPage2
 

Detailed Description

Injector and Ignition (on/off) scheduling (functions). There is usually 8 functions for cylinders 1-8 with same naming pattern.

Scheduling structures

Structures FuelSchedule and Schedule describe (from scheduler.h) describe the scheduling info for Fuel and Ignition respectively. They contain duration, current activity status, start timing, end timing, callbacks to carry out action, etc.

Scheduling Functions

For Injection:

For Ignition (has more complex schedule setup):

Macro Definition Documentation

◆ DWELL_AVERAGE

#define DWELL_AVERAGE (   input)    LOW_PASS_FILTER((input), DWELL_AVERAGE_ALPHA, currentStatus.actualDwell)

◆ DWELL_AVERAGE_ALPHA

#define DWELL_AVERAGE_ALPHA   30

Function Documentation

◆ beginInjectorPriming()

void beginInjectorPriming ( void  )

Perform the injector priming pulses. Set these to run at an arbitrary time in the future (100us). The prime pulse value is in ms*10, so need to multiple by 100 to get to uS

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clipDuration()

static uint16_t clipDuration ( uint16_t  duration)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ disableAllFuelSchedules()

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

◆ disableAllIgnSchedules()

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

◆ disableFuelSchedule()

void disableFuelSchedule ( uint8_t  channel)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ disableIgnSchedule()

void disableIgnSchedule ( uint8_t  channel)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ disableSchedule()

static void disableSchedule ( Schedule schedule)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fuelSchedule1Interrupt()

void fuelSchedule1Interrupt ( )

fuelSchedule*Interrupt (All 8 ISR functions below) get called (as timed interrupts) when either the start time or the duration time are reached. This calls the relevant callback function (startCallback or endCallback) depending on the status (PENDING => Needs to run, RUNNING => Needs to stop) of the schedule. The status of schedule is managed here based on startCallback /endCallback function called:

  • startCallback - change scheduler into RUNNING state
  • endCallback - change scheduler into OFF state (or PENDING if schedule.hasNextSchedule is set)
Here is the call graph for this function:

◆ fuelSchedule2Interrupt()

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

◆ fuelSchedule3Interrupt()

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

◆ fuelSchedule4Interrupt()

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

◆ fuelScheduleISR()

static void fuelScheduleISR ( FuelSchedule schedule)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ignitionSchedule1Interrupt()

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

◆ ignitionScheduleISR()

static void ignitionScheduleISR ( IgnitionSchedule schedule)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialiseFuelSchedulers()

void initialiseFuelSchedulers ( void  )

< The number of crank degrees until cylinder 1 is at TDC (This is obviously 0 for virtually ALL engines, but there's some weird ones)

< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC

< The number of crank degrees until cylinder 3 (and 5/6/7/8) is at TDC

< The number of crank degrees until cylinder 4 (and 5/6/7/8) is at TDC

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialiseIgnitionSchedulers()

void initialiseIgnitionSchedulers ( void  )

< The number of crank degrees until cylinder 1 is at TDC (This is obviously 0 for virtually ALL engines, but there's some weird ones)

< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC

< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC

< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC

Here is the call graph for this function:
Here is the caller graph for this function:

◆ refreshIgnitionSchedule1()

void refreshIgnitionSchedule1 ( unsigned long  timeToEnd)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset() [1/3]

static void reset ( FuelSchedule schedule)
inlinestatic
Here is the call graph for this function:

◆ reset() [2/3]

static void reset ( IgnitionSchedule schedule)
inlinestatic
Here is the call graph for this function:

◆ reset() [3/3]

static void reset ( Schedule schedule)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCallbacks()

void setCallbacks ( Schedule schedule,
voidVoidCallback  pStartCallback,
voidVoidCallback  pEndCallback 
)

Set the schedule action start & end callbacks.

Parameters
scheduleSchedule to modify
pStartCallbackStart callback
pEndCallbackEnd callback
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSchedule()

void setSchedule ( Schedule schedule,
uint32_t  delay,
uint16_t  duration,
bool  allowQueuedSchedule 
)

Set the schedule action to run for a certain duration in the future.

Parameters
scheduleSchedule to modify
delayDelay until the action starts (µS)
durationAction duration (µS)
allowQueuedScheduletrue to allow a schedule to be queued up if one is currently running; false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setScheduleNext()

static void setScheduleNext ( Schedule schedule,
uint32_t  delay,
uint16_t  duration 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setScheduleRunning()

static void setScheduleRunning ( Schedule schedule,
uint32_t  delay,
uint16_t  duration 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ startFuelSchedulers()

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

◆ startIgnitionSchedulers()

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

◆ stopFuelSchedulers()

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

◆ stopIgnitionSchedulers()

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

Variable Documentation

◆ configPage2

table2D_u8_u8_4 PrimingPulseTable& configPage2
static

◆ fuelSchedule1

◆ fuelSchedule2

◆ fuelSchedule3

◆ fuelSchedule4

◆ ignitionSchedule1

◆ ignitionSchedule2

◆ ignitionSchedule3

◆ ignitionSchedule4

◆ ignitionSchedule5