2016-10-06 23:34:27 -07:00
|
|
|
#ifndef AUX_H
|
|
|
|
#define AUX_H
|
2015-09-26 16:14:29 -07:00
|
|
|
|
2016-10-06 23:34:27 -07:00
|
|
|
void initialiseAuxPWM();
|
|
|
|
void boostControl();
|
|
|
|
void vvtControl();
|
2016-10-25 07:04:37 -07:00
|
|
|
void initialiseFan();
|
2018-06-29 08:19:51 -07:00
|
|
|
void nitrousControl();
|
2015-09-26 16:14:29 -07:00
|
|
|
|
2017-07-23 23:04:29 -07:00
|
|
|
#if defined(CORE_AVR)
|
2017-07-23 23:34:13 -07:00
|
|
|
#define ENABLE_BOOST_TIMER() TIMSK1 |= (1 << OCIE1A)
|
2017-07-23 23:04:29 -07:00
|
|
|
#define DISABLE_BOOST_TIMER() TIMSK1 &= ~(1 << OCIE1A)
|
2017-07-23 23:34:13 -07:00
|
|
|
#define ENABLE_VVT_TIMER() TIMSK1 |= (1 << OCIE1B)
|
|
|
|
#define DISABLE_VVT_TIMER() TIMSK1 &= ~(1 << OCIE1B)
|
|
|
|
|
|
|
|
#define BOOST_TIMER_COMPARE OCR1A
|
|
|
|
#define BOOST_TIMER_COUNTER TCNT1
|
|
|
|
#define VVT_TIMER_COMPARE OCR1B
|
|
|
|
#define VVT_TIMER_COUNTER TCNT1
|
|
|
|
|
|
|
|
#elif defined(CORE_TEENSY)
|
|
|
|
#define ENABLE_BOOST_TIMER() FTM1_C0SC |= FTM_CSC_CHIE
|
|
|
|
#define DISABLE_BOOST_TIMER() FTM1_C0SC &= ~FTM_CSC_CHIE
|
|
|
|
|
|
|
|
#define ENABLE_VVT_TIMER() FTM1_C1SC |= FTM_CSC_CHIE
|
|
|
|
#define DISABLE_VVT_TIMER() FTM1_C1SC &= ~FTM_CSC_CHIE
|
|
|
|
|
|
|
|
#define BOOST_TIMER_COMPARE FTM1_C0V
|
|
|
|
#define BOOST_TIMER_COUNTER FTM1_CNT
|
|
|
|
#define VVT_TIMER_COMPARE FTM1_C1V
|
|
|
|
#define VVT_TIMER_COUNTER FTM1_CNT
|
|
|
|
|
|
|
|
#elif defined(CORE_STM32)
|
2017-08-27 21:35:49 -07:00
|
|
|
#if defined(ARDUINO_ARCH_STM32) // STM32GENERIC core
|
|
|
|
#define ENABLE_BOOST_TIMER() (TIM1)->CCER |= TIM_CCER_CC2E
|
|
|
|
#define DISABLE_BOOST_TIMER() (TIM1)->CCER &= ~TIM_CCER_CC2E
|
|
|
|
|
|
|
|
#define ENABLE_VVT_TIMER() (TIM1)->CCER |= TIM_CCER_CC3E
|
|
|
|
#define DISABLE_VVT_TIMER() (TIM1)->CCER &= ~TIM_CCER_CC3E
|
|
|
|
|
|
|
|
#define BOOST_TIMER_COMPARE (TIM1)->CCR2
|
|
|
|
#define BOOST_TIMER_COUNTER (TIM1)->CNT
|
|
|
|
#define VVT_TIMER_COMPARE (TIM1)->CCR3
|
|
|
|
#define VVT_TIMER_COUNTER (TIM1)->CNT
|
|
|
|
#else //libmaple core aka STM32DUINO
|
|
|
|
#define ENABLE_BOOST_TIMER() (TIMER1->regs).gen->CCER |= TIMER_CCER_CC2E
|
|
|
|
#define DISABLE_BOOST_TIMER() (TIMER1->regs).gen->CCER &= ~TIMER_CCER_CC2E
|
|
|
|
|
|
|
|
#define ENABLE_VVT_TIMER() (TIMER1->regs).gen->CCER |= TIMER_CCER_CC3E
|
|
|
|
#define DISABLE_VVT_TIMER() (TIMER1->regs).gen->CCER &= ~TIMER_CCER_CC3E
|
|
|
|
|
|
|
|
#define BOOST_TIMER_COMPARE (TIMER1->regs).gen->CCR2
|
|
|
|
#define BOOST_TIMER_COUNTER (TIMER1->regs).gen->CNT
|
|
|
|
#define VVT_TIMER_COMPARE (TIMER1->regs).gen->CCR3
|
|
|
|
#define VVT_TIMER_COUNTER (TIMER1->regs).gen->CNT
|
|
|
|
#endif
|
2017-07-23 23:04:29 -07:00
|
|
|
#endif
|
|
|
|
|
2017-07-23 23:34:13 -07:00
|
|
|
#define BOOST_PIN_LOW() *boost_pin_port &= ~(boost_pin_mask)
|
|
|
|
#define BOOST_PIN_HIGH() *boost_pin_port |= (boost_pin_mask)
|
|
|
|
#define VVT_PIN_LOW() *vvt_pin_port &= ~(vvt_pin_mask)
|
|
|
|
#define VVT_PIN_HIGH() *vvt_pin_port |= (vvt_pin_mask)
|
2018-05-30 15:29:17 -07:00
|
|
|
#define FAN_PIN_LOW() *fan_pin_port &= ~(fan_pin_mask)
|
|
|
|
#define FAN_PIN_HIGH() *fan_pin_port |= (fan_pin_mask)
|
2018-07-01 03:37:57 -07:00
|
|
|
#define N2O_STAGE1_PIN_LOW() *n2o_stage1_pin_port &= ~(n2o_stage1_pin_mask)
|
|
|
|
#define N2O_STAGE1_PIN_HIGH() *n2o_stage1_pin_port |= (n2o_stage1_pin_mask)
|
|
|
|
#define N2O_STAGE2_PIN_LOW() *n2o_stage2_pin_port &= ~(n2o_stage2_pin_mask)
|
|
|
|
#define N2O_STAGE2_PIN_HIGH() *n2o_stage2_pin_port |= (n2o_stage2_pin_mask)
|
|
|
|
#define READ_N2O_ARM_PIN() ((*n2o_arming_pin_port & n2o_arming_pin_mask) ? true : false)
|
2017-07-23 23:34:13 -07:00
|
|
|
|
2015-09-26 16:14:29 -07:00
|
|
|
volatile byte *boost_pin_port;
|
|
|
|
volatile byte boost_pin_mask;
|
|
|
|
volatile byte *vvt_pin_port;
|
|
|
|
volatile byte vvt_pin_mask;
|
2018-05-30 15:29:17 -07:00
|
|
|
volatile byte *fan_pin_port;
|
|
|
|
volatile byte fan_pin_mask;
|
2018-07-01 03:37:57 -07:00
|
|
|
volatile byte *n2o_stage1_pin_port;
|
|
|
|
volatile byte n2o_stage1_pin_mask;
|
|
|
|
volatile byte *n2o_stage2_pin_port;
|
|
|
|
volatile byte n2o_stage2_pin_mask;
|
|
|
|
volatile byte *n2o_arming_pin_port;
|
|
|
|
volatile byte n2o_arming_pin_mask;
|
2015-09-26 16:14:29 -07:00
|
|
|
|
|
|
|
volatile bool boost_pwm_state;
|
|
|
|
unsigned int boost_pwm_max_count; //Used for variable PWM frequency
|
2015-09-26 23:41:07 -07:00
|
|
|
volatile unsigned int boost_pwm_cur_value;
|
2016-05-15 04:05:49 -07:00
|
|
|
long boost_pwm_target_value;
|
|
|
|
long boost_cl_target_boost;
|
2017-02-11 01:33:07 -08:00
|
|
|
byte boostCounter;
|
2015-09-26 16:14:29 -07:00
|
|
|
|
2018-07-19 00:35:35 -07:00
|
|
|
byte fanHIGH = HIGH; // Used to invert the cooling fan output
|
|
|
|
byte fanLOW = LOW; // Used to invert the cooling fan output
|
|
|
|
|
2015-09-26 16:14:29 -07:00
|
|
|
volatile bool vvt_pwm_state;
|
|
|
|
unsigned int vvt_pwm_max_count; //Used for variable PWM frequency
|
2015-09-26 23:41:07 -07:00
|
|
|
volatile unsigned int vvt_pwm_cur_value;
|
2016-05-15 04:05:49 -07:00
|
|
|
long vvt_pwm_target_value;
|
2017-08-27 21:35:49 -07:00
|
|
|
#if defined (CORE_TEENSY) || defined(CORE_STM32)
|
|
|
|
static inline void boostInterrupt();
|
|
|
|
static inline void vvtInterrupt();
|
|
|
|
#endif
|
2016-05-15 04:05:49 -07:00
|
|
|
|
2017-02-14 21:51:01 -08:00
|
|
|
|
2016-10-06 23:34:27 -07:00
|
|
|
#endif
|