Speeduino
Loading...
Searching...
No Matches
Macros | Functions | Variables
auxiliaries.cpp File Reference
#include "auxiliaries.h"
#include "globals.h"
#include "maths.h"
#include "src/PID_v1/PID_v1.h"
#include "decoders.h"
#include "timers.h"
#include "preprocessor.h"
#include "units.h"
#include "board_definition.h"
#include "atomic.h"
#include "src/pins/fastInputPin.h"
#include "src/pins/fastOutputPin.h"

Macros

#define BOOST_PIN_LOW()   ATOMIC() { boost_pin.setPinLow(); }
 
#define BOOST_PIN_HIGH()   ATOMIC() { boost_pin.setPinHigh(); }
 
#define N2O_STAGE1_PIN_LOW()   ATOMIC() { n2o_stage1_pin.setPinLow(); }
 
#define N2O_STAGE1_PIN_HIGH()   ATOMIC() { n2o_stage1_pin.setPinHigh(); }
 
#define N2O_STAGE2_PIN_LOW()   ATOMIC() { n2o_stage2_pin.setPinLow(); }
 
#define N2O_STAGE2_PIN_HIGH()   ATOMIC() { n2o_stage2_pin.setPinHigh(); }
 
#define AIRCON_PIN_LOW()   aircon_comp_pin.setPinLow()
 
#define AIRCON_PIN_HIGH()   aircon_comp_pin.setPinHigh()
 
#define AIRCON_FAN_PIN_LOW()   aircon_fan_pin.setPinLow()
 
#define AIRCON_FAN_PIN_HIGH()   aircon_fan_pin.setPinHigh()
 
#define AIRCON_ON()   ATOMIC() { ((((configPage15.airConCompPol)==1)) ? AIRCON_PIN_LOW() : AIRCON_PIN_HIGH()); currentStatus.airconCompressorOn = true; }
 
#define AIRCON_OFF()   ATOMIC() { ((((configPage15.airConCompPol)==1)) ? AIRCON_PIN_HIGH() : AIRCON_PIN_LOW()); currentStatus.airconCompressorOn = false; }
 
#define AIRCON_FAN_ON()   ATOMIC() { ((((configPage15.airConFanPol)==1)) ? AIRCON_FAN_PIN_LOW() : AIRCON_FAN_PIN_HIGH()); currentStatus.airconFanOn = true; }
 
#define AIRCON_FAN_OFF()   ATOMIC() { ((((configPage15.airConFanPol)==1)) ? AIRCON_FAN_PIN_HIGH() : AIRCON_FAN_PIN_LOW()); currentStatus.airconFanOn = false; }
 
#define VVT_TIME_DELAY_MULTIPLIER   50
 
#define WMI_TANK_IS_EMPTY()   ((configPage10.wmiEmptyEnabled) ? ((configPage10.wmiEmptyPolarity) ? digitalRead(pinWMIEmpty) : !digitalRead(pinWMIEmpty)) : 1)
 
#define FUEL_PUMP_PIN_HIGH()   pump_pin.setPinHigh()
 
#define FUEL_PUMP_PIN_LOW()   pump_pin.setPinLow()
 
#define FAN_PIN_LOW()   fan_pin.setPinLow()
 
#define FAN_PIN_HIGH()   fan_pin.setPinHigh()
 
#define VVT1_PIN_LOW()   ATOMIC() { vvt1_pin.setPinLow(); }
 
#define VVT1_PIN_HIGH()   ATOMIC() { vvt1_pin.setPinHigh(); }
 
#define VVT2_PIN_LOW()   ATOMIC() { vvt2_pin.setPinLow(); }
 
#define VVT2_PIN_HIGH()   ATOMIC() { vvt2_pin.setPinHigh(); }
 

Functions

static uint8_t getN2oArmPinPolarity (const config10 &page10)
 
static void initialiseN2oArmPin (const config10 &page10)
 
