Clean compiling stm32F1 and F4 with stm32GENERIC

This commit is contained in:
Josh Stewart 2019-01-26 20:34:20 +13:00
parent f8842c9935
commit 847d7d0c28
4 changed files with 36 additions and 11 deletions

View File

@ -30,12 +30,22 @@ lib_deps = EEPROM, FlexCAN
;lib_deps = EEPROM ;lib_deps = EEPROM
[env:genericSTM32F103RB] [env:genericSTM32F103RB]
platform = ststm32@~4.5.0 ;platform = ststm32@~4.5.0
platform = ststm32
framework = arduino framework = arduino
; framework-arduinoststm32 ; framework-arduinoststm32
board = genericSTM32F103RB board = genericSTM32F103RB
lib_deps = EEPROM, HardwareTimer, Flash_STM32
build_flags = -fpermissive -std=gnu++11 -UBOARD_NR_GPIO_PINS -DUSE_STM32GENERIC -DMENU_USB_SERIAL
[env:black_F407VE]
;platform = ststm32@~4.5.0
platform = ststm32
framework = arduino
; framework-arduinoststm32
board = black_F407VE
lib_deps = EEPROM lib_deps = EEPROM
build_flags = -fpermissive -std=gnu++11 -UBOARD_NR_GPIO_PINS build_flags = -fpermissive -std=gnu++11 -UBOARD_NR_GPIO_PINS -DUSE_STM32GENERIC -DMENU_USB_SERIAL
[env:bluepill_f103c8] [env:bluepill_f103c8]
platform = ststm32 platform = ststm32

View File

@ -82,13 +82,6 @@ void initialiseAuxPWM()
currentStatus.boostDuty = 0; currentStatus.boostDuty = 0;
boostCounter = 0; boostCounter = 0;
#if defined(CORE_STM32) //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);}
Timer1.resume();
#endif
currentStatus.nitrous_status = NITROUS_OFF; currentStatus.nitrous_status = NITROUS_OFF;

View File

@ -2,8 +2,6 @@
#define STM32_H #define STM32_H
#if defined(CORE_STM32) #if defined(CORE_STM32)
#include "HardwareTimer.h"
/* /*
*********************************************************************************************************** ***********************************************************************************************************
* General * General
@ -14,6 +12,10 @@
void initBoard(); void initBoard();
uint16_t freeRam(); uint16_t freeRam();
#if defined(USE_STM32GENERIC)
#define Serial Serial1
#endif
//Much of the below is not correct, but included to allow compilation //Much of the below is not correct, but included to allow compilation
//STM32F1/variants/.../board.cpp //STM32F1/variants/.../board.cpp
#if defined (STM32F4) #if defined (STM32F4)
@ -278,6 +280,12 @@
#define IDLE_TIMER_DISABLE() (TIMER1->regs).gen->CCER &= ~TIMER_CCER_CC4E #define IDLE_TIMER_DISABLE() (TIMER1->regs).gen->CCER &= ~TIMER_CCER_CC4E
#endif #endif
/*
***********************************************************************************************************
* Timers
*/
/* /*
*********************************************************************************************************** ***********************************************************************************************************
* CAN / Second serial * CAN / Second serial

View File

@ -4,6 +4,11 @@
#include "auxiliaries.h" #include "auxiliaries.h"
#include "idle.h" #include "idle.h"
#include "scheduler.h" #include "scheduler.h"
#include "HardwareTimer.h"
#if defined(STM32F4)
#include <stm32_TIM_variant_11.h>
HardwareTimer Timer8(TIM8, chip_tim8, sizeof(chip_tim8) / sizeof(chip_tim8[0]));
#endif
void initBoard() void initBoard()
{ {
@ -11,6 +16,7 @@ void initBoard()
*********************************************************************************************************** ***********************************************************************************************************
* General * General
*/ */
#define FLASH_LENGTH 8192
/* /*
@ -24,6 +30,7 @@ void initBoard()
//This must happen at the end of the idle init //This must happen at the end of the idle init
Timer1.setMode(4, TIMER_OUTPUT_COMPARE); Timer1.setMode(4, TIMER_OUTPUT_COMPARE);
//timer_set_mode(TIMER1, 4, TIMER_OUTPUT_COMPARE;
if(idle_pwm_max_count > 0) { Timer1.attachInterrupt(4, idleInterrupt);} //on first flash the configPage4.iacAlgorithm is invalid if(idle_pwm_max_count > 0) { Timer1.attachInterrupt(4, idleInterrupt);} //on first flash the configPage4.iacAlgorithm is invalid
Timer1.resume(); Timer1.resume();
@ -53,6 +60,13 @@ void initBoard()
boost_pwm_max_count = 1000000L / (2 * configPage6.boostFreq * 2); //Converts the frequency in Hz to the number of ticks (at 2uS) it takes to complete 1 cycle. The x2 is there because the frequency is stored at half value (in a byte) to allow freqneucies up to 511Hz boost_pwm_max_count = 1000000L / (2 * configPage6.boostFreq * 2); //Converts the frequency in Hz to the number of ticks (at 2uS) it takes to complete 1 cycle. The x2 is there because the frequency is stored at half value (in a byte) to allow freqneucies up to 511Hz
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 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);}
Timer1.resume();
/* /*
*********************************************************************************************************** ***********************************************************************************************************
* Schedules * Schedules