From 7e19e6c4adf92dc57c01aca4951d463ab37cdf9d Mon Sep 17 00:00:00 2001 From: VitorBoss Date: Sun, 18 Mar 2018 03:26:12 -0300 Subject: [PATCH] Fixes for STM crash --- speeduino/globals.h | 4 ++-- speeduino/scheduler.ino | 16 +++++++++++++--- speeduino/timers.ino | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/speeduino/globals.h b/speeduino/globals.h index 2ced573c..ddba6209 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -36,12 +36,12 @@ #endif //Specific mode for Bluepill due to its small flash size. This disables a number of strings from being compiled into the flash - #if defined(MCU_STM32F103C8) + #if defined(MCU_STM32F103C8) | defined(MCU_STM32F103CB) #define SMALL_FLASH_MODE #endif extern "C" char* sbrk(int incr); //Used to freeRam - //inline unsigned char digitalPinToInterrupt(unsigned char Interrupt_pin) { return Interrupt_pin; } //This isn't included in the stm32duino libs (yet) + inline unsigned char digitalPinToInterrupt(unsigned char Interrupt_pin) { return Interrupt_pin; } //This isn't included in the stm32duino libs (yet) #if defined(ARDUINO_ARCH_STM32) // STM32GENERIC core #define portOutputRegister(port) (volatile byte *)( &(port->ODR) ) #define portInputRegister(port) (volatile byte *)( &(port->IDR) ) diff --git a/speeduino/scheduler.ino b/speeduino/scheduler.ino index d5cefaad..5adee27b 100644 --- a/speeduino/scheduler.ino +++ b/speeduino/scheduler.ino @@ -246,10 +246,18 @@ void initialiseSchedulers() fuelSchedule2.counter = &FUEL2_COUNTER; fuelSchedule3.counter = &FUEL3_COUNTER; fuelSchedule4.counter = &FUEL4_COUNTER; + #if (INJ_CHANNELS >= 5) fuelSchedule5.counter = &FUEL5_COUNTER; - fuelSchedule6.counter = &FUEL6_COUNTER; - fuelSchedule7.counter = &FUEL7_COUNTER; - fuelSchedule8.counter = &FUEL8_COUNTER; + #endif + #if (INJ_CHANNELS >= 6) + fuelSchedule5.counter = &FUEL6_COUNTER; + #endif + #if (INJ_CHANNELS >= 7) + fuelSchedule5.counter = &FUEL7_COUNTER; + #endif + #if (INJ_CHANNELS >= 8) + fuelSchedule5.counter = &FUEL8_COUNTER; + #endif ignitionSchedule1.Status = OFF; ignitionSchedule2.Status = OFF; @@ -478,6 +486,7 @@ void setFuelSchedule4(unsigned long timeout, unsigned long duration) //Uses time } } +#if INJ_CHANNELS >= 5 void setFuelSchedule5(void (*startCallback)(), unsigned long timeout, unsigned long duration, void(*endCallback)()) { if(fuelSchedule5.Status != RUNNING) //Check that we're not already part way through a schedule @@ -509,6 +518,7 @@ void setFuelSchedule5(void (*startCallback)(), unsigned long timeout, unsigned l fuelSchedule5.hasNextSchedule = true; } } +#endif #if INJ_CHANNELS >= 6 //This uses timer diff --git a/speeduino/timers.ino b/speeduino/timers.ino index 2d7a1e6a..1c29e19e 100644 --- a/speeduino/timers.ino +++ b/speeduino/timers.ino @@ -40,7 +40,7 @@ void initialiseTimers() lowResTimer.begin(oneMSInterval, 1000); #elif defined(CORE_STM32) -#ifndef SMALL_FLASH_MODE +#if defined(ARDUINO_BLACK_F407VE) || defined(STM32F4) || defined(_STM32F4_) Timer8.setPeriod(1000); // Set up period Timer8.setMode(1, TIMER_OUTPUT_COMPARE); Timer8.attachInterrupt(1, oneMSInterval);