static uint8_t getAirConRequestPinMode (const config15 &page15)
 
static void initAirConRequestPin (const config15 &page15, uint8_t pin)
 
static void initializeBoostPin (uint8_t pin)
 
static void initialiseN2oPins (const config10 &page10)
 
static void initAirConCompressorPin (uint8_t pin)
 
static void initAirConFanPin (uint8_t pin)
 
static void checkAirConCoolantLockout (void)
 
static void checkAirConTPSLockout (void)
 
static void checkAirConRPMLockout (void)
 
void initialiseAirCon (void)
 
static bool READ_AIRCON_REQUEST (void)
 
void airConControl (void)
 
static void initialisePumpPin (uint8_t pin)
 
void fuelPumpOn (void)
 
void fuelPumpOff (void)
 
bool initialiseFuelPump (const config2 &page2, uint8_t pumpPin)
 
static void initialiseFanPin (uint8_t pin)
 
void fanOn (void)
 
void fanOff (void)
 
void initialiseFan (uint8_t fanPin)
 
void fanControl (void)
 
static void initialiseVvtPins (uint8_t pin1, uint8_t pin2)
 
void initialiseAuxPWM (void)
 
static void boostByGear (void)
 
void boostControl (void)
 
void vvt1On (void)
 
void vvt1Off (void)
 
void vvt2On (void)
 
void vvt2Off (void)
 
void vvtControl (void)
 
void nitrousControl (void)
 
void wmiControl (void)
 
void boostDisable (void)
 
void boostInterrupt (void)
 
void vvtInterrupt (void)
 

Variables

constexpr uint8_t SIMPLE_BOOST_P = 1U
 
constexpr uint8_t SIMPLE_BOOST_I = 1U
 
constexpr uint8_t SIMPLE_BOOST_D = 1U
 
static long vvt1_pwm_value
 
static long vvt2_pwm_value
 
static volatile unsigned int vvt1_pwm_cur_value
 
static volatile unsigned int vvt2_pwm_cur_value
 
static long vvt_pid_target_angle
 
static long vvt2_pid_target_angle
 
static long vvt_pid_current_angle
 
static long vvt2_pid_current_angle
 
static volatile bool vvt1_pwm_state
 
static volatile bool vvt2_pwm_state
 
static volatile bool vvt1_max_pwm
 
static volatile bool vvt2_max_pwm
 
static volatile char nextVVT
 
static byte boostCounter
 
static byte vvtCounter
 
static fastInputPin_t n2o_arming_pin
 
static fastInputPin_t aircon_req_pin
 
static fastOutputPin_t boost_pin
 
static fastOutputPin_t n2o_stage1_pin
 
static fastOutputPin_t n2o_stage2_pin
 
static fastOutputPin_t aircon_comp_pin
 
static fastOutputPin_t aircon_fan_pin
 
constexpr table2D_u8_u8_4 fanPWMTableconfigPage6
 
static bool acIsEnabled
 
static bool acStandAloneFanIsEnabled
 
static uint8_t acStartDelay
 
static uint8_t acTPSLockoutDelay
 
static uint8_t acRPMLockoutDelay
 
static uint8_t acAfterEngineStartDelay
 
static bool waitedAfterCranking
 
static long boost_pwm_target_value
 
static volatile bool boost_pwm_state
 
static volatile unsigned int boost_pwm_cur_value = 0
 
static uint32_t vvtWarmTime
 
static bool vvtIsHot
 
static bool vvtTimeHold
 
uint16_t vvt_pwm_max_count
 
uint16_t boost_pwm_max_count
 
constexpr table2D_u8_s16_6 flexBoostTableconfigPage10
 
static integerPID_ideal boostPIDcurrentStatus
 
static fastOutputPin_t pump_pin
 
static fastOutputPin_t fan_pin
 
static fastOutputPin_t vvt1_pin
 
static fastOutputPin_t vvt2_pin
 

