fix STM32F407 comilation wuth new stm32duino 1.7.0
This commit is contained in:
parent
9ccb913738
commit
a44cacc9d4
|
@ -2,8 +2,9 @@
|
|||
#define STM32F407VE_H
|
||||
#if defined(CORE_STM32_OFFICIAL)
|
||||
#include <Arduino.h>
|
||||
#include <timer.h>
|
||||
#include "stm32f4xx_ll_tim.h"
|
||||
#include <HardwareTimer.h>
|
||||
#include <HardwareSerial.h>
|
||||
#include "stm32f1xx_ll_tim.h"
|
||||
/*
|
||||
***********************************************************************************************************
|
||||
* General
|
||||
|
@ -28,10 +29,10 @@
|
|||
#define USE_SERIAL3
|
||||
void initBoard();
|
||||
uint16_t freeRam();
|
||||
extern void oneMSIntervalIRQ(stimer_t *Timer);
|
||||
extern void EmptyIRQCallback(stimer_t *Timer, uint32_t channel);
|
||||
extern "C" char* sbrk(int incr);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
***********************************************************************************************************
|
||||
* Schedules
|
||||
|
@ -154,6 +155,26 @@ extern "C" char* sbrk(int incr);
|
|||
* Timers
|
||||
*/
|
||||
|
||||
HardwareTimer Timer1(TIM1);
|
||||
HardwareTimer Timer2(TIM2);
|
||||
HardwareTimer Timer3(TIM3);
|
||||
HardwareTimer Timer4(TIM4);
|
||||
HardwareTimer Timer5(TIM5);
|
||||
HardwareTimer Timer8(TIM8);
|
||||
|
||||
void oneMSInterval(HardwareTimer*);
|
||||
void boostInterrupt(HardwareTimer*);
|
||||
void fuelSchedule1Interrupt(HardwareTimer*);
|
||||
void fuelSchedule2Interrupt(HardwareTimer*);
|
||||
void fuelSchedule3Interrupt(HardwareTimer*);
|
||||
void fuelSchedule4Interrupt(HardwareTimer*);
|
||||
void idleInterrupt(HardwareTimer*);
|
||||
void vvtInterrupt(HardwareTimer*);
|
||||
void ignitionSchedule1Interrupt(HardwareTimer*);
|
||||
void ignitionSchedule2Interrupt(HardwareTimer*);
|
||||
void ignitionSchedule3Interrupt(HardwareTimer*);
|
||||
void ignitionSchedule4Interrupt(HardwareTimer*);
|
||||
void ignitionSchedule5Interrupt(HardwareTimer*);
|
||||
|
||||
/*
|
||||
***********************************************************************************************************
|
||||
|
|
|
@ -4,56 +4,21 @@
|
|||
#include "auxiliaries.h"
|
||||
#include "idle.h"
|
||||
#include "scheduler.h"
|
||||
#include <timer.h>
|
||||
#include "HardwareTimer.h"
|
||||
|
||||
|
||||
#if defined(STM32F4)
|
||||
#define NR_OFF_TIMERS 9
|
||||
//stimer_t HardwareTimers[NR_OFF_TIMERS + 1];
|
||||
stimer_t HardwareTimers_1;
|
||||
stimer_t HardwareTimers_2;
|
||||
stimer_t HardwareTimers_3;
|
||||
stimer_t HardwareTimers_4;
|
||||
stimer_t HardwareTimers_5;
|
||||
stimer_t HardwareTimers_8;
|
||||
//These should really be in the stm32GENERIC libs, but for somereason they only have timers 1-4
|
||||
// #include <stm32_TIM_variant_11.h>
|
||||
// #include "src/HardwareTimers/HardwareTimer.h"
|
||||
// HardwareTimer Timer5(TIM5, chip_tim5, sizeof(chip_tim5) / sizeof(chip_tim5[0]));
|
||||
// HardwareTimer Timer8(TIM8, chip_tim8, sizeof(chip_tim8) / sizeof(chip_tim8[0]));
|
||||
#else
|
||||
#include "HardwareTimer.h"
|
||||
#endif
|
||||
|
||||
extern void oneMSIntervalIRQ(stimer_t *Timer)
|
||||
{
|
||||
oneMSInterval();
|
||||
}
|
||||
extern void EmptyIRQCallback(stimer_t *Timer, uint32_t channel)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void initBoard()
|
||||
{
|
||||
/*
|
||||
* Initialize timers
|
||||
*/
|
||||
|
||||
HardwareTimers_1.timer = TIM1;
|
||||
HardwareTimers_2.timer = TIM2;
|
||||
HardwareTimers_3.timer = TIM3;
|
||||
HardwareTimers_4.timer = TIM4;
|
||||
|
||||
HardwareTimers_5.timer = TIM5;
|
||||
HardwareTimers_8.timer = TIM8;
|
||||
|
||||
|
||||
/*
|
||||
***********************************************************************************************************
|
||||
* General
|
||||
*/
|
||||
#define FLASH_LENGTH 8192
|
||||
|
||||
#ifndef FLASH_LENGTH
|
||||
#define FLASH_LENGTH 8192
|
||||
#endif
|
||||
delay(10);
|
||||
/*
|
||||
***********************************************************************************************************
|
||||
* Idle
|
||||
|
@ -64,14 +29,9 @@
|
|||
}
|
||||
|
||||
//This must happen at the end of the idle init
|
||||
TimerPulseInit(&HardwareTimers_1, 0xFFFF, 0, EmptyIRQCallback);
|
||||
//setTimerPrescalerRegister(&HardwareTimers_1, (uint32_t)(getTimerClkFreq(HardwareTimers_1.timer) / (500000)) - 1);
|
||||
if(idle_pwm_max_count > 0) { attachIntHandleOC(&HardwareTimers_1, idleInterrupt, 4, 0);} //on first flash the configPage4.iacAlgorithm is invalid
|
||||
//Timer1.setMode(4, TIMER_OUTPUT_COMPARE);
|
||||
Timer1.setMode(4, TIMER_OUTPUT_COMPARE);
|
||||
//timer_set_mode(TIMER1, 4, TIMER_OUTPUT_COMPARE;
|
||||
//on first flash the configPage4.iacAlgorithm is invalid:
|
||||
//if(idle_pwm_max_count > 0) { Timer1.attachInterrupt(4, idleInterrupt);}
|
||||
//Timer1.resume();
|
||||
if(idle_pwm_max_count > 0) { Timer1.attachInterrupt(4, idleInterrupt); } //on first flash the configPage4.iacAlgorithm is invalid
|
||||
|
||||
|
||||
/*
|
||||
|
@ -79,10 +39,15 @@
|
|||
* Timers
|
||||
*/
|
||||
#if defined(ARDUINO_BLACK_F407VE) || defined(STM32F4) || defined(_STM32F4_)
|
||||
TimerHandleInit(&HardwareTimers_8, 1000, 168);
|
||||
attachIntHandle(&HardwareTimers_8, oneMSIntervalIRQ);
|
||||
Timer8.setOverflow(1000, MICROSEC_FORMAT); // Set up period
|
||||
Timer8.setMode(1, TIMER_OUTPUT_COMPARE);
|
||||
Timer8.attachInterrupt(1, oneMSInterval);
|
||||
Timer8.resume(); //Start Timer
|
||||
#else
|
||||
//Should do something here for other boards
|
||||
Timer4.setOverflow(1000, MICROSEC_FORMAT); // Set up period
|
||||
Timer4.setMode(1, TIMER_OUTPUT_COMPARE);
|
||||
Timer4.attachInterrupt(1, oneMSInterval);
|
||||
Timer4.resume(); //Start Timer
|
||||
#endif
|
||||
pinMode(LED_BUILTIN, OUTPUT); //Visual WDT
|
||||
|
||||
|
@ -95,72 +60,85 @@
|
|||
vvt_pwm_max_count = 1000000L / (2 * configPage6.vvtFreq * 2); //Converts the frequency in Hz to the number of ticks (at 2uS) it takes to complete 1 cycle
|
||||
|
||||
//Need to be initialised last due to instant interrupt
|
||||
// Timer1.setMode(2, TIMER_OUTPUT_COMPARE);
|
||||
// Timer1.setMode(3, TIMER_OUTPUT_COMPARE);
|
||||
// if(boost_pwm_max_count > 0) { Timer1.attachInterrupt(2, boostInterrupt);}
|
||||
// if(vvt_pwm_max_count > 0) { Timer1.attachInterrupt(3, vvtInterrupt);}
|
||||
if(idle_pwm_max_count > 0) { attachIntHandleOC(&HardwareTimers_1, boostInterrupt, 2, 0);}
|
||||
if(vvt_pwm_max_count > 0) { attachIntHandleOC(&HardwareTimers_1, vvtInterrupt, 3, 0);}
|
||||
// Timer1.resume();
|
||||
|
||||
TimerPulseInit(&HardwareTimers_3, 0xFFFF, 0, EmptyIRQCallback);
|
||||
attachIntHandleOC(&HardwareTimers_3, fuelSchedule1Interrupt, 1, 0);
|
||||
attachIntHandleOC(&HardwareTimers_3, fuelSchedule2Interrupt, 2, 0);
|
||||
attachIntHandleOC(&HardwareTimers_3, fuelSchedule3Interrupt, 3, 0);
|
||||
attachIntHandleOC(&HardwareTimers_3, fuelSchedule4Interrupt, 4, 0);
|
||||
|
||||
Timer1.setMode(2, TIMER_OUTPUT_COMPARE);
|
||||
Timer1.setMode(3, TIMER_OUTPUT_COMPARE);
|
||||
if(boost_pwm_max_count > 0) { Timer1.attachInterrupt(2, boostInterrupt);}
|
||||
if(vvt_pwm_max_count > 0) { Timer1.attachInterrupt(3, vvtInterrupt);}
|
||||
|
||||
TimerPulseInit(&HardwareTimers_2, 0xFFFF, 0, EmptyIRQCallback);
|
||||
attachIntHandleOC(&HardwareTimers_2, ignitionSchedule1Interrupt, 1, 0);
|
||||
attachIntHandleOC(&HardwareTimers_2, ignitionSchedule2Interrupt, 2, 0);
|
||||
attachIntHandleOC(&HardwareTimers_2, ignitionSchedule3Interrupt, 3, 0);
|
||||
attachIntHandleOC(&HardwareTimers_2, ignitionSchedule4Interrupt, 4, 0);
|
||||
|
||||
//Attach interupt functions
|
||||
//Injection
|
||||
/*
|
||||
***********************************************************************************************************
|
||||
* Schedules
|
||||
*/
|
||||
Timer1.setOverflow(MAX_TIMER_PERIOD, MICROSEC_FORMAT);
|
||||
Timer2.setOverflow(MAX_TIMER_PERIOD, MICROSEC_FORMAT);
|
||||
Timer3.setOverflow(MAX_TIMER_PERIOD, MICROSEC_FORMAT);
|
||||
|
||||
TimerPulseInit(&HardwareTimers_5, 0xFFFF, 0, EmptyIRQCallback);
|
||||
//setTimerPrescalerRegister(&HardwareTimers_5, (uint32_t)(getTimerClkFreq(HardwareTimers_5.timer) / (1000000)) - 1);
|
||||
#if (INJ_CHANNELS >= 5)
|
||||
attachIntHandleOC(&HardwareTimers_5, fuelSchedule5Interrupt, 1, 0);
|
||||
//Timer5.attachInterrupt(1, fuelSchedule5Interrupt);
|
||||
#endif
|
||||
#if (INJ_CHANNELS >= 6)
|
||||
attachIntHandleOC(&HardwareTimers_5, fuelSchedule6Interrupt, 2, 0);
|
||||
//Timer5.attachInterrupt(2, fuelSchedule6Interrupt);
|
||||
#endif
|
||||
#if (INJ_CHANNELS >= 7)
|
||||
attachIntHandleOC(&HardwareTimers_5, fuelSchedule7Interrupt, 3, 0);
|
||||
//Timer5.attachInterrupt(3, fuelSchedule7Interrupt);
|
||||
#endif
|
||||
#if (INJ_CHANNELS >= 8)
|
||||
attachIntHandleOC(&HardwareTimers_5, fuelSchedule8Interrupt, 4, 0);
|
||||
//Timer5.attachInterrupt(4, fuelSchedule8Interrupt);
|
||||
#endif
|
||||
|
||||
TimerPulseInit(&HardwareTimers_4, 0xFFFF, 0, EmptyIRQCallback);
|
||||
//setTimerPrescalerRegister(&HardwareTimers_4, (uint32_t)(getTimerClkFreq(HardwareTimers_4.timer) / (1000000)) - 1);
|
||||
#if (IGN_CHANNELS >= 5)
|
||||
attachIntHandleOC(&HardwareTimers_4, ignitionSchedule5Interrupt, 1, 0);
|
||||
//Timer4.attachInterrupt(1, ignitionSchedule5Interrupt);
|
||||
#endif
|
||||
#if (IGN_CHANNELS >= 6)
|
||||
attachIntHandleOC(&HardwareTimers_4, ignitionSchedule6Interrupt, 2, 0);
|
||||
//Timer4.attachInterrupt(2, ignitionSchedule6Interrupt);
|
||||
#endif
|
||||
#if (IGN_CHANNELS >= 7)
|
||||
attachIntHandleOC(&HardwareTimers_4, ignitionSchedule7Interrupt, 3, 0);
|
||||
//Timer4.attachInterrupt(3, ignitionSchedule7Interrupt);
|
||||
#endif
|
||||
#if (IGN_CHANNELS >= 8)
|
||||
attachIntHandleOC(&HardwareTimers_4, ignitionSchedule8Interrupt, 4, 0);
|
||||
//Timer4.attachInterrupt(4, ignitionSchedule8Interrupt);
|
||||
#endif
|
||||
|
||||
setTimerPrescalerRegister(&HardwareTimers_2, (uint32_t)(getTimerClkFreq(HardwareTimers_2.timer) / (250000)) - 1);
|
||||
setTimerPrescalerRegister(&HardwareTimers_3, (uint32_t)(getTimerClkFreq(HardwareTimers_3.timer) / (250000)) - 1);
|
||||
setTimerPrescalerRegister(&HardwareTimers_4, (uint32_t)(getTimerClkFreq(HardwareTimers_4.timer) / (250000)) - 1);
|
||||
setTimerPrescalerRegister(&HardwareTimers_5, (uint32_t)(getTimerClkFreq(HardwareTimers_5.timer) / (250000)) - 1);
|
||||
Timer2.setMode(1, TIMER_OUTPUT_COMPARE);
|
||||
Timer2.setMode(2, TIMER_OUTPUT_COMPARE);
|
||||
Timer2.setMode(3, TIMER_OUTPUT_COMPARE);
|
||||
Timer2.setMode(4, TIMER_OUTPUT_COMPARE);
|
||||
|
||||
Timer3.setMode(1, TIMER_OUTPUT_COMPARE);
|
||||
Timer3.setMode(2, TIMER_OUTPUT_COMPARE);
|
||||
Timer3.setMode(3, TIMER_OUTPUT_COMPARE);
|
||||
Timer3.setMode(4, TIMER_OUTPUT_COMPARE);
|
||||
Timer1.setMode(1, TIMER_OUTPUT_COMPARE);
|
||||
|
||||
//Attach interupt functions
|
||||
//Injection
|
||||
Timer3.attachInterrupt(1, fuelSchedule1Interrupt);
|
||||
Timer3.attachInterrupt(2, fuelSchedule2Interrupt);
|
||||
Timer3.attachInterrupt(3, fuelSchedule3Interrupt);
|
||||
Timer3.attachInterrupt(4, fuelSchedule4Interrupt);
|
||||
#if (INJ_CHANNELS >= 5)
|
||||
Timer5.setMode(1, TIMER_OUTPUT_COMPARE);
|
||||
Timer5.attachInterrupt(1, fuelSchedule5Interrupt);
|
||||
#endif
|
||||
#if (INJ_CHANNELS >= 6)
|
||||
Timer5.setMode(2, TIMER_OUTPUT_COMPARE);
|
||||
Timer5.attachInterrupt(2, fuelSchedule6Interrupt);
|
||||
#endif
|
||||
#if (INJ_CHANNELS >= 7)
|
||||
Timer5.setMode(3, TIMER_OUTPUT_COMPARE);
|
||||
Timer5.attachInterrupt(3, fuelSchedule7Interrupt);
|
||||
#endif
|
||||
#if (INJ_CHANNELS >= 8)
|
||||
Timer5.setMode(4, TIMER_OUTPUT_COMPARE);
|
||||
Timer5.attachInterrupt(4, fuelSchedule8Interrupt);
|
||||
#endif
|
||||
|
||||
//Ignition
|
||||
Timer2.attachInterrupt(1, ignitionSchedule1Interrupt);
|
||||
Timer2.attachInterrupt(2, ignitionSchedule2Interrupt);
|
||||
Timer2.attachInterrupt(3, ignitionSchedule3Interrupt);
|
||||
Timer2.attachInterrupt(4, ignitionSchedule4Interrupt);
|
||||
#if (IGN_CHANNELS >= 5)
|
||||
Timer4.setMode(1, TIMER_OUTPUT_COMPARE);
|
||||
Timer4.attachInterrupt(1, ignitionSchedule5Interrupt);
|
||||
#endif
|
||||
#if (IGN_CHANNELS >= 6)
|
||||
Timer4.setMode(2, TIMER_OUTPUT_COMPARE);
|
||||
Timer4.attachInterrupt(2, ignitionSchedule6Interrupt);
|
||||
#endif
|
||||
#if (IGN_CHANNELS >= 7)
|
||||
Timer4.setMode(3, TIMER_OUTPUT_COMPARE);
|
||||
Timer4.attachInterrupt(3, ignitionSchedule7Interrupt);
|
||||
#endif
|
||||
#if (IGN_CHANNELS >= 8)
|
||||
Timer4.setMode(4, TIMER_OUTPUT_COMPARE);
|
||||
Timer4.attachInterrupt(4, ignitionSchedule8Interrupt);
|
||||
#endif
|
||||
|
||||
Timer1.resume();
|
||||
Timer2.resume();
|
||||
Timer3.resume();
|
||||
#if (IGN_CHANNELS >= 5)
|
||||
Timer4.resume();
|
||||
#endif
|
||||
#if (INJ_CHANNELS >= 5)
|
||||
Timer5.resume();
|
||||
#endif
|
||||
}
|
||||
|
||||
uint16_t freeRam()
|
||||
|
@ -169,7 +147,22 @@
|
|||
return &top - reinterpret_cast<char*>(sbrk(0));
|
||||
}
|
||||
|
||||
//pinmapping the STM32F407 for different boards, at this moment no board is desgined.
|
||||
//All boards are set to the default just to be sure.
|
||||
|
||||
/*
|
||||
***********************************************************************************************************
|
||||
* Interrupt callback functions
|
||||
*/
|
||||
void oneMSInterval(HardwareTimer*){oneMSInterval();}
|
||||
void boostInterrupt(HardwareTimer*){boostInterrupt();}
|
||||
void fuelSchedule1Interrupt(HardwareTimer*){fuelSchedule1Interrupt();}
|
||||
void fuelSchedule2Interrupt(HardwareTimer*){fuelSchedule2Interrupt();}
|
||||
void fuelSchedule3Interrupt(HardwareTimer*){fuelSchedule3Interrupt();}
|
||||
void fuelSchedule4Interrupt(HardwareTimer*){fuelSchedule4Interrupt();}
|
||||
void idleInterrupt(HardwareTimer*){idleInterrupt();}
|
||||
void vvtInterrupt(HardwareTimer*){vvtInterrupt();}
|
||||
void ignitionSchedule1Interrupt(HardwareTimer*){ignitionSchedule1Interrupt();}
|
||||
void ignitionSchedule2Interrupt(HardwareTimer*){ignitionSchedule2Interrupt();}
|
||||
void ignitionSchedule3Interrupt(HardwareTimer*){ignitionSchedule3Interrupt();}
|
||||
void ignitionSchedule4Interrupt(HardwareTimer*){ignitionSchedule4Interrupt();}
|
||||
void ignitionSchedule5Interrupt(HardwareTimer*){ignitionSchedule5Interrupt();}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue