Fix building stm32 f401 (#489)

* fix building for STM32F401CC and general macro cleanup

* Now building for all generic STM32F4x7 boards in arduino IDE is ok.

* buildflag cleanup

Co-authored-by: Tjeerd <tjeerdie@users.noreply.github.com>
This commit is contained in:
Tjeerd 2020-12-07 14:43:01 +01:00 committed by GitHub
parent cebf27e573
commit 5c5ecbbcea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 38 additions and 30 deletions

View File

@ -78,7 +78,7 @@ framework = arduino
board = black_f407ve
;lib_deps = EEPROM
board_build.core = stm32
build_flags = -std=gnu++11 -UBOARD_NR_GPIO_PINS -DARDUINO_BLACK_F407VE -DCORE_STM32_OFFICIAL -DENABLE_HWSERIAL2 -DENABLE_HWSERIAL3 -DUSBCON -DHAL_PCD_MODULE_ENABLED -DUSBD_USE_CDC -DHAL_UART_MODULE_ENABLED
build_flags = -std=gnu++11 -UBOARD_NR_GPIO_PINS -DENABLE_HWSERIAL2 -DENABLE_HWSERIAL3 -DUSBCON -DHAL_PCD_MODULE_ENABLED -DUSBD_USE_CDC
upload_protocol = dfu
debug_tool = stlink
monitor_speed = 115200
@ -89,7 +89,7 @@ platform = ststm32
framework = arduino
board = blackpill_f401cc
board_build.core = stm32
build_flags = -fpermissive -std=gnu++11 -UBOARD_NR_GPIO_PINS -DUSBCON -DHAL_PCD_MODULE_ENABLED -DUSBD_USE_CDC -DHAL_UART_MODULE_ENABLED -DHAL_DAC_MODULE_DISABLED -DHAL_RTC_MODULE_DISABLED -DHAL_ETH_MODULE_DISABLED -DHAL_SD_MODULE_DISABLED -DHAL_QSPI_MODULE_DISABLED
build_flags = -std=gnu++11 -UBOARD_NR_GPIO_PINS -DUSBCON -DHAL_PCD_MODULE_ENABLED -DUSBD_USE_CDC -DHAL_DAC_MODULE_DISABLED -DHAL_RTC_MODULE_DISABLED -DHAL_ETH_MODULE_DISABLED -DHAL_SD_MODULE_DISABLED -DHAL_QSPI_MODULE_DISABLED
upload_protocol = dfu
debug_tool = stlink
monitor_speed = 115200

View File

@ -36,7 +36,7 @@
#if defined(FRAM_AS_EEPROM)
#include <Fram.h>
#if defined(ARDUINO_BLACK_F407VE)
#if defined(STM32F407xx)
FramClass EEPROM(PB5, PB4, PB3, PB0); /*(mosi, miso, sclk, ssel, clockspeed) 31/01/2020*/
#else
FramClass EEPROM(PB15, PB14, PB13, PB12); //Blue/Black Pills

View File

@ -1,7 +1,7 @@
#ifndef STM32OFFICIAL_H
#define STM32OFFICIAL_H
#if defined(CORE_STM32_OFFICIAL)
#include <Arduino.h>
#if defined(STM32_CORE_VERSION_MAJOR)
#include <HardwareTimer.h>
#include <HardwareSerial.h>
@ -27,6 +27,12 @@
#define USE_SERIAL3
//When building for Black board Serial1 is instanciated,building generic STM32F4x7 has serial2 and serial 1 must be done here
#if SERIAL_UART_INSTANCE==2
HardwareSerial Serial1(PA10, PA9);
#endif
void initBoard();
uint16_t freeRam();
void doSystemReset();
@ -83,7 +89,7 @@ extern "C" char* sbrk(int incr);
#elif defined(FRAM_AS_EEPROM) //https://github.com/VitorBoss/FRAM
#define EEPROM_LIB_H <Fram.h>
#include EEPROM_LIB_H
#if defined(ARDUINO_BLACK_F407VE)
#if defined(STM32F407xx)
FramClass EEPROM(PB5, PB4, PB3, PB0); /*(mosi, miso, sclk, ssel, clockspeed) 31/01/2020*/
#else
FramClass EEPROM(PB15, PB14, PB13, PB12); //Blue/Black Pills
@ -291,7 +297,8 @@ void ignitionSchedule8Interrupt(HardwareTimer*);
***********************************************************************************************************
* CAN / Second serial
*/
#if defined(ARDUINO_BLACK_F407VE)
#if defined(STM32F407xx) || defined(STM32F103xB) || defined(STM32F405xx)
#define NATIVE_CAN_AVAILABLE
//HardwareSerial CANSerial(PD6, PD5);
#include <src/STM32_CAN/STM32_CAN.h>
//This activates CAN1 interface on STM32, but it's named as Can0, because that's how Teensy implementation is done

View File

@ -1,5 +1,5 @@
#if defined(CORE_STM32_OFFICIAL)
#include "board_stm32_official.h"
#if defined(STM32_CORE_VERSION_MAJOR)
#include "globals.h"
#include "auxiliaries.h"
#include "idle.h"
@ -158,6 +158,7 @@
void jumpToBootloader( void ) // https://github.com/3devo/Arduino_Core_STM32/blob/jumpSysBL/libraries/SrcWrapper/src/stm32/bootloader.c
{ // https://github.com/markusgritsch/SilF4ware/blob/master/SilF4ware/drv_reset.c
#if !defined(STM32F103xB)
HAL_RCC_DeInit();
HAL_DeInit();
SysTick->VAL = SysTick->LOAD = SysTick->CTRL = 0;
@ -182,6 +183,7 @@
: : [DFU_addr] "l" (DFU_addr) : "r0"
);
__builtin_unreachable();
#endif
}
/*

View File

@ -149,5 +149,6 @@
#endif
static CAN_message_t outMsg;
static CAN_message_t inMsg;
#define NATIVE_CAN_AVAILABLE
#endif //CORE_TEENSY
#endif //TEENSY35_H

View File

@ -150,13 +150,14 @@
***********************************************************************************************************
* CAN / Second serial
*/
#define USE_SERIAL3
#define USE_SERIAL3
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> Can0;
FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> Can1;
FlexCAN_T4<CAN3, RX_SIZE_256, TX_SIZE_16> Can2;
static CAN_message_t outMsg;
static CAN_message_t inMsg;
#define NATIVE_CAN_AVAILABLE
#endif //CORE_TEENSY
#endif //TEENSY41_H

