From e23abe82ced7340f14e1d43ef55e44d33b4435c3 Mon Sep 17 00:00:00 2001 From: Lucas Jansson Date: Mon, 20 Oct 2025 13:00:31 +0200 Subject: [PATCH 1/5] Include the algorithm library where needed Fixes build with gcc 14+ --- Firmware/FFBoard/Inc/CAN.h | 1 + Firmware/FFBoard/Src/CommandHandler.cpp | 1 + Firmware/FFBoard/Src/ErrorHandler.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/Firmware/FFBoard/Inc/CAN.h b/Firmware/FFBoard/Inc/CAN.h index d58a31841..06357e6ed 100644 --- a/Firmware/FFBoard/Inc/CAN.h +++ b/Firmware/FFBoard/Inc/CAN.h @@ -11,6 +11,7 @@ #ifdef CANBUS //#include "CanHandler.h" #include "main.h" +#include #include #include "semaphore.hpp" #include diff --git a/Firmware/FFBoard/Src/CommandHandler.cpp b/Firmware/FFBoard/Src/CommandHandler.cpp index ae7c3fcbc..1c488a832 100644 --- a/Firmware/FFBoard/Src/CommandHandler.cpp +++ b/Firmware/FFBoard/Src/CommandHandler.cpp @@ -12,6 +12,7 @@ #include "CDCcomm.h" //#include #include "ChoosableClass.h" +#include //std::vector CommandHandler::cmdHandlers; //std::set CommandHandler::cmdHandlerIDs; diff --git a/Firmware/FFBoard/Src/ErrorHandler.cpp b/Firmware/FFBoard/Src/ErrorHandler.cpp index 94f6eaf22..dc7ff60e4 100644 --- a/Firmware/FFBoard/Src/ErrorHandler.cpp +++ b/Firmware/FFBoard/Src/ErrorHandler.cpp @@ -10,6 +10,7 @@ #include "FFBoardMain.h" #include "cppmain.h" #include "critical.hpp" +#include #include std::vector ErrorHandler::errorHandlers; From 07ee4c61d445b4634348cb9be8d3ca528dce469a Mon Sep 17 00:00:00 2001 From: Lucas Jansson Date: Mon, 20 Oct 2025 14:07:01 +0200 Subject: [PATCH 2/5] Fix deprecation warning in ringbufferwrapper --- Firmware/FFBoard/Inc/ringbufferwrapper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/FFBoard/Inc/ringbufferwrapper.h b/Firmware/FFBoard/Inc/ringbufferwrapper.h index 2ba46b8c8..99eef8caf 100644 --- a/Firmware/FFBoard/Inc/ringbufferwrapper.h +++ b/Firmware/FFBoard/Inc/ringbufferwrapper.h @@ -57,7 +57,7 @@ T RingBufferWrapper::peek_as(bool* ok) noexcept T data; // Only POD types can be trivially copied from // the ring buffer. - if (!std::is_pod::value) { + if (!std::is_standard_layout::value && !std::is_trivial::value) { *ok = false; return data; } From bc63e6a40d2195cf288316312fc19c07b68f3e9d Mon Sep 17 00:00:00 2001 From: Lucas Jansson Date: Mon, 20 Oct 2025 13:04:23 +0200 Subject: [PATCH 3/5] Makefile cleanup --- Firmware/Makefile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Firmware/Makefile b/Firmware/Makefile index 4c50b75b1..b5e4fb33c 100644 --- a/Firmware/Makefile +++ b/Firmware/Makefile @@ -26,7 +26,7 @@ BUILD_DIR = build ###################################### # Choose your board mcu F407VG or F411RE -MCU_TARGET=F407VG +MCU_TARGET ?= F407VG # The directory of mcu target TARGET_DIR = Targets/$(MCU_TARGET) @@ -36,7 +36,7 @@ TARGET_DIR = Targets/$(MCU_TARGET) TARGET = OpenFFBoard_$(MCU_TARGET) # Output directory for hex/bin files -OUTPUT_DIR = $(BUILD_DIR) +OUTPUT_DIR ?= $(BUILD_DIR) # C sources C_SOURCES = $(wildcard $(TARGET_DIR)/Core/Src/*.c) @@ -229,15 +229,15 @@ $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile $(OUTPUT_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(OUTPUT_DIR) $(HEX) $< $@ - + $(OUTPUT_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(OUTPUT_DIR) - $(BIN) $< $@ - + $(BIN) $< $@ + $(BUILD_DIR): - -mkdir $@ - + -mkdir -p $@ + $(OUTPUT_DIR): $(BUILD_DIR) - -mkdir $@ + -mkdir -p $@ ####################################### # clean up @@ -256,4 +256,4 @@ upload: $(BUILD_DIR)/$(TARGET).bin ####################################### -include $(wildcard $(BUILD_DIR)/*.d) -# *** EOF *** \ No newline at end of file +# *** EOF *** From 7cbcb08ffcdb73d431d0f5e0d77f7c1e5a5e7003 Mon Sep 17 00:00:00 2001 From: Lucas Jansson Date: Wed, 5 Nov 2025 12:50:51 +0100 Subject: [PATCH 4/5] Fix SPI_Buttons constructor procedure --- .../FFBoard/UserExtensions/Src/SPIButtons.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Firmware/FFBoard/UserExtensions/Src/SPIButtons.cpp b/Firmware/FFBoard/UserExtensions/Src/SPIButtons.cpp index f4a0512a6..a82e0d710 100644 --- a/Firmware/FFBoard/UserExtensions/Src/SPIButtons.cpp +++ b/Firmware/FFBoard/UserExtensions/Src/SPIButtons.cpp @@ -51,13 +51,6 @@ SPI_Buttons::SPI_Buttons(uint16_t configuration_address, uint16_t configuration_ this->configuration_address_2 = configuration_address_2; restoreFlash(); - this->spiConfig.peripheral.BaudRatePrescaler = speedPresets[this->conf.spi_speed]; - this->spiConfig.peripheral.FirstBit = SPI_FIRSTBIT_LSB; - this->spiConfig.peripheral.CLKPhase = SPI_PHASE_1EDGE; - this->spiConfig.peripheral.CLKPolarity = SPI_POLARITY_LOW; - - initSPI(); - registerCommands(); this->setCommandsEnabled(true); ready = true; @@ -109,18 +102,17 @@ void SPI_Buttons::setConfig(ButtonSourceConfig config){ if(conf.mode == SPI_BtnMode::TM){ this->spiConfig.cspol = true; this->conf.cutRight = true; - this->spiConfig.peripheral.CLKPolarity = SPI_POLARITY_LOW; + this->spiConfig.peripheral.FirstBit = SPI_FIRSTBIT_LSB; this->spiConfig.peripheral.CLKPhase = SPI_PHASE_1EDGE; - + this->spiConfig.peripheral.CLKPolarity = SPI_POLARITY_LOW; }else if(conf.mode == SPI_BtnMode::PISOSR){ this->spiConfig.cspol = false; this->conf.cutRight = false; + this->spiConfig.peripheral.FirstBit = SPI_FIRSTBIT_LSB; this->spiConfig.peripheral.CLKPhase = SPI_PHASE_2EDGE; this->spiConfig.peripheral.CLKPolarity = SPI_POLARITY_HIGH; // its actually shifting on the rising edge but 165 will have the first output set even before clocking. First clock cycle is actually second bit so we sample at the falling edge and skip the first bit with that. } -// spiPort.takeSemaphore(); -// spiPort.configurePort(&this->spiConfig.peripheral); -// spiPort.giveSemaphore(); + this->spiConfig.peripheral.BaudRatePrescaler = speedPresets[this->conf.spi_speed]; initSPI(); if(config.numButtons == 64){ // Special case mask = 0xffffffffffffffff; From b7624a84028a837551a0e516cd43d21e2bf53d66 Mon Sep 17 00:00:00 2001 From: Lucas Jansson Date: Wed, 5 Nov 2025 12:53:47 +0100 Subject: [PATCH 5/5] Add RP2040 SPI_Buttons mode --- Firmware/FFBoard/UserExtensions/Inc/SPIButtons.h | 2 +- Firmware/FFBoard/UserExtensions/Src/SPIButtons.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Firmware/FFBoard/UserExtensions/Inc/SPIButtons.h b/Firmware/FFBoard/UserExtensions/Inc/SPIButtons.h index 9f8f061df..9e9fdf57a 100644 --- a/Firmware/FFBoard/UserExtensions/Inc/SPIButtons.h +++ b/Firmware/FFBoard/UserExtensions/Inc/SPIButtons.h @@ -19,7 +19,7 @@ // Set this to 64, 128 or 256 to slow down SPI if unstable. #define SPIBUTTONS_SPEED SPI_BAUDRATEPRESCALER_32 -enum class SPI_BtnMode : uint8_t {TM=0,PISOSR=1}; +enum class SPI_BtnMode : uint8_t {TM=0,PISOSR=1,RP2040=2}; struct ButtonSourceConfig{ diff --git a/Firmware/FFBoard/UserExtensions/Src/SPIButtons.cpp b/Firmware/FFBoard/UserExtensions/Src/SPIButtons.cpp index a82e0d710..7aa092ef4 100644 --- a/Firmware/FFBoard/UserExtensions/Src/SPIButtons.cpp +++ b/Firmware/FFBoard/UserExtensions/Src/SPIButtons.cpp @@ -15,7 +15,7 @@ static ButtonSourceConfig decodeIntToConf(uint16_t config, uint16_t config_int_2); static std::tuple encodeConfToInt(ButtonSourceConfig* c); -const std::vector SPI_Buttons::mode_names = {"Thrustmaster/HEF4021BT","74xx165"}; +const std::vector SPI_Buttons::mode_names = {"Thrustmaster/HEF4021BT","74xx165","RP2040"}; const std::vector SPI_Buttons::speed_names = {"Fast","Medium","Slow"}; ClassIdentifier SPI_Buttons_1::info = { @@ -111,6 +111,12 @@ void SPI_Buttons::setConfig(ButtonSourceConfig config){ this->spiConfig.peripheral.FirstBit = SPI_FIRSTBIT_LSB; this->spiConfig.peripheral.CLKPhase = SPI_PHASE_2EDGE; this->spiConfig.peripheral.CLKPolarity = SPI_POLARITY_HIGH; // its actually shifting on the rising edge but 165 will have the first output set even before clocking. First clock cycle is actually second bit so we sample at the falling edge and skip the first bit with that. + }else if(conf.mode == SPI_BtnMode::RP2040){ + this->conf.cutRight = false; + this->spiConfig.cspol = true; + this->spiConfig.peripheral.FirstBit = SPI_FIRSTBIT_MSB; + this->spiConfig.peripheral.CLKPhase = SPI_PHASE_1EDGE; + this->spiConfig.peripheral.CLKPolarity = SPI_POLARITY_LOW; } this->spiConfig.peripheral.BaudRatePrescaler = speedPresets[this->conf.spi_speed]; initSPI();