Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Firmware/FFBoard/UserExtensions/Inc/SPIButtons.h
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
8 changes: 7 additions & 1 deletion Firmware/FFBoard/UserExtensions/Src/SPIButtons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
static ButtonSourceConfig decodeIntToConf(uint16_t config, uint16_t config_int_2);
static std::tuple<uint16_t, uint16_t> encodeConfToInt(ButtonSourceConfig* c);

const std::vector<std::string> SPI_Buttons::mode_names = {"Thrustmaster/HEF4021BT","74xx165"};
const std::vector<std::string> SPI_Buttons::mode_names = {"Thrustmaster/HEF4021BT","74xx165","RP2040"};
const std::vector<std::string> SPI_Buttons::speed_names = {"Fast","Medium","Slow"};

ClassIdentifier SPI_Buttons_1::info = {
Expand Down Expand Up @@ -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();
Expand Down