Macro Definition Documentation

◆ AIRCON_FAN_OFF

#define AIRCON_FAN_OFF ( )    ATOMIC() { ((((configPage15.airConFanPol)==1)) ? AIRCON_FAN_PIN_HIGH() : AIRCON_FAN_PIN_LOW()); currentStatus.airconFanOn = false; }

◆ AIRCON_FAN_ON

#define AIRCON_FAN_ON ( )    ATOMIC() { ((((configPage15.airConFanPol)==1)) ? AIRCON_FAN_PIN_LOW() : AIRCON_FAN_PIN_HIGH()); currentStatus.airconFanOn = true; }

◆ AIRCON_FAN_PIN_HIGH

#define AIRCON_FAN_PIN_HIGH ( )    aircon_fan_pin.setPinHigh()

◆ AIRCON_FAN_PIN_LOW

#define AIRCON_FAN_PIN_LOW ( )    aircon_fan_pin.setPinLow()

◆ AIRCON_OFF

#define AIRCON_OFF ( )    ATOMIC() { ((((configPage15.airConCompPol)==1)) ? AIRCON_PIN_HIGH() : AIRCON_PIN_LOW()); currentStatus.airconCompressorOn = false; }

◆ AIRCON_ON

#define AIRCON_ON ( )    ATOMIC() { ((((configPage15.airConCompPol)==1)) ? AIRCON_PIN_LOW() : AIRCON_PIN_HIGH()); currentStatus.airconCompressorOn = true; }

◆ AIRCON_PIN_HIGH

#define AIRCON_PIN_HIGH ( )    aircon_comp_pin.setPinHigh()

◆ AIRCON_PIN_LOW

#define AIRCON_PIN_LOW ( )    aircon_comp_pin.setPinLow()

◆ BOOST_PIN_HIGH

#define BOOST_PIN_HIGH ( )    ATOMIC() { boost_pin.setPinHigh(); }

◆ BOOST_PIN_LOW

#define BOOST_PIN_LOW ( )    ATOMIC() { boost_pin.setPinLow(); }

◆ FAN_PIN_HIGH

#define FAN_PIN_HIGH ( )    fan_pin.setPinHigh()

◆ FAN_PIN_LOW

#define FAN_PIN_LOW ( )    fan_pin.setPinLow()

◆ FUEL_PUMP_PIN_HIGH

#define FUEL_PUMP_PIN_HIGH ( )    pump_pin.setPinHigh()

◆ FUEL_PUMP_PIN_LOW

#define FUEL_PUMP_PIN_LOW ( )    pump_pin.setPinLow()

◆ N2O_STAGE1_PIN_HIGH

#define N2O_STAGE1_PIN_HIGH ( )    ATOMIC() { n2o_stage1_pin.setPinHigh(); }

◆ N2O_STAGE1_PIN_LOW

#define N2O_STAGE1_PIN_LOW ( )    ATOMIC() { n2o_stage1_pin.setPinLow(); }

◆ N2O_STAGE2_PIN_HIGH

#define N2O_STAGE2_PIN_HIGH ( )    ATOMIC() { n2o_stage2_pin.setPinHigh(); }

◆ N2O_STAGE2_PIN_LOW

#define N2O_STAGE2_PIN_LOW ( )    ATOMIC() { n2o_stage2_pin.setPinLow(); }

◆ VVT1_PIN_HIGH

#define VVT1_PIN_HIGH ( )    ATOMIC() { vvt1_pin.setPinHigh(); }

◆ VVT1_PIN_LOW

#define VVT1_PIN_LOW ( )    ATOMIC() { vvt1_pin.setPinLow(); }

◆ VVT2_PIN_HIGH

#define VVT2_PIN_HIGH ( )    ATOMIC() { vvt2_pin.setPinHigh(); }

◆ VVT2_PIN_LOW

