Speeduino
Loading...
Searching...
No Matches
Macros | Functions | Variables
scheduler_fuel_controller.cpp File Reference
#include "scheduler_fuel_controller.h"
#include "scheduledIO_inj.h"
#include "units.h"
#include "table2d.h"
#include "globals.h"

Macros

#define SET_CALLBACKS(index)   setCallbacks(fuelSchedule ## index, openInjector ## index, closeInjector ## index);\
 
#define SET_FUEL_CHANNEL(channel)    setFuelChannelSchedule(fuelSchedule ##channel, UINT8_C(channel), crankAngle, injChannelMask, injAngle, &angleCalcCache);
 
#define ASSIGN_PRIMARY_PW(index)   fuelSchedule ## index .pw = applyFuelTrim(trimTables[index-1U], pulse_widths.primary, page6, current);
 
#define ASSIGN_SECONDARY_PW(index)
 
#define ASSIGN_ZERO_PW(index)   fuelSchedule ## index .pw = 0U;
 

Functions

static void setupSequentialCallbacks (void)
 
static void setupPairedCallbacks (void)
 
static void setupSemiSequentialCallbacks (uint8_t nCylinders, uint8_t inj4cylPairing)
 
static void setupCallbacks (uint8_t injLayout, uint8_t nCylinders, uint8_t inj4cylPairing)
 
static bool isSwitchableCylinderCount (const config2 &page2)
 
TESTABLE_INLINE_STATIC bool changeToSemiSequentialInjection (const config2 &page2, const decoder_status_t &decoderStatus)
 
TESTABLE_INLINE_STATIC bool changeToFullSequentialInjection (const config2 &page2, const decoder_status_t &decoderStatus)
 
TESTABLE_INLINE_STATIC bool isAnyFuelScheduleRunning (void)
 
static void changeFuellingToFullSequential (const config2 &page2, statuses &current)
 
static void changeFuellingToSemiSequential (const config2 &page2, const config4 &page4, statuses &current)
 
TESTABLE_STATIC void matchFuelSchedulersToSyncState (const config2 &page2, const config4 &page4, statuses &current)
 
TESTABLE_INLINE_STATIC uint16_t lookupInjectorAngle (const statuses &current)
 
TESTABLE_INLINE_STATIC uint16_t updatePwAngleCache (uint16_t pw, injectorAngleCalcCache *pCache)
 
TESTABLE_INLINE_STATIC uint16_t _calculateOpenAngle (FuelSchedule &schedule, uint16_t pwDegrees, uint16_t injAngle)
 Compute the injector open angle for an injection channel.
 
TESTABLE_INLINE_STATIC uint32_t calculateInjectorTimeout (const FuelSchedule &schedule, int16_t crankAngle, uint16_t openAngle)
 Calculate the time in uS from now to when the injector should be opened.
 
TESTABLE_INLINE_STATIC void setFuelChannelSchedule (FuelSchedule &schedule, uint8_t channel, uint16_t crankAngle, byte injChannelMask, uint16_t injAngle, injectorAngleCalcCache *pCache) noexcept
 
TESTABLE_INLINE_STATIC uint16_t setFuelChannelSchedules (uint16_t crankAngle, byte injChannelMask, uint16_t injAngle)
 
TESTABLE_INLINE_STATIC uint16_t injectorLimits (uint16_t angle)
 Clamp the angle to within [0,CRANK_ANGLE_MAX_INJ].
 
 BEGIN_LTO_ALWAYS_INLINE (uint16_t) setFuelChannelSchedules(const statuses &current)
 
static uint16_t applyFuelTrim (const table3d6RpmLoad &trimTable, uint16_t pw, const config6 &page6, const statuses &current)
 
static void assignPrimaryPws (const pulseWidths &pulse_widths, const config6 &page6, const statuses &current)
 
static void assignSecondaryPws (const pulseWidths &pulse_widths, const statuses &current)
 
