![]() |
Speeduino
|
#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 ¤t) |
| static void | changeFuellingToSemiSequential (const config2 &page2, const config4 &page4, statuses ¤t) |
| TESTABLE_STATIC void | matchFuelSchedulersToSyncState (const config2 &page2, const config4 &page4, statuses ¤t) |
| TESTABLE_INLINE_STATIC uint16_t | lookupInjectorAngle (const statuses ¤t) |
| 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 ¤t) | |
| static uint16_t | applyFuelTrim (const table3d6RpmLoad &trimTable, uint16_t pw, const config6 &page6, const statuses ¤t) |
| static void | assignPrimaryPws (const pulseWidths &pulse_widths, const config6 &page6, const statuses ¤t) |
| static void | assignSecondaryPws (const pulseWidths &pulse_widths, const statuses ¤t) |
| 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 ¤t, 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 ¤t, const config2 &page2, const config10 &page10) |
| static uint8_t | calulateDefaultSquirts (const config2 &page2) |
| void | initialiseFuelSchedules (statuses ¤t, 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 config2 & | page2 |
| const config2 const config4 & | page4 |
| const config2 const config4 const config6 & | page6 |
| const config2 const config4 const config6 statuses & | current |
| #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; |
| #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); |
| TESTABLE_INLINE_STATIC uint16_t _calculateOpenAngle | ( | FuelSchedule & | schedule, |
| uint16_t | pwDegrees, | ||
| uint16_t | injAngle | ||
| ) |
Compute the injector open angle for an injection channel.
| pwDegrees | How many crank degrees the calculated PW will take at the current speed |
| tdcOffset | The number of crank degrees until cylinder is at TDC (at rest) |
| injAngle | The requested injection angle |

|
inlinestatic |

|
inlinestatic |
|
inlinestatic |
| assignSecondaryPws | ( | pulse_widths | , |
| current | |||
| ) |
| BEGIN_LTO_ALWAYS_INLINE | ( | uint16_t | ) | const & |

| BEGIN_LTO_ALWAYS_INLINE | ( | void | ) | const & |

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


| 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.
| schedule | The ignition channel |
| openAngle | The angle at which to open the injector |
| crankAngle | The current crank angle |


|
static |


|
inlinestatic |


|
inlinestatic |


| TESTABLE_INLINE_STATIC bool changeToFullSequentialInjection | ( | const config2 & | page2, |
| const decoder_status_t & | decoderStatus | ||
| ) |

| TESTABLE_INLINE_STATIC bool changeToSemiSequentialInjection | ( | const config2 & | page2, |
| const decoder_status_t & | decoderStatus | ||
| ) |


|
static |
Limit all injection schedule channel angles to 0-CRANK_ANGLE_MAX_INJ.


| void closeAllInjectors | ( | void | ) |
Utility function to close all injectors.


|
static |

| void initialiseFuelSchedules | ( | statuses & | current, |
| const config2 & | page2, | ||
| const config4 & | page4, | ||
| const config10 & | page10, | ||
| const pinNumbers_t & | pins | ||
| ) |
Initialise this module.


| TESTABLE_INLINE_STATIC uint16_t injectorLimits | ( | uint16_t | angle | ) |
Clamp the angle to within [0,CRANK_ANGLE_MAX_INJ].

| TESTABLE_INLINE_STATIC bool isAnyFuelScheduleRunning | ( | void | ) |


|
inlinestatic |

| TESTABLE_INLINE_STATIC uint16_t lookupInjectorAngle | ( | const statuses & | current | ) |


| TESTABLE_STATIC void matchFuelSchedulersToSyncState | ( | const config2 & | page2, |
| const config4 & | page4, | ||
| statuses & | current | ||
| ) |


|
static |


|
noexcept |

| TESTABLE_INLINE_STATIC uint16_t setFuelChannelSchedules | ( | uint16_t | crankAngle, |
| byte | injChannelMask, | ||
| uint16_t | injAngle | ||
| ) |

|
static |


|
static |


|
static |


|
static |

| void startFuelSchedulers | ( | void | ) |
Start the timers that drive schedulers.


| void stopFuelSchedulers | ( | void | ) |
Stop the timers that drive schedulers.

| TESTABLE_INLINE_STATIC uint16_t updatePwAngleCache | ( | uint16_t | pw, |
| injectorAngleCalcCache * | pCache | ||
| ) |


|
inlinestatic |

| TESTABLE_CONSTEXPR table2D_u8_u8_4 PrimingPulseTable& configPage2 |
| FuelSchedule fuelSchedule1(FUEL1_COUNTER, FUEL1_COMPARE) | ( | FUEL1_COUNTER | , |
| FUEL1_COMPARE | |||
| ) |
| const config2& page2 |