diff --git a/speeduino/auxiliaries.h b/speeduino/auxiliaries.h index 013164d3..434597ec 100644 --- a/speeduino/auxiliaries.h +++ b/speeduino/auxiliaries.h @@ -88,6 +88,9 @@ long boost_pwm_target_value; long boost_cl_target_boost; byte boostCounter; +byte fanHIGH = HIGH; // Used to invert the cooling fan output +byte fanLOW = LOW; // Used to invert the cooling fan output + volatile bool vvt_pwm_state; unsigned int vvt_pwm_max_count; //Used for variable PWM frequency volatile unsigned int vvt_pwm_cur_value; diff --git a/speeduino/auxiliaries.ino b/speeduino/auxiliaries.ino index c40791b7..c9be0619 100644 --- a/speeduino/auxiliaries.ino +++ b/speeduino/auxiliaries.ino @@ -3,6 +3,10 @@ Speeduino - Simple engine management for the Arduino Mega 2560 platform Copyright (C) Josh Stewart A full copy of the license may be found in the projects root directory */ +#include "auxiliaries.h" +#include "globals.h" +#include "src/PID_v1/PID_v1.h" + //Old PID method. Retained incase the new one has issues //integerPID boostPID(&MAPx100, &boost_pwm_target_value, &boostTargetx100, configPage6.boostKP, configPage6.boostKI, configPage6.boostKD, DIRECT); integerPID_ideal boostPID(¤tStatus.MAP, ¤tStatus.boostDuty , ¤tStatus.boostTarget, &configPage10.boostSens, &configPage10.boostIntv, configPage6.boostKP, configPage6.boostKI, configPage6.boostKD, DIRECT); //This is the PID object if that algorithm is used. Needs to be global as it maintains state outside of each function call diff --git a/speeduino/globals.h b/speeduino/globals.h index 543fa81f..eb3f674f 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -334,7 +334,7 @@ struct statuses { byte iatCorrection; //The amount of inlet air temperature adjustment currently being applied byte launchCorrection; //The amount of correction being applied if launch control is active byte flexCorrection; //Amount of correction being applied to compensate for ethanol content - byte flexIgnCorrection; //Amount of additional advance being applied based on flex + int8_t flexIgnCorrection; //Amount of additional advance being applied based on flex. Note the type as this allows for negative values byte afrTarget; byte idleDuty; bool idleUpActive; @@ -732,7 +732,7 @@ struct config10 { uint8_t flexFuelBins[6]; uint8_t flexFuelAdj[6]; //Fuel % @ current ethanol (typically 100% @ 0%, 163% @ 100%) uint8_t flexAdvBins[6]; - uint8_t flexAdvAdj[6]; //Additional advance (in degrees) @ current ethanol (typically 0 @ 0%, 10-20 @ 100%) + uint8_t flexAdvAdj[6]; //Additional advance (in degrees) @ current ethanol (typically 0 @ 0%, 10-20 @ 100%). NOTE: THIS IS A SIGNED VALUE! //And another three corn rows die. byte n2o_enable : 2; diff --git a/speeduino/maths.h b/speeduino/maths.h index a48542bd..2ef6a111 100644 --- a/speeduino/maths.h +++ b/speeduino/maths.h @@ -3,6 +3,8 @@ int fastMap1023toX(int, int); unsigned long percentage(byte, unsigned long); +inline long powint(int, unsigned int); +int divs100(long); #define DIV_ROUND_CLOSEST(n, d) ((((n) < 0) ^ ((d) < 0)) ? (((n) - (d)/2)/(d)) : (((n) + (d)/2)/(d))) diff --git a/speeduino/sensors.h b/speeduino/sensors.h index a8e3450e..6d78e197 100644 --- a/speeduino/sensors.h +++ b/speeduino/sensors.h @@ -40,9 +40,15 @@ uint16_t MAPcurRev; //Tracks which revolution we're sampling on static inline void instanteneousMAPReading() __attribute__((always_inline)); static inline void readMAP() __attribute__((always_inline)); +void initialiseADC(); void readTPS(); void readO2_2(); void flexPulse(); +void readCLT(); +void readIAT(); +void readO2(); +void readBat(); +void readBaro(); #if defined(ANALOG_ISR) diff --git a/speeduino/sensors.ino b/speeduino/sensors.ino index 6681f900..e8a56fa8 100644 --- a/speeduino/sensors.ino +++ b/speeduino/sensors.ino @@ -4,6 +4,8 @@ Copyright (C) Josh Stewart A full copy of the license may be found in the projects root directory */ #include "sensors.h" +#include "globals.h" +#include "maths.h" void initialiseADC() { diff --git a/speeduino/speeduino.ino b/speeduino/speeduino.ino index a3e97adb..2c0d603b 100644 --- a/speeduino/speeduino.ino +++ b/speeduino/speeduino.ino @@ -36,12 +36,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "idle.h" #include "auxiliaries.h" #include "sensors.h" -#include "src/PID_v1/PID_v1.h" //#include "src/DigitalWriteFast/digitalWriteFast.h" #include "errors.h" #include "storage.h" #include "scheduledIO.h" #include "crankMaths.h" +#include "updates.h" #include #if defined (CORE_TEENSY) #include @@ -92,8 +92,6 @@ int CRANK_ANGLE_MAX_INJ = 360; // The number of crank degrees that the system tr static byte coilHIGH = HIGH; static byte coilLOW = LOW; -static byte fanHIGH = HIGH; // Used to invert the cooling fan output -static byte fanLOW = LOW; // Used to invert the cooling fan output volatile uint16_t mainLoopCount; byte deltaToothCount = 0; //The last tooth that was used with the deltaV calc diff --git a/speeduino/updates.h b/speeduino/updates.h new file mode 100644 index 00000000..529c7d91 --- /dev/null +++ b/speeduino/updates.h @@ -0,0 +1,6 @@ +#ifndef UPDATES_H +#define UPDATES_H + +void doUpdates(); + +#endif \ No newline at end of file diff --git a/speeduino/utils.h b/speeduino/utils.h index 74f1ccb9..b1893188 100644 --- a/speeduino/utils.h +++ b/speeduino/utils.h @@ -8,6 +8,7 @@ These are some utility functions and variables used through the main code uint16_t freeRam (); void setPinMapping(byte boardID); +void initialiseTriggers(); //This is dumb, but it'll do for now to get things compiling #if defined(CORE_STM32) diff --git a/speeduino/utils.ino b/speeduino/utils.ino index 6876a394..3f25312f 100644 --- a/speeduino/utils.ino +++ b/speeduino/utils.ino @@ -10,6 +10,7 @@ This function is one big MISRA violation. MISRA advisories forbid directly poking at memory addresses, however there is no other way of determining heap size on embedded systems. */ #include "utils.h" +#include "globals.h" uint16_t freeRam () { @@ -1110,4 +1111,4 @@ void initialiseTriggers() else { attachInterrupt(triggerInterrupt, trigger, FALLING); } break; } -} +} \ No newline at end of file