#define VVT2_PIN_LOW ( )    ATOMIC() { vvt2_pin.setPinLow(); }

◆ VVT_TIME_DELAY_MULTIPLIER

#define VVT_TIME_DELAY_MULTIPLIER   50

◆ WMI_TANK_IS_EMPTY

#define WMI_TANK_IS_EMPTY ( )    ((configPage10.wmiEmptyEnabled) ? ((configPage10.wmiEmptyPolarity) ? digitalRead(pinWMIEmpty) : !digitalRead(pinWMIEmpty)) : 1)

Function Documentation

◆ airConControl()

void airConControl ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ boostByGear()

static void boostByGear ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ boostControl()

void boostControl ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ boostDisable()

void boostDisable ( void  )
Here is the caller graph for this function:

◆ boostInterrupt()

void boostInterrupt ( void  )

◆ checkAirConCoolantLockout()

static void checkAirConCoolantLockout ( void  )
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkAirConRPMLockout()

static void checkAirConRPMLockout ( void  )
inlinestatic
Here is the caller graph for this function:

◆ checkAirConTPSLockout()

static void checkAirConTPSLockout ( void  )
inlinestatic
Here is the caller graph for this function:

◆ fanControl()

void fanControl ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fanOff()

void fanOff ( void  )
Here is the caller graph for this function:

◆ fanOn()

void fanOn ( void  )
Here is the caller graph for this function:

◆ fuelPumpOff()

void fuelPumpOff ( void  )
Here is the caller graph for this function:

◆ fuelPumpOn()

void fuelPumpOn ( void  )
Here is the caller graph for this function:

◆ getAirConRequestPinMode()

static uint8_t getAirConRequestPinMode ( const config15 page15)
static
Here is the caller graph for this function:

◆ getN2oArmPinPolarity()

static uint8_t getN2oArmPinPolarity ( const config10 page10)
inlinestatic
Here is the caller graph for this function:

◆ initAirConCompressorPin()

static void initAirConCompressorPin ( uint8_t  pin)
static
Here is the caller graph for this function:

◆ initAirConFanPin()

static void initAirConFanPin ( uint8_t  pin)
static
Here is the caller graph for this function:

◆ initAirConRequestPin()

