2016-10-06 23:34:27 -07:00
|
|
|
#ifndef AUX_H
|
|
|
|
#define AUX_H
|
2015-09-26 16:14:29 -07:00
|
|
|
|
2019-01-18 02:15:27 -08:00
|
|
|
#include BOARD_H //Note that this is not a real file, it is defined in globals.h.
|
|
|
|
|
2016-10-06 23:34:27 -07:00
|
|
|
void initialiseAuxPWM();
|
|
|
|
void boostControl();
|
2018-07-19 06:26:31 -07:00
|
|
|
void boostDisable();
|
|
|
|
void idleControl();
|
2016-10-06 23:34:27 -07:00
|
|
|
void vvtControl();
|
2016-10-25 07:04:37 -07:00
|
|
|
void initialiseFan();
|
2018-06-29 08:19:51 -07:00
|
|
|
void nitrousControl();
|
2018-08-15 00:44:30 -07:00
|
|
|
void fanControl();
|
2020-07-21 18:27:21 -07:00
|
|
|
void wmiControl();
|
2015-09-26 16:14:29 -07:00
|
|
|
|
2019-11-12 22:25:59 -08:00
|
|
|
#define SIMPLE_BOOST_P 1
|
|
|
|
#define SIMPLE_BOOST_I 1
|
|
|
|
#define SIMPLE_BOOST_D 1
|
|
|
|
|
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)
|
2020-07-26 16:05:02 -07:00
|
|
|
#define VVT1_PIN_LOW() *vvt1_pin_port &= ~(vvt1_pin_mask)
|
|
|
|
#define VVT1_PIN_HIGH() *vvt1_pin_port |= (vvt1_pin_mask)
|
|
|
|
#define VVT2_PIN_LOW() *vvt2_pin_port &= ~(vvt2_pin_mask)
|
|
|
|
#define VVT2_PIN_HIGH() *vvt2_pin_port |= (vvt2_pin_mask)
|
2020-12-10 17:50:13 -08:00
|
|
|
#define VVT1_PIN_ON() if (configPage6.vvtPWMdir == 0) { VVT1_PIN_HIGH(); } else { VVT1_PIN_LOW(); }
|
|
|
|
#define VVT1_PIN_OFF() if (configPage6.vvtPWMdir == 0) { VVT1_PIN_LOW() ; } else { VVT1_PIN_HIGH(); }
|
|
|
|
//#define VVT2_PIN_ON() if (configPage6.vvtPWMdir == 0) { VVT2_PIN_HIGH(); } else { VVT2_PIN_LOW(); }
|
|
|
|
//#define VVT2_PIN_OFF() if (configPage6.vvtPWMdir == 0) { VVT2_PIN_LOW() ; } else { VVT2_PIN_HIGH(); }
|
|
|
|
#define VVT2_PIN_ON() {} //Disabled as VVT2 not yet complete
|
|
|
|
#define VVT2_PIN_OFF() {} //Disabled as VVT2 not yet complete
|
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
|
|
|
|
2020-05-17 17:30:03 -07:00
|
|
|
#define FAN_ON() ((configPage6.fanInv) ? FAN_PIN_LOW() : FAN_PIN_HIGH())
|
|
|
|
#define FAN_OFF() ((configPage6.fanInv) ? FAN_PIN_HIGH() : FAN_PIN_LOW())
|
|
|
|
|
2020-07-21 18:27:21 -07:00
|
|
|
#define WMI_TANK_IS_EMPTY() ((configPage10.wmiEmptyEnabled) ? ((configPage10.wmiEmptyPolarity) ? !digitalRead(pinWMIEmpty) : digitalRead(pinWMIEmpty)) : 0)
|
|
|
|
|
2019-01-18 02:15:27 -08:00
|
|
|
volatile PORT_TYPE *boost_pin_port;
|
2019-03-03 14:15:57 -08:00
|
|
|
volatile PINMASK_TYPE boost_pin_mask;
|
2020-07-26 16:05:02 -07:00
|
|
|
volatile PORT_TYPE *vvt1_pin_port;
|
|
|
|
volatile PINMASK_TYPE vvt1_pin_mask;
|
|
|
|
volatile PORT_TYPE *vvt2_pin_port;
|
|
|
|
volatile PINMASK_TYPE vvt2_pin_mask;
|
2019-01-18 02:15:27 -08:00
|
|
|
volatile PORT_TYPE *fan_pin_port;
|
2019-03-03 14:15:57 -08:00
|
|
|
volatile PINMASK_TYPE fan_pin_mask;
|
2019-01-18 02:15:27 -08:00
|
|
|
volatile PORT_TYPE *n2o_stage1_pin_port;
|
2019-03-03 14:15:57 -08:00
|
|
|
volatile PINMASK_TYPE n2o_stage1_pin_mask;
|
2019-01-18 02:15:27 -08:00
|
|
|
volatile PORT_TYPE *n2o_stage2_pin_port;
|
2019-03-03 14:15:57 -08:00
|
|
|
volatile PINMASK_TYPE n2o_stage2_pin_mask;
|
2019-01-18 02:15:27 -08:00
|
|
|
volatile PORT_TYPE *n2o_arming_pin_port;
|
2019-03-03 14:15:57 -08:00
|
|
|
volatile PINMASK_TYPE 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;
|
2019-08-19 16:55:46 -07:00
|
|
|
byte vvtCounter;
|
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
|
|
|
|
|
2020-07-26 16:05:02 -07:00
|
|
|
volatile bool vvt1_pwm_state;
|
|
|
|
volatile bool vvt2_pwm_state;
|
|
|
|
volatile bool vvt1_max_pwm;
|
|
|
|
volatile bool vvt2_max_pwm;
|
|
|
|
volatile char nextVVT;
|
2015-09-26 16:14:29 -07:00
|
|
|
unsigned int vvt_pwm_max_count; //Used for variable PWM frequency
|
2020-07-26 16:05:02 -07:00
|
|
|
volatile unsigned int vvt1_pwm_cur_value;
|
|
|
|
volatile unsigned int vvt2_pwm_cur_value;
|
|
|
|
long vvt1_pwm_value;
|
|
|
|
long vvt2_pwm_value;
|
2019-08-19 16:55:46 -07:00
|
|
|
long vvt_pid_target_angle;
|
|
|
|
//long vvt_pid_current_angle;
|
2019-01-19 19:57:16 -08:00
|
|
|
static inline void boostInterrupt();
|
|
|
|
static inline void vvtInterrupt();
|
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
|