From c6bb42399e67449be4469ecd51585059075433be Mon Sep 17 00:00:00 2001 From: tx_haggis <13982343+adbancroft@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:44:06 -0500 Subject: [PATCH] ARM cores call moveToNextState directly --- speeduino/board_stm32_official.cpp | 52 ++++++++++------ speeduino/board_teensy35.cpp | 32 +++++----- speeduino/board_teensy41.cpp | 32 +++++----- speeduino/scheduler.cpp | 35 +++-------- speeduino/scheduler.h | 97 ++++++++++-------------------- 5 files changed, 102 insertions(+), 146 deletions(-) diff --git a/speeduino/board_stm32_official.cpp b/speeduino/board_stm32_official.cpp index 71267fcf69..f14eeca8de 100644 --- a/speeduino/board_stm32_official.cpp +++ b/speeduino/board_stm32_official.cpp @@ -84,45 +84,57 @@ STM32RTC& rtc = STM32RTC::getInstance(); *********************************************************************************************************** * Interrupt callback functions */ + #define IGNITION_INTERRUPT_NAME(index) CONCAT(CONCAT(ignitionSchedule, index), Interrupt) + #define FUEL_INTERRUPT_NAME(index) CONCAT(CONCAT(fuelSchedule, index), Interrupt) + + #if ((STM32_CORE_VERSION_MINOR<=8) & (STM32_CORE_VERSION_MAJOR==1)) void oneMSInterval(HardwareTimer*){oneMSInterval();} void boostInterrupt(HardwareTimer*){boostInterrupt();} - void fuelSchedule1Interrupt(HardwareTimer*){FUEL_INTERRUPT_NAME(1)();} - void fuelSchedule2Interrupt(HardwareTimer*){FUEL_INTERRUPT_NAME(2)();} - void fuelSchedule3Interrupt(HardwareTimer*){FUEL_INTERRUPT_NAME(3)();} - void fuelSchedule4Interrupt(HardwareTimer*){FUEL_INTERRUPT_NAME(4)();} + void idleInterrupt(HardwareTimer*){idleInterrupt();} + void vvtInterrupt(HardwareTimer*){vvtInterrupt();} + void fanInterrupt(HardwareTimer*){fanInterrupt();} + #define STM_FUEL_INTERRUPT(index) void FUEL_INTERRUPT_NAME(index)(HardwareTimer*) {moveToNextState(fuelSchedule ## index);} + #define STM_IGNITION_INTERRUPT(index) void IGNITION_INTERRUPT_NAME(index)(HardwareTimer*) {moveToNextState(ignitionSchedule ## index);} + #else //End core<=1.8 + #define STM_FUEL_INTERRUPT(index) void FUEL_INTERRUPT_NAME(index)(void) {moveToNextState(fuelSchedule ## index);} + #define STM_IGNITION_INTERRUPT(index) void IGNITION_INTERRUPT_NAME(index)(void) {moveToNextState(ignitionSchedule ## index);} + #endif + + STM_FUEL_INTERRUPT(1) + STM_FUEL_INTERRUPT(2) + STM_FUEL_INTERRUPT(3) + STM_FUEL_INTERRUPT(4) #if (INJ_CHANNELS >= 5) - void fuelSchedule5Interrupt(HardwareTimer*){FUEL_INTERRUPT_NAME(5)();} + STM_FUEL_INTERRUPT(5) #endif #if (INJ_CHANNELS >= 6) - void fuelSchedule6Interrupt(HardwareTimer*){FUEL_INTERRUPT_NAME(6)();} + STM_FUEL_INTERRUPT(6) #endif #if (INJ_CHANNELS >= 7) - void fuelSchedule7Interrupt(HardwareTimer*){FUEL_INTERRUPT_NAME(7)();} + STM_FUEL_INTERRUPT(7) #endif #if (INJ_CHANNELS >= 8) - void fuelSchedule8Interrupt(HardwareTimer*){FUEL_INTERRUPT_NAME(8)();} + STM_FUEL_INTERRUPT(8) #endif - void idleInterrupt(HardwareTimer*){idleInterrupt();} - void vvtInterrupt(HardwareTimer*){vvtInterrupt();} - void fanInterrupt(HardwareTimer*){fanInterrupt();} - void ignitionSchedule1Interrupt(HardwareTimer*){IGNITION_INTERRUPT_NAME(1)();} - void ignitionSchedule2Interrupt(HardwareTimer*){IGNITION_INTERRUPT_NAME(2)();} - void ignitionSchedule3Interrupt(HardwareTimer*){IGNITION_INTERRUPT_NAME(3)();} - void ignitionSchedule4Interrupt(HardwareTimer*){IGNITION_INTERRUPT_NAME(4)();} + + STM_IGNITION_INTERRUPT(1) + STM_IGNITION_INTERRUPT(2) + STM_IGNITION_INTERRUPT(3) + STM_IGNITION_INTERRUPT(4) #if (IGN_CHANNELS >= 5) - void ignitionSchedule5Interrupt(HardwareTimer*){IGNITION_INTERRUPT_NAME(5)();} + STM_IGNITION_INTERRUPT(5) #endif #if (IGN_CHANNELS >= 6) - void ignitionSchedule6Interrupt(HardwareTimer*){IGNITION_INTERRUPT_NAME(6)();} + STM_IGNITION_INTERRUPT(6) #endif #if (IGN_CHANNELS >= 7) - void ignitionSchedule7Interrupt(HardwareTimer*){IGNITION_INTERRUPT_NAME(7)();} + STM_IGNITION_INTERRUPT(7) #endif #if (IGN_CHANNELS >= 8) - void ignitionSchedule8Interrupt(HardwareTimer*){IGNITION_INTERRUPT_NAME(8)();} + STM_IGNITION_INTERRUPT(8) #endif - #endif //End core<=1.8 + void initBoard() { diff --git a/speeduino/board_teensy35.cpp b/speeduino/board_teensy35.cpp index 57bb494350..9d52e6ce13 100644 --- a/speeduino/board_teensy35.cpp +++ b/speeduino/board_teensy35.cpp @@ -315,14 +315,14 @@ void ftm0_isr(void) bool interrupt7 = (FTM0_C6SC & FTM_CSC_CHF); bool interrupt8 = (FTM0_C7SC & FTM_CSC_CHF); - if(interrupt1) { FTM0_C0SC &= ~FTM_CSC_CHF; FUEL_INTERRUPT_NAME(1)(); } - else if(interrupt2) { FTM0_C1SC &= ~FTM_CSC_CHF; FUEL_INTERRUPT_NAME(2)(); } - else if(interrupt3) { FTM0_C2SC &= ~FTM_CSC_CHF; FUEL_INTERRUPT_NAME(3)(); } - else if(interrupt4) { FTM0_C3SC &= ~FTM_CSC_CHF; FUEL_INTERRUPT_NAME(4)(); } - else if(interrupt5) { FTM0_C4SC &= ~FTM_CSC_CHF; IGNITION_INTERRUPT_NAME(1)(); } - else if(interrupt6) { FTM0_C5SC &= ~FTM_CSC_CHF; IGNITION_INTERRUPT_NAME(2)(); } - else if(interrupt7) { FTM0_C6SC &= ~FTM_CSC_CHF; IGNITION_INTERRUPT_NAME(3)(); } - else if(interrupt8) { FTM0_C7SC &= ~FTM_CSC_CHF; IGNITION_INTERRUPT_NAME(4)(); } + if(interrupt1) { FTM0_C0SC &= ~FTM_CSC_CHF; moveToNextState(fuelSchedule1); } + else if(interrupt2) { FTM0_C1SC &= ~FTM_CSC_CHF; moveToNextState(fuelSchedule2); } + else if(interrupt3) { FTM0_C2SC &= ~FTM_CSC_CHF; moveToNextState(fuelSchedule3); } + else if(interrupt4) { FTM0_C3SC &= ~FTM_CSC_CHF; moveToNextState(fuelSchedule4); } + else if(interrupt5) { FTM0_C4SC &= ~FTM_CSC_CHF; moveToNextState(ignitionSchedule1); } + else if(interrupt6) { FTM0_C5SC &= ~FTM_CSC_CHF; moveToNextState(ignitionSchedule2); } + else if(interrupt7) { FTM0_C6SC &= ~FTM_CSC_CHF; moveToNextState(ignitionSchedule3); } + else if(interrupt8) { FTM0_C7SC &= ~FTM_CSC_CHF; moveToNextState(ignitionSchedule4); } } void ftm3_isr(void) @@ -330,35 +330,35 @@ void ftm3_isr(void) #if (INJ_CHANNELS >= 5) bool interrupt1 = (FTM3_C0SC & FTM_CSC_CHF); - if(interrupt1) { FTM3_C0SC &= ~FTM_CSC_CHF; FUEL_INTERRUPT_NAME(5)(); } + if(interrupt1) { FTM3_C0SC &= ~FTM_CSC_CHF; moveToNextState(fuelSchedule5); } #endif #if (INJ_CHANNELS >= 6) bool interrupt2 = (FTM3_C1SC & FTM_CSC_CHF); - if(interrupt2) { FTM3_C1SC &= ~FTM_CSC_CHF; FUEL_INTERRUPT_NAME(6)(); } + if(interrupt2) { FTM3_C1SC &= ~FTM_CSC_CHF; moveToNextState(fuelSchedule6); } #endif #if (INJ_CHANNELS >= 7) bool interrupt3 = (FTM3_C2SC & FTM_CSC_CHF); - if(interrupt3) { FTM3_C2SC &= ~FTM_CSC_CHF; FUEL_INTERRUPT_NAME(7)(); } + if(interrupt3) { FTM3_C2SC &= ~FTM_CSC_CHF; moveToNextState(fuelSchedule7); } #endif #if (INJ_CHANNELS >= 8) bool interrupt4 = (FTM3_C3SC & FTM_CSC_CHF); - if(interrupt4) { FTM3_C3SC &= ~FTM_CSC_CHF; FUEL_INTERRUPT_NAME(8)(); } + if(interrupt4) { FTM3_C3SC &= ~FTM_CSC_CHF; moveToNextState(fuelSchedule8); } #endif #if (IGN_CHANNELS >= 5) bool interrupt5 = (FTM3_C4SC & FTM_CSC_CHF); - if(interrupt5) { FTM3_C4SC &= ~FTM_CSC_CHF; IGNITION_INTERRUPT_NAME(5)(); } + if(interrupt5) { FTM3_C4SC &= ~FTM_CSC_CHF; moveToNextState(ignitionSchedule5); } #endif #if (IGN_CHANNELS >= 6) bool interrupt6 = (FTM3_C5SC & FTM_CSC_CHF); - if(interrupt6) { FTM3_C5SC &= ~FTM_CSC_CHF; IGNITION_INTERRUPT_NAME(6)(); } + if(interrupt6) { FTM3_C5SC &= ~FTM_CSC_CHF; moveToNextState(ignitionSchedule6); } #endif #if (IGN_CHANNELS >= 7) bool interrupt7 = (FTM3_C6SC & FTM_CSC_CHF); - if(interrupt7) { FTM3_C6SC &= ~FTM_CSC_CHF; IGNITION_INTERRUPT_NAME(7)(); } + if(interrupt7) { FTM3_C6SC &= ~FTM_CSC_CHF; moveToNextState(ignitionSchedule7); } #endif #if (IGN_CHANNELS >= 8) bool interrupt8 = (FTM3_C7SC & FTM_CSC_CHF); - if(interrupt8) { FTM3_C7SC &= ~FTM_CSC_CHF; IGNITION_INTERRUPT_NAME(8)(); } + if(interrupt8) { FTM3_C7SC &= ~FTM_CSC_CHF; moveToNextState(ignitionSchedule8); } #endif } diff --git a/speeduino/board_teensy41.cpp b/speeduino/board_teensy41.cpp index 1917dfbb26..329e390492 100644 --- a/speeduino/board_teensy41.cpp +++ b/speeduino/board_teensy41.cpp @@ -235,10 +235,10 @@ void TMR1_isr(void) bool interrupt3 = (TMR1_CSCTRL2 & TMR_CSCTRL_TCF1); bool interrupt4 = (TMR1_CSCTRL3 & TMR_CSCTRL_TCF1); - if(interrupt1) { TMR1_CSCTRL0 &= ~TMR_CSCTRL_TCF1; FUEL_INTERRUPT_NAME(1)(); } - else if(interrupt2) { TMR1_CSCTRL1 &= ~TMR_CSCTRL_TCF1; FUEL_INTERRUPT_NAME(2)(); } - else if(interrupt3) { TMR1_CSCTRL2 &= ~TMR_CSCTRL_TCF1; FUEL_INTERRUPT_NAME(3)(); } - else if(interrupt4) { TMR1_CSCTRL3 &= ~TMR_CSCTRL_TCF1; FUEL_INTERRUPT_NAME(4)(); } + if(interrupt1) { TMR1_CSCTRL0 &= ~TMR_CSCTRL_TCF1; moveToNextState(fuelSchedule1); } + else if(interrupt2) { TMR1_CSCTRL1 &= ~TMR_CSCTRL_TCF1; moveToNextState(fuelSchedule2); } + else if(interrupt3) { TMR1_CSCTRL2 &= ~TMR_CSCTRL_TCF1; moveToNextState(fuelSchedule3); } + else if(interrupt4) { TMR1_CSCTRL3 &= ~TMR_CSCTRL_TCF1; moveToNextState(fuelSchedule4); } } void TMR2_isr(void) { @@ -248,10 +248,10 @@ void TMR2_isr(void) bool interrupt3 = (TMR2_CSCTRL2 & TMR_CSCTRL_TCF1); bool interrupt4 = (TMR2_CSCTRL3 & TMR_CSCTRL_TCF1); - if(interrupt1) { TMR2_CSCTRL0 &= ~TMR_CSCTRL_TCF1; IGNITION_INTERRUPT_NAME(1)(); } - else if(interrupt2) { TMR2_CSCTRL1 &= ~TMR_CSCTRL_TCF1; IGNITION_INTERRUPT_NAME(2)(); } - else if(interrupt3) { TMR2_CSCTRL2 &= ~TMR_CSCTRL_TCF1; IGNITION_INTERRUPT_NAME(3)(); } - else if(interrupt4) { TMR2_CSCTRL3 &= ~TMR_CSCTRL_TCF1; IGNITION_INTERRUPT_NAME(4)(); } + if(interrupt1) { TMR2_CSCTRL0 &= ~TMR_CSCTRL_TCF1; moveToNextState(ignitionSchedule1); } + else if(interrupt2) { TMR2_CSCTRL1 &= ~TMR_CSCTRL_TCF1; moveToNextState(ignitionSchedule2); } + else if(interrupt3) { TMR2_CSCTRL2 &= ~TMR_CSCTRL_TCF1; moveToNextState(ignitionSchedule3); } + else if(interrupt4) { TMR2_CSCTRL3 &= ~TMR_CSCTRL_TCF1; moveToNextState(ignitionSchedule4); } } void TMR3_isr(void) { @@ -261,10 +261,10 @@ void TMR3_isr(void) bool interrupt3 = (TMR3_CSCTRL2 & TMR_CSCTRL_TCF1); bool interrupt4 = (TMR3_CSCTRL3 & TMR_CSCTRL_TCF1); - if(interrupt1) { TMR3_CSCTRL0 &= ~TMR_CSCTRL_TCF1; FUEL_INTERRUPT_NAME(5)(); } - else if(interrupt2) { TMR3_CSCTRL1 &= ~TMR_CSCTRL_TCF1; FUEL_INTERRUPT_NAME(6)(); } - else if(interrupt3) { TMR3_CSCTRL2 &= ~TMR_CSCTRL_TCF1; FUEL_INTERRUPT_NAME(7)(); } - else if(interrupt4) { TMR3_CSCTRL3 &= ~TMR_CSCTRL_TCF1; FUEL_INTERRUPT_NAME(8)(); } + if(interrupt1) { TMR3_CSCTRL0 &= ~TMR_CSCTRL_TCF1; moveToNextState(fuelSchedule5); } + else if(interrupt2) { TMR3_CSCTRL1 &= ~TMR_CSCTRL_TCF1; moveToNextState(fuelSchedule6); } + else if(interrupt3) { TMR3_CSCTRL2 &= ~TMR_CSCTRL_TCF1; moveToNextState(fuelSchedule7); } + else if(interrupt4) { TMR3_CSCTRL3 &= ~TMR_CSCTRL_TCF1; moveToNextState(fuelSchedule8); } } void TMR4_isr(void) { @@ -274,10 +274,10 @@ void TMR4_isr(void) bool interrupt3 = (TMR4_CSCTRL2 & TMR_CSCTRL_TCF1); bool interrupt4 = (TMR4_CSCTRL3 & TMR_CSCTRL_TCF1); - if(interrupt1) { TMR4_CSCTRL0 &= ~TMR_CSCTRL_TCF1; IGNITION_INTERRUPT_NAME(5)(); } - else if(interrupt2) { TMR4_CSCTRL1 &= ~TMR_CSCTRL_TCF1; IGNITION_INTERRUPT_NAME(6)(); } - else if(interrupt3) { TMR4_CSCTRL2 &= ~TMR_CSCTRL_TCF1; IGNITION_INTERRUPT_NAME(7)(); } - else if(interrupt4) { TMR4_CSCTRL3 &= ~TMR_CSCTRL_TCF1; IGNITION_INTERRUPT_NAME(8)(); } + if(interrupt1) { TMR4_CSCTRL0 &= ~TMR_CSCTRL_TCF1; moveToNextState(ignitionSchedule5); } + else if(interrupt2) { TMR4_CSCTRL1 &= ~TMR_CSCTRL_TCF1; moveToNextState(ignitionSchedule6); } + else if(interrupt3) { TMR4_CSCTRL2 &= ~TMR_CSCTRL_TCF1; moveToNextState(ignitionSchedule7); } + else if(interrupt4) { TMR4_CSCTRL3 &= ~TMR_CSCTRL_TCF1; moveToNextState(ignitionSchedule8); } } uint16_t freeRam() diff --git a/speeduino/scheduler.cpp b/speeduino/scheduler.cpp index 4b0369256b..d314bc81fb 100644 --- a/speeduino/scheduler.cpp +++ b/speeduino/scheduler.cpp @@ -307,13 +307,7 @@ extern void beginInjectorPriming(void) * @{ */ -/** - * @brief 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 @ref schedule-state-machine - * - * @param schedule The fuel schedule to move to the next state - */ -static inline __attribute__((always_inline)) void onFuelScheduleTimer(FuelSchedule &schedule) +void moveToNextState(FuelSchedule &schedule) { movetoNextState(schedule, defaultPendingToRunning, defaultRunningToOff, defaultRunningToPending); } @@ -322,14 +316,8 @@ static inline __attribute__((always_inline)) void onFuelScheduleTimer(FuelSchedu #if defined(CORE_AVR) //AVR chips use the ISR for this #define FUEL_INTERRUPT(index, avr_vector) \ ISR((avr_vector)) { \ - onFuelScheduleTimer(fuelSchedule ## index); \ - } -#else -#define FUEL_INTERRUPT(index, avr_vector) \ - void FUEL_INTERRUPT_NAME(index) (void) { \ - onFuelScheduleTimer(fuelSchedule ## index); \ + moveToNextState(fuelSchedule ## index); \ } -#endif /** @brief ISR for fuel channel 1 */ // cppcheck-suppress misra-c2012-8.2 @@ -369,6 +357,7 @@ FUEL_INTERRUPT(7, TIMER5_COMPC_vect) // cppcheck-suppress misra-c2012-8.2 FUEL_INTERRUPT(8, TIMER5_COMPB_vect) #endif +#endif ///@} @@ -420,13 +409,7 @@ static inline void ignitionRunningToPending(Schedule *pSchedule) { onEndIgnitionEvent((IgnitionSchedule *)pSchedule); } -/** - * @brief 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 @ref schedule-state-machine - * - * @param schedule The ignition schedule to move to the next state - */ -static inline __attribute__((always_inline)) void onIgnitionScheduleTimer(IgnitionSchedule &schedule) +void moveToNextState(IgnitionSchedule &schedule) { movetoNextState(schedule, ignitionPendingToRunning, ignitionRunningToOff, ignitionRunningToPending); } @@ -435,14 +418,8 @@ static inline __attribute__((always_inline)) void onIgnitionScheduleTimer(Igniti #if defined(CORE_AVR) //AVR chips use the ISR for this #define IGNITION_INTERRUPT(index, avr_vector) \ ISR((avr_vector)) { \ - onIgnitionScheduleTimer(ignitionSchedule ## index); \ - } -#else -#define IGNITION_INTERRUPT(index, avr_vector) \ - void IGNITION_INTERRUPT_NAME(index) (void) { \ - onIgnitionScheduleTimer(ignitionSchedule ## index); \ + moveToNextState(ignitionSchedule ## index); \ } -#endif /** @brief ISR for ignition channel 1 */ // cppcheck-suppress misra-c2012-8.2 @@ -482,6 +459,8 @@ IGNITION_INTERRUPT(7, TIMER3_COMPC_vect) IGNITION_INTERRUPT(8, TIMER3_COMPB_vect) #endif +#endif + ///@} void disablePendingFuelSchedule(byte channel) diff --git a/speeduino/scheduler.h b/speeduino/scheduler.h index 5840cf6d52..002de2cdf4 100644 --- a/speeduino/scheduler.h +++ b/speeduino/scheduler.h @@ -56,57 +56,6 @@ void disablePendingIgnSchedule(byte channel); void refreshIgnitionSchedule1(unsigned long timeToEnd); -//The ARM cores use separate functions for their ISRs -#if defined(ARDUINO_ARCH_STM32) || defined(CORE_TEENSY) - #define FUEL_INTERRUPT_NAME(index) CONCAT(CONCAT(fuelSchedule, index), Interrupt) - void FUEL_INTERRUPT_NAME(1)(void); -#if (INJ_CHANNELS >= 2) - void FUEL_INTERRUPT_NAME(2)(void); -#endif -#if (INJ_CHANNELS >= 3) - void FUEL_INTERRUPT_NAME(3)(void); -#endif -#if (INJ_CHANNELS >= 4) - void FUEL_INTERRUPT_NAME(4)(void); -#endif -#if (INJ_CHANNELS >= 5) - void FUEL_INTERRUPT_NAME(5)(void); -#endif -#if (INJ_CHANNELS >= 6) - void FUEL_INTERRUPT_NAME(6)(void); -#endif -#if (INJ_CHANNELS >= 7) - void FUEL_INTERRUPT_NAME(7)(void); -#endif -#if (INJ_CHANNELS >= 8) - void FUEL_INTERRUPT_NAME(8)(void); -#endif - - #define IGNITION_INTERRUPT_NAME(index) CONCAT(CONCAT(ignitionSchedule, index), Interrupt) - void IGNITION_INTERRUPT_NAME(1)(void); -#if (IGN_CHANNELS >= 2) - void IGNITION_INTERRUPT_NAME(2)(void); -#endif -#if (IGN_CHANNELS >= 3) - void IGNITION_INTERRUPT_NAME(3)(void); -#endif -#if (IGN_CHANNELS >= 4) - void IGNITION_INTERRUPT_NAME(4)(void); -#endif -#if (IGN_CHANNELS >= 5) - void IGNITION_INTERRUPT_NAME(5)(void); -#endif -#if (IGN_CHANNELS >= 6) - void IGNITION_INTERRUPT_NAME(6)(void); -#endif -#if (IGN_CHANNELS >= 7) - void IGNITION_INTERRUPT_NAME(7)(void); -#endif -#if (IGN_CHANNELS >= 8) - void IGNITION_INTERRUPT_NAME(8)(void); -#endif -#endif - /** \enum ScheduleStatus * @brief The current state of a schedule * */ @@ -216,6 +165,29 @@ static inline __attribute__((always_inline)) void setIgnitionSchedule(IgnitionSc interrupts(); } +/** + * @brief 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 @ref schedule-state-machine + * + * @param schedule The ignition schedule to move to the next state + */ +void moveToNextState(IgnitionSchedule &schedule); + +extern IgnitionSchedule ignitionSchedule1; +extern IgnitionSchedule ignitionSchedule2; +extern IgnitionSchedule ignitionSchedule3; +extern IgnitionSchedule ignitionSchedule4; +extern IgnitionSchedule ignitionSchedule5; +#if IGN_CHANNELS >= 6 +extern IgnitionSchedule ignitionSchedule6; +#endif +#if IGN_CHANNELS >= 7 +extern IgnitionSchedule ignitionSchedule7; +#endif +#if IGN_CHANNELS >= 8 +extern IgnitionSchedule ignitionSchedule8; +#endif + /** Fuel injection schedule. * Fuel schedules don't use the callback pointers, or the startTime/endScheduleSetByDecoder variables. * They are removed in this struct to save RAM. @@ -242,6 +214,14 @@ static inline __attribute__((always_inline)) void setFuelSchedule(FuelSchedule & } } +/** + * @brief 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 @ref schedule-state-machine + * + * @param schedule The fuel schedule to move to the next state + */ +void moveToNextState(FuelSchedule &schedule); + extern FuelSchedule fuelSchedule1; extern FuelSchedule fuelSchedule2; extern FuelSchedule fuelSchedule3; @@ -259,19 +239,4 @@ extern FuelSchedule fuelSchedule7; extern FuelSchedule fuelSchedule8; #endif -extern IgnitionSchedule ignitionSchedule1; -extern IgnitionSchedule ignitionSchedule2; -extern IgnitionSchedule ignitionSchedule3; -extern IgnitionSchedule ignitionSchedule4; -extern IgnitionSchedule ignitionSchedule5; -#if IGN_CHANNELS >= 6 -extern IgnitionSchedule ignitionSchedule6; -#endif -#if IGN_CHANNELS >= 7 -extern IgnitionSchedule ignitionSchedule7; -#endif -#if IGN_CHANNELS >= 8 -extern IgnitionSchedule ignitionSchedule8; -#endif - #endif // SCHEDULER_H