static void zeroAllChannels (void)
 
 BEGIN_LTO_ALWAYS_INLINE (void) applyPwToInjectorChannels(const pulseWidths &pulse_widths
 
 assignPrimaryPws (pulse_widths, page6, current)
 
 assignSecondaryPws (pulse_widths, current)
 
static void resetFuelSchedules (void)
 
void startFuelSchedulers (void)
 Start the timers that drive schedulers.
 
void stopFuelSchedulers (void)
 Stop the timers that drive schedulers.
 
void beginInjectorPriming (const statuses &current, const config4 &page4)
 Start priming the fuel system.
 
void closeAllInjectors (void)
 Utility function to close all injectors.
 
static void clampInjectionChannelAngles (void)
 Limit all injection schedule channel angles to 0-CRANK_ANGLE_MAX_INJ.
 
static void initFuelScheduleAngles (statuses &current, const config2 &page2, const config10 &page10)
 
static uint8_t calulateDefaultSquirts (const config2 &page2)
 
void initialiseFuelSchedules (statuses &current, const config2 &page2, const config4 &page4, const config10 &page10, const pinNumbers_t &pins)
 Initialise this module.
 

Variables

FuelSchedule fuelSchedule1 (FUEL1_COUNTER, FUEL1_COMPARE)
 
TESTABLE_STATIC table2D_u8_u16_4 injectorAngleTable & configPage2
 
const config2page2
 
const config2 const config4page4
 
const config2 const config4 const config6page6
 
const config2 const config4 const config6 statusescurrent
 

Macro Definition Documentation

◆ ASSIGN_PRIMARY_PW

#define ASSIGN_PRIMARY_PW (   index)    fuelSchedule ## index .pw = applyFuelTrim(trimTables[index-1U], pulse_widths.primary, page6, current);

◆ ASSIGN_SECONDARY_PW

#define ASSIGN_SECONDARY_PW (   index)
Value:
if ((index>current.numPrimaryInjOutputs) && (index<=getTotalInjChannelCount(current))) \
{ \
fuelSchedule ## index .pw = pulse_widths.secondary; \
}
const config2 const config4 const config6 statuses & current
Definition scheduler_fuel_controller.cpp:506
static uint8_t getTotalInjChannelCount(const statuses &current)
Definition statuses.h:335

◆ ASSIGN_ZERO_PW

#define ASSIGN_ZERO_PW (   index)    fuelSchedule ## index .pw = 0U;

◆ SET_CALLBACKS

#define SET_CALLBACKS (   index)    setCallbacks(fuelSchedule ## index, openInjector ## index, closeInjector ## index);\

◆ SET_FUEL_CHANNEL

#define SET_FUEL_CHANNEL (   channel)     setFuelChannelSchedule(fuelSchedule ##channel, UINT8_C(channel), crankAngle, injChannelMask, injAngle, &angleCalcCache);

Function Documentation

◆ _calculateOpenAngle()

TESTABLE_INLINE_STATIC uint16_t _calculateOpenAngle ( FuelSchedule schedule,
uint16_t  pwDegrees,
uint16_t  injAngle 
)

Compute the injector open angle for an injection channel.

Parameters
pwDegreesHow many crank degrees the calculated PW will take at the current speed
tdcOffsetThe number of crank degrees until cylinder is at TDC (at rest)
injAngleThe requested injection angle
Returns
uint16_t
Here is the caller graph for this function:

◆ applyFuelTrim()

static uint16_t applyFuelTrim ( const table3d6RpmLoad &  trimTable,
uint16_t  pw,
const config6 page6,
const statuses current 
)
inlinestatic
Here is the call graph for this function:

◆ assignPrimaryPws() [1/2]

static void assignPrimaryPws ( const pulseWidths pulse_widths,
const config6 page6,
const statuses current 
)
inlinestatic

◆ assignPrimaryPws() [2/2]

assignPrimaryPws ( pulse_widths  ,
page6  ,
current   
)

◆ assignSecondaryPws() [1/2]

static void assignSecondaryPws ( const pulseWidths pulse_widths,
const statuses current 
)
inlinestatic

◆ assignSecondaryPws() [2/2]

assignSecondaryPws ( pulse_widths  ,
current   
)

◆ BEGIN_LTO_ALWAYS_INLINE() [1/2]

BEGIN_LTO_ALWAYS_INLINE ( uint16_t  ) const &
Here is the call graph for this function:

◆ BEGIN_LTO_ALWAYS_INLINE() [2/2]

BEGIN_LTO_ALWAYS_INLINE ( void  ) const &
Here is the call graph for this function:

◆ beginInjectorPriming()

void beginInjectorPriming ( const statuses current,
const config4 page4 
)

Start priming the fuel system.

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:

◆ calculateInjectorTimeout()

TESTABLE_INLINE_STATIC uint32_t calculateInjectorTimeout ( const FuelSchedule schedule,
int16_t  crankAngle,
uint16_t  openAngle 
)

Calculate the time in uS from now to when the injector should be opened.

Parameters
scheduleThe ignition channel
openAngleThe angle at which to open the injector
crankAngleThe current crank angle
Returns
uint32_t
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calulateDefaultSquirts()

static uint8_t calulateDefaultSquirts ( const config2 page2)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ changeFuellingToFullSequential()

static void changeFuellingToFullSequential ( const config2 page2,
statuses current 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ changeFuellingToSemiSequential()

static void changeFuellingToSemiSequential ( const config2 page2,
const config4 page4,
statuses current 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ changeToFullSequentialInjection()

TESTABLE_INLINE_STATIC bool changeToFullSequentialInjection ( const config2 page2,
const decoder_status_t decoderStatus 
)
Here is the caller graph for this function:

◆ changeToSemiSequentialInjection()

TESTABLE_INLINE_STATIC bool changeToSemiSequentialInjection ( const config2 page2,
const decoder_status_t decoderStatus 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clampInjectionChannelAngles()

static void clampInjectionChannelAngles ( void  )
static

Limit all injection schedule channel angles to 0-CRANK_ANGLE_MAX_INJ.

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

◆ closeAllInjectors()

void closeAllInjectors ( void  )

Utility function to close all injectors.

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

◆ initFuelScheduleAngles()

static void initFuelScheduleAngles ( statuses current,
const config2 page2,
const config10 page10 
)
static
Here is the caller graph for this function:

◆ initialiseFuelSchedules()

void initialiseFuelSchedules ( statuses current,
const config2 page2,
const config4 page4,
const config10 page10,
const pinNumbers_t pins 
)

Initialise this module.

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

◆ injectorLimits()

TESTABLE_INLINE_STATIC uint16_t injectorLimits ( uint16_t  angle)

Clamp the angle to within [0,CRANK_ANGLE_MAX_INJ].

Here is the caller graph for this function:

◆ isAnyFuelScheduleRunning()

TESTABLE_INLINE_STATIC bool isAnyFuelScheduleRunning ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSwitchableCylinderCount()

static bool isSwitchableCylinderCount ( const config2 page2)
inlinestatic
Here is the caller graph for this function:

◆ lookupInjectorAngle()

TESTABLE_INLINE_STATIC uint16_t lookupInjectorAngle ( const statuses current)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ matchFuelSchedulersToSyncState()

TESTABLE_STATIC void matchFuelSchedulersToSyncState ( const config2 page2,
const config4 page4,
statuses current 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetFuelSchedules()

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

◆ setFuelChannelSchedule()

TESTABLE_INLINE_STATIC void setFuelChannelSchedule ( FuelSchedule schedule,
uint8_t  channel,
uint16_t  crankAngle,
byte  injChannelMask,
uint16_t  injAngle,
injectorAngleCalcCache pCache 
)
noexcept
Here is the call graph for this function:

◆ setFuelChannelSchedules()

TESTABLE_INLINE_STATIC uint16_t setFuelChannelSchedules ( uint16_t  crankAngle,
byte  injChannelMask,
uint16_t  injAngle 
)
Here is the caller graph for this function:

◆ setupCallbacks()

static void setupCallbacks ( uint8_t  injLayout,
uint8_t  nCylinders,
uint8_t  inj4cylPairing 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setupPairedCallbacks()

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

◆ setupSemiSequentialCallbacks()

static void setupSemiSequentialCallbacks ( uint8_t  nCylinders,
uint8_t  inj4cylPairing 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setupSequentialCallbacks()

static void setupSequentialCallbacks ( void  )
static
Here is the caller graph for this function:

◆ startFuelSchedulers()

void startFuelSchedulers ( void  )

Start the timers that drive schedulers.

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

◆ stopFuelSchedulers()

void stopFuelSchedulers ( void  )

Stop the timers that drive schedulers.

Here is the call graph for this function:

◆ updatePwAngleCache()

TESTABLE_INLINE_STATIC uint16_t updatePwAngleCache ( uint16_t  pw,
injectorAngleCalcCache pCache 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zeroAllChannels()

zeroAllChannels ( void  )
inlinestatic
Here is the caller graph for this function:

Variable Documentation

◆ configPage2

TESTABLE_CONSTEXPR table2D_u8_u8_4 PrimingPulseTable& configPage2

◆ current

const config2 const config4 const config6 statuses& current
Initial value:
{
const config2 & page2
Definition scheduler_fuel_controller.cpp:506
TESTABLE_STATIC void matchFuelSchedulersToSyncState(const config2 &page2, const config4 &page4, statuses &current)
Definition scheduler_fuel_controller.cpp:219
const config2 const config4 & page4
Definition scheduler_fuel_controller.cpp:506

◆ fuelSchedule1

◆ page2

const config2& page2

◆ page4

const config2 const config4& page4

◆ page6

const config2 const config4 const config6& page6