Bring in stm32f407 official core support within platformio

This commit is contained in:
Josh Stewart 2019-03-07 22:47:22 +11:00
parent 05e3d928ad
commit 430032d3ab
8 changed files with 42 additions and 39 deletions

View File

@ -32,10 +32,9 @@ lib_deps = EEPROM, FlexCAN
[env:genericSTM32F103RB]
platform = ststm32@~4.5.0
framework = arduino
; framework-arduinoststm32
board = genericSTM32F103RB
lib_deps = EEPROM
build_flags = -fpermissive -std=gnu++11
build_flags = -fpermissive -std=gnu++11 -DCORE_STM32_OFFICIAL
[env:genericSTM32F103RB_STM32GENERIC]
;platform = ststm32@~4.5.0
@ -51,11 +50,13 @@ build_flags = -fpermissive -std=gnu++11 -UBOARD_NR_GPIO_PINS -DUSE_STM32GENERIC
;platform = ststm32@~4.5.0
platform = ststm32
framework = arduino
; framework-arduinoststm32
board = genericSTM32F407VET6
;board = genericSTM32F407VET6
board = black_f407ve
lib_deps = EEPROM
build_flags = -fpermissive -std=gnu++11 -UBOARD_NR_GPIO_PINS -DCORE_STM32_OFFICIAL -DMENU_USB_SERIAL
upload_protocol = dfu
board_build.core = stm32
build_flags = -fpermissive -std=gnu++11 -UBOARD_NR_GPIO_PINS -DCORE_STM32_OFFICIAL -DSPI_AS_EEPROM
[env:bluepill_f103c8]
platform = ststm32
@ -64,7 +65,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 -UBOARD_NR_GPIO_PINS
build_flags = -fpermissive -std=gnu++11 -Os -DCORE_STM32_OFFICIAL -UBOARD_NR_GPIO_PINS
;SAMD21
[env:samd21]

View File