View File

@ -286,7 +286,7 @@ void sendcanValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portTy
void can_Command()
{
//int currentcanCommand = inMsg.id;
#if defined(CORE_TEENSY) || defined(ARDUINO_ARCH_STM32)
#if defined (NATIVE_CAN_AVAILABLE)
// currentStatus.canin[12] = (inMsg.id);
if ( (inMsg.id == uint16_t(configPage9.obd_address + 0x100)) || (inMsg.id == 0x7DF))
{
@ -355,7 +355,7 @@ void sendCancommand(uint8_t cmdtype, uint16_t canaddress, uint8_t candata1, uint
//send to truecan send routine
//canaddress == speeduino canid, candata1 == canin channel dest, paramgroup == can address to request from
//This section is to be moved to the correct can output routine later
#if defined(CORE_TEENSY) || defined(ARDUINO_ARCH_STM32) //Scope guarding this for now, but this needs a bit of a rethink for how it can be handled better across multiple archs
#if defined(CORE_TEENSY) || defined(STM32F407xx) || defined(STM32F103xB) || defined(STM32F405xx) //Scope guarding this for now, but this needs a bit of a rethink for how it can be handled better across multiple archs
outMsg.id = (canaddress);
outMsg.len = 8;
outMsg.buf[0] = 0x0B ; //11;
@ -376,7 +376,7 @@ void sendCancommand(uint8_t cmdtype, uint16_t canaddress, uint8_t candata1, uint
#endif
}
#if defined(CORE_TEENSY35) || defined(ARDUINO_ARCH_STM32)
#if defined(NATIVE_CAN_AVAILABLE)
// This routine builds the realtime data into packets that the obd requesting device can understand. This is only used by teensy and stm32 with onboard canbus
void obd_response(uint8_t PIDmode, uint8_t requestedPIDlow, uint8_t requestedPIDhigh)
{

View File

@ -70,7 +70,7 @@
#ifndef LED_BUILTIN
#define LED_BUILTIN PB1 //Maple Mini
#endif
#elif defined(ARDUINO_BLACK_F407VE)
#elif defined(STM32F407xx)
#define BOARD_DIGITAL_GPIO_PINS 74
#define BOARD_NR_GPIO_PINS 74
#endif

View File

@ -212,7 +212,7 @@ void initialiseAll()
//Setup the calibration tables
loadCalibration();
#if defined(CORE_TEENSY35) || defined(ARDUINO_ARCH_STM32)
#if defined (NATIVE_CAN_AVAILABLE)
configPage9.intcan_available = 1; // device has internal canbus
//Teensy uses the Flexcan_T4 library to use the internal canbus
//enable local can interface
@ -1309,7 +1309,7 @@ void setPinMapping(byte boardID)
pinCoil4 = 29;
pinCoil3 = 30;
pinO2 = A22;
#elif defined(ARDUINO_BLACK_F407VE)
#elif defined(STM32F407xx)
//Pin definitions for experimental board Tjeerd
//Black F407VE wiki.stm32duino.com/index.php?title=STM32F407
@ -2043,7 +2043,7 @@ void setPinMapping(byte boardID)
case 60:
#if defined(ARDUINO_BLACK_F407VE)
#if defined(STM32F407xx)
//Pin definitions for experimental board Tjeerd
//Black F407VE wiki.stm32duino.com/index.php?title=STM32F407
//https://github.com/Tjeerdie/SPECTRE/tree/master/SPECTRE_V0.5
@ -2191,7 +2191,7 @@ void setPinMapping(byte boardID)
#endif
break;
default:
#if defined(ARDUINO_BLACK_F407VE)
#if defined(STM32F407xx)
//Pin definitions for experimental board Tjeerd
//Black F407VE wiki.stm32duino.com/index.php?title=STM32F407

View File

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

View File

@ -126,7 +126,7 @@ void loop()
}
}
#endif
#if defined(CORE_TEENSY35) || defined(ARDUINO_ARCH_STM32)
#if defined (NATIVE_CAN_AVAILABLE)
//currentStatus.canin[12] = configPage9.enable_intcan;
if (configPage9.enable_intcan == 1) // use internal can module
{

View File

@ -1,5 +1,4 @@
//#if defined(ARDUINO_BLACK_F407VE)
#if defined(ARDUINO_ARCH_STM32)
#if defined(STM32F407xx)
#include "BackupSramAsEEPROM.h"
BackupSramAsEEPROM::BackupSramAsEEPROM(){

View File

@ -2,9 +2,7 @@
//The backup battery is available on the ebay stm32F407VET6 black boards.
#ifndef BACKUPSRAMASEEPROM_H
#define BACKUPSRAMASEEPROM_H
#if defined(ARDUINO_ARCH_STM32)
#if defined(STM32F407xx)
#include <stdint.h>
#include "stm32f407xx.h"

View File

@ -37,7 +37,7 @@ SPIFlash::SPIFlash(uint8_t cs) {
pinMode(csPin, OUTPUT);
CHIP_DESELECT
}
#elif defined (ARDUINO_ARCH_SAMD) || defined (ARCH_STM32)
#elif defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_ARCH_STM32)
SPIFlash::SPIFlash(uint8_t cs, SPIClass *spiinterface) {
_spi = spiinterface; //Sets SPI interface - if no user selection is made, this defaults to SPI
csPin = cs;

View File

@ -34,7 +34,7 @@ class SPIFlash {
public:
//------------------------------------ Constructor ------------------------------------//
//New Constructor to Accept the PinNames as a Chip select Parameter - @boseji <salearj@hotmail.com> 02.03.17
#if defined (ARDUINO_ARCH_SAMD) || defined(ARCH_STM32) || defined(CORE_STM32_OFFICIAL)
#if defined (ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_STM32)
SPIFlash(uint8_t cs = CS, SPIClass *spiinterface=&SPI);
#elif defined (BOARD_RTL8195A)
SPIFlash(PinName cs = CS);

View File

@ -107,7 +107,7 @@
#define ARCH_STM32
#endif
#endif
#if defined (ARDUINO_ARCH_SAM) || defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_ARCH_ESP8266) || defined (SIMBLEE) || defined (ARDUINO_ARCH_ESP32) || defined (BOARD_RTL8195A) || defined(ARCH_STM32) || defined(ESP32) || defined(NRF5)
#if defined (ARDUINO_ARCH_SAM) || defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_ARCH_ESP8266) || defined (SIMBLEE) || defined (ARDUINO_ARCH_ESP32) || defined (BOARD_RTL8195A) || defined(ARDUINO_ARCH_STM32) || defined(ESP32) || defined(NRF5)
// RTL8195A included - @boseji <salearj@hotmail.com> 02.03.17
#define _delay_us(us) delayMicroseconds(us)
#else

View File

@ -43,7 +43,7 @@
#define BEGIN_SPI SPI.begin();
// Defines and variables specific to SAMD architecture
#elif defined (ARDUINO_ARCH_SAMD) || defined(ARCH_STM32)
#elif defined (ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_STM32)
#define CHIP_SELECT digitalWrite(csPin, LOW);
#define CHIP_DESELECT digitalWrite(csPin, HIGH);
#define xfer(n) _spi->transfer(n)

View File

@ -1,4 +1,4 @@
#if defined(ARDUINO_ARCH_STM32)
#if defined(STM32F407xx) || defined(STM32F103xB) || defined(STM32F405xx)
#include "STM32_CAN.h"
uint8_t STM32_CAN::CANMsgAvail()

View File

@ -9,7 +9,7 @@ https://github.com/nopnop2002/Arduino-STM32-CAN
#ifndef STM32_CAN_H
#define STM32_CAN_H
#if defined(ARDUINO_ARCH_STM32)
#if defined(STM32F407xx) || defined(STM32F103xB) || defined(STM32F405xx)
#include <Arduino.h>
#define STM32_CAN_TIR_TXRQ (1U << 0U) // Bit 0: Transmit Mailbox Request

View File

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