static void initAirConRequestPin ( const config15 page15,
uint8_t  pin 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialiseAirCon()

void initialiseAirCon ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialiseAuxPWM()

void initialiseAuxPWM ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialiseFan()

void initialiseFan ( uint8_t  fanPin)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialiseFanPin()

static void initialiseFanPin ( uint8_t  pin)
static
Here is the caller graph for this function:

◆ initialiseFuelPump()

bool initialiseFuelPump ( const config2 page2,
uint8_t  pumpPin 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialiseN2oArmPin()

static void initialiseN2oArmPin ( const config10 page10)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialiseN2oPins()

static void initialiseN2oPins ( const config10 page10)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialisePumpPin()

static void initialisePumpPin ( uint8_t  pin)
inlinestatic
Here is the caller graph for this function:

◆ initialiseVvtPins()

static void initialiseVvtPins ( uint8_t  pin1,
uint8_t  pin2 
)
inlinestatic
Here is the caller graph for this function:

◆ initializeBoostPin()

static void initializeBoostPin ( uint8_t  pin)
static
Here is the caller graph for this function:

◆ nitrousControl()

void nitrousControl ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ READ_AIRCON_REQUEST()

static bool READ_AIRCON_REQUEST ( void  )
static
Here is the caller graph for this function:

◆ vvt1Off()

void vvt1Off ( void  )
Here is the caller graph for this function:

◆ vvt1On()

void vvt1On ( void  )
Here is the caller graph for this function:

◆ vvt2Off()

void vvt2Off ( void  )
Here is the caller graph for this function:

◆ vvt2On()

void vvt2On ( void  )
Here is the caller graph for this function:

◆ vvtControl()

void vvtControl ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vvtInterrupt()

void vvtInterrupt ( void  )
Here is the call graph for this function:

◆ wmiControl()

void wmiControl ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ acAfterEngineStartDelay

uint8_t acAfterEngineStartDelay
static

◆ acIsEnabled

bool acIsEnabled
static

◆ acRPMLockoutDelay

uint8_t acRPMLockoutDelay
static

◆ acStandAloneFanIsEnabled

bool acStandAloneFanIsEnabled
static

◆ acStartDelay

uint8_t acStartDelay
static

◆ acTPSLockoutDelay

uint8_t acTPSLockoutDelay
static

◆ aircon_comp_pin

fastOutputPin_t aircon_comp_pin
static

◆ aircon_fan_pin

fastOutputPin_t aircon_fan_pin
static

◆ aircon_req_pin

fastInputPin_t aircon_req_pin
static

◆ boost_pin

fastOutputPin_t boost_pin
static

◆ boost_pwm_cur_value

volatile unsigned int boost_pwm_cur_value = 0
static

◆ boost_pwm_max_count

uint16_t boost_pwm_max_count

◆ boost_pwm_state

volatile bool boost_pwm_state
static

◆ boost_pwm_target_value

long boost_pwm_target_value
static

◆ boostCounter

byte boostCounter
static

◆ configPage10

◆ configPage6

constexpr table2D_u8_u8_4 iacCrankDutyTable & configPage6
constexpr

◆ currentStatus

integerPID_ideal boostPID& currentStatus
static

◆ fan_pin

fastOutputPin_t fan_pin
static

◆ n2o_arming_pin

fastInputPin_t n2o_arming_pin
static

◆ n2o_stage1_pin

fastOutputPin_t n2o_stage1_pin
static

◆ n2o_stage2_pin

fastOutputPin_t n2o_stage2_pin
static

◆ nextVVT

volatile char nextVVT
static

◆ pump_pin

fastOutputPin_t pump_pin
static

◆ SIMPLE_BOOST_D

constexpr uint8_t SIMPLE_BOOST_D = 1U
constexpr

◆ SIMPLE_BOOST_I

constexpr uint8_t SIMPLE_BOOST_I = 1U
constexpr

◆ SIMPLE_BOOST_P

constexpr uint8_t SIMPLE_BOOST_P = 1U
constexpr

◆ vvt1_max_pwm

volatile bool vvt1_max_pwm
static

◆ vvt1_pin

fastOutputPin_t vvt1_pin
static

◆ vvt1_pwm_cur_value

volatile unsigned int vvt1_pwm_cur_value
static

◆ vvt1_pwm_state

volatile bool vvt1_pwm_state
static

◆ vvt1_pwm_value

long vvt1_pwm_value
static

◆ vvt2_max_pwm

volatile bool vvt2_max_pwm
static

◆ vvt2_pid_current_angle

static integerPID vvt2PID & vvt2_pid_current_angle
static

◆ vvt2_pid_target_angle

long vvt2_pid_target_angle
static

◆ vvt2_pin

fastOutputPin_t vvt2_pin
static

◆ vvt2_pwm_cur_value

volatile unsigned int vvt2_pwm_cur_value
static

◆ vvt2_pwm_state

volatile bool vvt2_pwm_state
static

◆ vvt2_pwm_value

long vvt2_pwm_value
static

◆ vvt_pid_current_angle

static integerPID vvtPID & vvt_pid_current_angle
static

◆ vvt_pid_target_angle

long vvt_pid_target_angle
static

◆ vvt_pwm_max_count

uint16_t vvt_pwm_max_count

◆ vvtCounter

byte vvtCounter
static

◆ vvtIsHot

bool vvtIsHot
static

◆ vvtTimeHold

bool vvtTimeHold
static

◆ vvtWarmTime

uint32_t vvtWarmTime
static

◆ waitedAfterCranking

bool waitedAfterCranking
static