@ -1,9 +1,9 @@
#ifndef STM32F407VE_H
#define STM32F407VE_H
#if defined(CORE_STM32_OFFICIAL)
#include <Arduino.h>
#include <timer.h>
#include <stm32f4xx_ll_tim.h>
#include "stm32f4xx_ll_tim.h"
/*
***********************************************************************************************************
* General
@ -11,8 +11,17 @@
#define PORT_TYPE uint32_t
#define PINMASK_TYPE uint32_t
#define micros_safe() micros() //timer5 method is not used on anything but AVR, the micros_safe() macro is simply an alias for the normal micros()
#define EEPROM_LIB_H "src/BackupSram/BackupSramAsEEPROM.h"
#define digitalPinToInterrupt(p) (p)
#if defined(SRAM_AS_EEPROM)
#define EEPROM_LIB_H "src/BackupSram/BackupSramAsEEPROM.h"
#elif defined(SPI_AS_EEPROM)
#define EEPROM_LIB_H "src/SPIAsEEPROM/SPIAsEEPROM.h"
#else
#define EEPROM_LIB_H <EEPROM.h>
#endif
#ifndef LED_BUILTIN
#define LED_BUILTIN PA7
#endif
#define USE_SERIAL3
void initBoard();

View File

@ -15,7 +15,6 @@
stimer_t HardwareTimers_4;
stimer_t HardwareTimers_5;
stimer_t HardwareTimers_8;
#define LED_BUILTIN PA7
//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"
@ -78,15 +77,9 @@
***********************************************************************************************************
* Timers
*/
#if defined(ARDUINO_BLACK_F407VE) || defined(STM32F4) || defined(_STM32F4_)
//#if defined(ARDUINO_BLACK_F407VE) || defined(STM32F4) || defined(_STM32F4_)
TimerHandleInit(&HardwareTimers_8, 1000, 168);
attachIntHandle(&HardwareTimers_8, oneMSIntervalIRQ);
#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
/*

View File

@ -3,23 +3,27 @@
#include <Arduino.h>
#include "table.h"
//These are configuration options for changing around the outputs that are used. THese are just the defaults and may be changed in the sections below based on the hardware in use.
#define INJ_CHANNELS 4
#define IGN_CHANNELS 5
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
#define BOARD_DIGITAL_GPIO_PINS 54
#define BOARD_NR_GPIO_PINS 62
#define LED_BUILTIN 13
#define CORE_AVR
#define BOARD_H "board_avr2560.h"
#define INJ_CHANNELS 4
#define IGN_CHANNELS 5
//#define TIMER5_MICROS
#elif defined(CORE_TEENSY)
#define BOARD_H "board_teensy35.h"
#define INJ_CHANNELS 8
#define IGN_CHANNELS 8
#elif defined(STM32_MCU_SERIES) || defined(ARDUINO_ARCH_STM32) || defined(__STM32F1__) || defined(STM32F4) || defined(STM32)
//These should be updated to 8 later, but there's bits missing currently
#define INJ_CHANNELS 4
#define IGN_CHANNELS 5
#ifndef word
#define word(h, l) ((h << 8) | l) //word() function not defined for this platform in the main library
#endif
@ -32,17 +36,11 @@
#elif defined(ARDUINO_BLACK_F407VE) || defined(STM32F4)
#define BOARD_DIGITAL_GPIO_PINS 80
#define BOARD_NR_GPIO_PINS 80
//These boards always make 8/8 channels available
#undef INJ_CHANNELS
#undef IGN_CHANNELS
#define INJ_CHANNELS 8
#define IGN_CHANNELS 8
#endif
#if defined(CORE_STM32_OFFICIAL)
//Need to identify the official core better
#define CORE_STM32_OFFICIAL
//#define CORE_STM32_OFFICIAL
#define BOARD_H "board_stm32_official.h"
#else
#define CORE_STM32_GENERIC
@ -334,8 +332,10 @@ volatile uint8_t compositeLogHistory[TOOTH_LOG_BUFFER];
volatile bool fpPrimed = false; //Tracks whether or not the fuel pump priming has been completed yet
volatile unsigned int toothHistoryIndex = 0;
volatile byte toothHistorySerialIndex = 0;
byte primaryTriggerEdge;
byte secondaryTriggerEdge;
byte primaryTriggerEdge;
byte secondaryTriggerEdge;
int CRANK_ANGLE_MAX = 720;
int CRANK_ANGLE_MAX_IGN = 360;
int CRANK_ANGLE_MAX_INJ = 360; //The number of crank degrees that the system track over. 360 for wasted / timed batch and 720 for sequential

View File

@ -50,7 +50,7 @@ void setIgnitionSchedule8(void (*startCallback)(), unsigned long timeout, unsign
static inline void refreshIgnitionSchedule1(unsigned long timeToEnd) __attribute__((always_inline));
//The ARM cores use seprate functions for their ISRs
#if defined(CORE_STM32) || defined(CORE_TEENSY)
#if defined(CORE_STM32_OFFICIAL) || defined(CORE_STM32_GENERIC) || defined(CORE_TEENSY)
static inline void fuelSchedule1Interrupt();
static inline void fuelSchedule2Interrupt();
static inline void fuelSchedule3Interrupt();

View File

@ -1,6 +1,9 @@
#if defined(ARDUINO_BLACK_F407VE)
//#if defined(ARDUINO_BLACK_F407VE)
#if defined(CORE_STM32_OFFICIAL) && defined(SRAM_AS_EEPROM)
#include "BackupSramAsEEPROM.h"
#include "libmaple/rccF4.h"
BackupSramAsEEPROM::BackupSramAsEEPROM(){
//Enable the power interface clock
RCC->APB1ENR |= RCC_APB1ENR_PWREN;

View File

@ -1,9 +1,6 @@
//Backup sram stores data in the battery backuped sram portion.
//The backup battery is available on the ebay stm32F407VET6 black boards.
#if defined(ARDUINO_BLACK_F407VE)
#if defined(CORE_STM32_OFFICIAL) && defined(SRAM_AS_EEPROM)
//UGLY HACK TO PREVENT EEPROM LIBRARY BEING IMPORTED FIRST!!
//Use with black_F407VE board

View File

@ -32,7 +32,7 @@ volatile uint16_t last250msLoopCount = 1000; //Set to effectively random number
#if defined (CORE_TEENSY)
IntervalTimer lowResTimer;
void oneMSInterval();
#elif defined(CORE_STM32)
#elif defined(CORE_STM32_OFFICIAL) || defined(CORE_STM32_GENERIC)
void oneMSInterval();
#endif
void initialiseTimers();