Begin moving board specific code out of timers.x
This commit is contained in:
parent
73dc15e0d5
commit
f4c0513c2f
|
@ -35,7 +35,7 @@ framework = arduino
|
|||
; framework-arduinoststm32
|
||||
board = genericSTM32F103RB
|
||||
lib_deps = EEPROM
|
||||
build_flags = -fpermissive -std=gnu++11
|
||||
build_flags = -fpermissive -std=gnu++11 -UBOARD_NR_GPIO_PINS
|
||||
|
||||
[env:bluepill_f103c8]
|
||||
platform = ststm32
|
||||
|
@ -44,7 +44,7 @@ framework = arduino
|
|||
board = bluepill_f103c8
|
||||
lib_deps = EEPROM
|
||||
;build_flags = -fpermissive -std=gnu++11 -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-Map,output.map
|
||||
build_flags = -fpermissive -std=gnu++11 -Os
|
||||
build_flags = -fpermissive -std=gnu++11 -Os -UBOARD_NR_GPIO_PINS
|
||||
|
||||
;SAMD21
|
||||
[env:samd21]
|
||||
|
|
|
@ -13,6 +13,14 @@
|
|||
void initBoard();
|
||||
uint16_t freeRam();
|
||||
|
||||
#if defined(TIMER5_MICROS)
|
||||
//#define micros() (((timer5_overflow_count << 16) + TCNT5) * 4) //Fast version of micros() that uses the 4uS tick of timer5. See timers.ino for the overflow ISR of timer5
|
||||
#define millis() (ms_counter) //Replaces the standard millis() function with this macro. It is both faster and more accurate. See timers.ino for its counter increment.
|
||||
static inline unsigned long micros_safe(); //A version of micros() that is interrupt safe
|
||||
#else
|
||||
#define micros_safe() micros() //If the timer5 method is not used, the micros_safe() macro is simply an alias for the normal micros()
|
||||
#endif
|
||||
|
||||
/*
|
||||
***********************************************************************************************************
|
||||
* Schedules
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
|
||||
#include "globals.h"
|
||||
|
||||
#if defined(CORE_AVR)
|
||||
|
||||
void initBoard()
|
||||
{
|
||||
|
||||
/*
|
||||
***********************************************************************************************************
|
||||
* General
|
||||
*/
|
||||
configPage9.intcan_available = 0; // AVR devices do NOT have internal canbus
|
||||
}
|
||||
|
||||
uint16_t freeRam()
|
||||
|
@ -16,4 +19,22 @@ uint16_t freeRam()
|
|||
return (uint16_t) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
|
||||
}
|
||||
|
||||
#if defined(TIMER5_MICROS)
|
||||
//This is used by the fast version of micros(). We just need to increment the timer overflow counter
|
||||
ISR(TIMER5_OVF_vect)
|
||||
{
|
||||
++timer5_overflow_count;
|
||||
}
|
||||
|
||||
static inline unsigned long micros_safe()
|
||||
{
|
||||
unsigned long newMicros;
|
||||
noInterrupts();
|
||||
newMicros = (((timer5_overflow_count << 16) + TCNT5) * 4);
|
||||
interrupts();
|
||||
|
||||
return newMicros;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -10,7 +10,7 @@ void initBoard()
|
|||
*/
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
***********************************************************************************************************
|
||||
* Idle
|
||||
*/
|
||||
|
@ -25,7 +25,25 @@ void initBoard()
|
|||
Timer1.resume();
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
***********************************************************************************************************
|
||||
* Timers
|
||||
*/
|
||||
#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);
|
||||
Timer8.resume(); //Start Timer
|
||||
#else
|
||||
Timer4.setPeriod(1000); // Set up period
|
||||
Timer4.setMode(1, TIMER_OUTPUT_COMPARE);
|
||||
Timer4.attachInterrupt(1, oneMSInterval);
|
||||
Timer4.resume(); //Start Timer
|
||||
#endif
|
||||
pinMode(LED_BUILTIN, OUTPUT); //Visual WDT
|
||||
|
||||
|
||||
/*
|
||||
***********************************************************************************************************
|
||||
* Schedules
|
||||
*/
|
||||
|
|
|
@ -78,6 +78,13 @@ void initBoard()
|
|||
NVIC_ENABLE_IRQ(IRQ_FTM2);
|
||||
}
|
||||
|
||||
/*
|
||||
***********************************************************************************************************
|
||||
* Timers
|
||||
*/
|
||||
//Uses the PIT timer on Teensy.
|
||||
lowResTimer.begin(oneMSInterval, 1000);
|
||||
|
||||
/*
|
||||
***********************************************************************************************************
|
||||
* Schedules
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
void initialiseAll()
|
||||
{
|
||||
initBoard();
|
||||
initBoard(); //This calls the current individual boards init function. See the board_xxx.ino files for these.
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
table3D_setSize(&fuelTable, 16);
|
||||
|
@ -41,10 +41,7 @@ void initialiseAll()
|
|||
|
||||
Serial.begin(115200);
|
||||
if (configPage9.enable_secondarySerial == 1) { CANSerial.begin(115200); }
|
||||
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
configPage9.intcan_available = 0; // device does NOT have internal canbus
|
||||
#endif
|
||||
|
||||
#if defined(CORE_STM32) || defined(CORE_TEENSY)
|
||||
configPage9.intcan_available = 1; // device has internal canbus
|
||||
//Teensy onboard CAN not used currently
|
||||
|
|
|
@ -29,14 +29,6 @@ volatile unsigned int dwellLimit_uS;
|
|||
volatile uint16_t lastRPM_100ms; //Need to record this for rpmDOT calculation
|
||||
volatile uint16_t last250msLoopCount = 1000; //Set to effectively random number on startup. Just need this to be different to what mainLoopCount equals initially (Probably 0)
|
||||
|
||||
#if defined(TIMER5_MICROS)
|
||||
//#define micros() (((timer5_overflow_count << 16) + TCNT5) * 4) //Fast version of micros() that uses the 4uS tick of timer5. See timers.ino for the overflow ISR of timer5
|
||||
#define millis() (ms_counter) //Replaces the standard millis() function with this macro. It is both faster and more accurate. See timers.ino for its counter increment.
|
||||
static inline unsigned long micros_safe(); //A version of micros() that is interrupt safe
|
||||
#else
|
||||
#define micros_safe() micros() //If the timer5 method is not used, the micros_safe() macro is simply an alias for the normal micros()
|
||||
#endif
|
||||
|
||||
#if defined (CORE_TEENSY)
|
||||
IntervalTimer lowResTimer;
|
||||
void oneMSInterval();
|
||||
|
|
|
@ -39,22 +39,8 @@ void initialiseTimers()
|
|||
//wdt_enable(WDTO_2S);
|
||||
|
||||
#elif defined (CORE_TEENSY)
|
||||
//Uses the PIT timer on Teensy.
|
||||
lowResTimer.begin(oneMSInterval, 1000);
|
||||
|
||||
|
||||
#elif defined(CORE_STM32)
|
||||
#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);
|
||||
Timer8.resume(); //Start Timer
|
||||
#else
|
||||
Timer4.setPeriod(1000); // Set up period
|
||||
Timer4.setMode(1, TIMER_OUTPUT_COMPARE);
|
||||
Timer4.attachInterrupt(1, oneMSInterval);
|
||||
Timer4.resume(); //Start Timer
|
||||
#endif
|
||||
pinMode(LED_BUILTIN, OUTPUT); //Visual WDT
|
||||
#endif
|
||||
|
||||
lastRPM_100ms = 0;
|
||||
|
@ -231,20 +217,3 @@ void oneMSInterval() //Most ARM chips can simply call a function
|
|||
#endif
|
||||
}
|
||||
|
||||
#if defined(TIMER5_MICROS)
|
||||
//This is used by the fast version of micros(). We just need to increment the timer overflow counter
|
||||
ISR(TIMER5_OVF_vect)
|
||||
{
|
||||
++timer5_overflow_count;
|
||||
}
|
||||
|
||||
static inline unsigned long micros_safe()
|
||||
{
|
||||
unsigned long newMicros;
|
||||
noInterrupts();
|
||||
newMicros = (((timer5_overflow_count << 16) + TCNT5) * 4);
|
||||
interrupts();
|
||||
|
||||
return newMicros;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue