![]() |
Speeduino
|
#include "globals.h"#include "scheduler.h"#include "timers.h"#include "schedule_calcs.h"#include "preprocessor.h"#include "units.h"#include "schedule_state_machine.h"#include "unit_testing.h"#include "decoders.h"#include "scheduledIO_inj.h"Functions | |
| void | nullCallback (void) |
| A scheduler callback that does nothing. | |
| void | initialiseFuelSchedulers (void) |
| Initialize all schedulers to the OFF state. | |
| void | startFuelSchedulers (void) |
| Start the timers that drive schedulers | |
| void | stopFuelSchedulers (void) |
| Stop the timers that drive schedulers | |
| void | setCallbacks (Schedule &schedule, Schedule::callback pStartCallback, Schedule::callback pEndCallback) noexcept |
| Set the schedule callbacks. I.e the functions called when the action needs to start & stop. | |
| static uint16_t | clipDuration (uint16_t duration) |
| static void | setScheduleNext (Schedule &schedule, uint32_t delay, uint16_t duration) noexcept |
| static void | setScheduleRunning (Schedule &schedule, uint32_t delay, uint16_t duration) noexcept |
| 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 | beginInjectorPriming (void) |
| Start fuel system priming the fuel. | |
| void | moveToNextState (FuelSchedule &schedule) noexcept |
| Shared fuel schedule timer ISR implementation. Should be called by the actual timer ISRs (as timed interrupts) when either the start time or the duration time are reached. See Schedule finite state machine. | |
| template<typename T > | |
| static void | increment_volatile (volatile T &value) |
| Increment a volatile variable correctly. | |
| static void | onEndIgnitionEvent (const IgnitionSchedule *pSchedule) |
| Called when an ignition event ends. I.e. a spark fires. | |
| BEGIN_LTO_ALWAYS_INLINE (void) static ignitionPendingToRunning(Schedule *pSchedule) | |
| Called when the supplied schedule transitions from a PENDING state to RUNNING. | |
| void | moveToNextState (IgnitionSchedule &schedule) noexcept |
| Shared ignition schedule timer ISR implementation. Should be called by the actual ignition timer ISRs (as timed interrupts) when either the start time or the duration time are reached. See Schedule finite state machine. | |
| static bool | isAnyFuelScheduleRunning (void) |
| static void | changeFuellingToFullSequential (const config2 &page2, statuses ¤t) |
| void | changeHalfToFullSync (const config2 &page2, statuses ¤t) |
| static void | changeFuellingtoHalfSync (const config2 &page2, const config4 &page4, statuses ¤t) |
| void | changeFullToHalfSync (const config2 &page2, const config4 &page4, statuses ¤t) |
Injector and Ignition (on/off) scheduling (functions). There is usually 8 functions for cylinders 1-8 with same naming pattern.
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.
For Injection:
For Ignition (has more complex schedule setup):
Start fuel system priming the fuel.
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




Initialize all schedulers to the OFF state.
< 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


A scheduler callback that does nothing.

|
noexcept |
Set the schedule callbacks. I.e the functions called when the action needs to start & stop.
| schedule | Schedule to modify |
| pStartCallback | The new start callback - called when the schedule switches to RUNNING status |
| pEndCallback | The new end callback - called when the schedule switches from RUNNING to OFF status |


| 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.
| schedule | Schedule to modify |
| delay | Delay until the action starts (µS) |
| duration | Action duration (µS) |
| allowQueuedSchedule | true to allow a schedule to be queued up if one is currently running; false otherwise |


|
inlinestaticnoexcept |


|
inlinestaticnoexcept |


Start the timers that drive schedulers


Stop the timers that drive schedulers

|
constexpr |
| FuelSchedule fuelSchedule1(FUEL1_COUNTER, FUEL1_COMPARE) | ( | FUEL1_COUNTER | , |
| FUEL1_COMPARE | |||
| ) |
| FuelSchedule fuelSchedule2(FUEL2_COUNTER, FUEL2_COMPARE) | ( | FUEL2_COUNTER | , |
| FUEL2_COMPARE | |||
| ) |
| FuelSchedule fuelSchedule3(FUEL3_COUNTER, FUEL3_COMPARE) | ( | FUEL3_COUNTER | , |
| FUEL3_COMPARE | |||
| ) |
| FuelSchedule fuelSchedule4(FUEL4_COUNTER, FUEL4_COMPARE) | ( | FUEL4_COUNTER | , |
| FUEL4_COMPARE | |||
| ) |