diff --git a/Firmware/FFBoard/Inc/CAN.h b/Firmware/FFBoard/Inc/CAN.h index d58a3184..06357e6e 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/Inc/ringbufferwrapper.h b/Firmware/FFBoard/Inc/ringbufferwrapper.h index 2ba46b8c..99eef8ca 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; } diff --git a/Firmware/FFBoard/Src/CommandHandler.cpp b/Firmware/FFBoard/Src/CommandHandler.cpp index ae7c3fcb..1c488a83 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 94f6eaf2..dc7ff60e 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; diff --git a/Firmware/FFBoard/UserExtensions/Inc/SPIButtons.h b/Firmware/FFBoard/UserExtensions/Inc/SPIButtons.h index 9f8f061d..9e9fdf57 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 f4a0512a..7aa092ef 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 = { @@ -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,23 @@ 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. + }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; } -// 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; diff --git a/Firmware/Makefile b/Firmware/Makefile index 4c50b75b..b5e4fb33 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 ***