2023-03-05 22:23:17 -08:00
# pragma once
# include <stdint.h>
# include "scheduler.h"
extern int ignition1StartAngle ;
2023-06-25 19:13:53 -07:00
extern int ignition1EndAngle ;
extern int channel1IgnDegrees ; /**< 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) */
2023-03-05 22:23:17 -08:00
extern int ignition2StartAngle ;
2023-06-25 19:13:53 -07:00
extern int ignition2EndAngle ;
extern int channel2IgnDegrees ; /**< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC */
2023-03-05 22:23:17 -08:00
extern int ignition3StartAngle ;
2023-06-25 19:13:53 -07:00
extern int ignition3EndAngle ;
extern int channel3IgnDegrees ; /**< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC */
2023-03-05 22:23:17 -08:00
extern int ignition4StartAngle ;
2023-06-25 19:13:53 -07:00
extern int ignition4EndAngle ;
extern int channel4IgnDegrees ; /**< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC */
# if (IGN_CHANNELS >= 5)
2023-03-05 22:23:17 -08:00
extern int ignition5StartAngle ;
2023-06-25 19:13:53 -07:00
extern int ignition5EndAngle ;
extern int channel5IgnDegrees ; /**< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC */
# endif
# if (IGN_CHANNELS >= 6)
2023-03-05 22:23:17 -08:00
extern int ignition6StartAngle ;
2023-06-25 19:13:53 -07:00
extern int ignition6EndAngle ;
extern int channel6IgnDegrees ; /**< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC */
# endif
# if (IGN_CHANNELS >= 7)
2023-03-05 22:23:17 -08:00
extern int ignition7StartAngle ;
2023-06-25 19:13:53 -07:00
extern int ignition7EndAngle ;
extern int channel7IgnDegrees ; /**< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC */
# endif
# if (IGN_CHANNELS >= 8)
2023-03-05 22:23:17 -08:00
extern int ignition8StartAngle ;
2023-06-25 19:13:53 -07:00
extern int ignition8EndAngle ;
extern int channel8IgnDegrees ; /**< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC */
# endif
2023-03-05 22:23:17 -08:00
extern int channel1InjDegrees ; /**< 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) */
extern int channel2InjDegrees ; /**< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC */
extern int channel3InjDegrees ; /**< The number of crank degrees until cylinder 3 (and 5/6/7/8) is at TDC */
extern int channel4InjDegrees ; /**< The number of crank degrees until cylinder 4 (and 5/6/7/8) is at TDC */
2023-06-25 19:13:53 -07:00
# if (INJ_CHANNELS >= 5)
2023-03-05 22:23:17 -08:00
extern int channel5InjDegrees ; /**< The number of crank degrees until cylinder 5 is at TDC */
2023-06-25 19:13:53 -07:00
# endif
# if (INJ_CHANNELS >= 6)
2023-03-05 22:23:17 -08:00
extern int channel6InjDegrees ; /**< The number of crank degrees until cylinder 6 is at TDC */
2023-06-25 19:13:53 -07:00
# endif
# if (INJ_CHANNELS >= 7)
2023-03-05 22:23:17 -08:00
extern int channel7InjDegrees ; /**< The number of crank degrees until cylinder 7 is at TDC */
2023-06-25 19:13:53 -07:00
# endif
# if (INJ_CHANNELS >= 8)
2023-03-05 22:23:17 -08:00
extern int channel8InjDegrees ; /**< The number of crank degrees until cylinder 8 is at TDC */
2023-06-25 19:13:53 -07:00
# endif
2023-11-05 14:10:08 -08:00
static inline uint16_t __attribute__ ( ( always_inline ) ) calculateInjectorStartAngle ( uint16_t PWdivTimerPerDegree , int16_t injChannelDegrees , uint16_t injAngle ) ;
2023-06-25 19:13:53 -07:00
2023-11-05 14:10:08 -08:00
static inline uint32_t __attribute__ ( ( always_inline ) ) calculateInjectorTimeout ( const FuelSchedule & schedule , int channelInjDegrees , int injectorStartAngle , int crankAngle ) ;
2023-06-25 19:13:53 -07:00
2024-03-20 17:45:10 -07:00
static inline void __attribute__ ( ( always_inline ) ) calculateIgnitionAngle ( const uint16_t dwellAngle , const uint16_t channelIgnDegrees , int8_t advance , int * pEndAngle , int * pStartAngle ) ;
2023-06-25 19:13:53 -07:00
// Ignition for rotary.
2024-03-20 17:45:10 -07:00
static inline void __attribute__ ( ( always_inline ) ) calculateIgnitionTrailingRotary ( uint16_t dwellAngle , int rotarySplitDegrees , int leadIgnitionAngle , int * pEndAngle , int * pStartAngle ) ;
2023-03-05 22:23:17 -08:00
2023-11-05 14:10:08 -08:00
static inline uint32_t __attribute__ ( ( always_inline ) ) calculateIgnitionTimeout ( const IgnitionSchedule & schedule , int startAngle , int channelIgnDegrees , int crankAngle ) ;
2023-03-05 22:23:17 -08:00
2023-10-06 14:25:26 -07:00
# include "schedule_calcs.hpp"