Skip to content

Commit

Permalink
Always specify a dummy NSS pin to fix RF-EDU issue
Browse files Browse the repository at this point in the history
The RF-EDU issue is acutally an issue between all SPIs and UART1. When
an SPI is initialized the default value for the NSS pin (GPIO_INVALID)
is not handled correctly and sets PA15 to the alternative function AF05.
This fucks up the configuration for UART1 where we use PA15 as TX pin.
  • Loading branch information
PatrickKa committed Aug 16, 2023
1 parent 78fcb24 commit a082264
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 15 deletions.
4 changes: 4 additions & 0 deletions Sts1CobcSw/Hal/IoNames.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ inline constexpr auto rfSdnPin = pb14;
inline constexpr auto rfGpio0Pin = pc6;
inline constexpr auto rfGpio1Pin = pc8;
inline constexpr auto rfPaEnablePin = pc9;

// We don't need/use NSS pins but due to a bug in Rodos we must specify one so we choose this
// unconnected pin.
inline constexpr auto spiNssDummyPin = pa0;
}
7 changes: 5 additions & 2 deletions Sts1CobcSw/Periphery/Flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ constexpr auto sectorErase4ByteAddress = 0x21_b;

auto csGpioPin = hal::GpioPin(hal::flashCsPin);
auto writeProtectionGpioPin = hal::GpioPin(hal::flashWriteProtectionPin);
auto spi = RODOS::HAL_SPI(
hal::flashSpiIndex, hal::flashSpiSckPin, hal::flashSpiMisoPin, hal::flashSpiMosiPin);
auto spi = RODOS::HAL_SPI(hal::flashSpiIndex,
hal::flashSpiSckPin,
hal::flashSpiMisoPin,
hal::flashSpiMosiPin,
hal::spiNssDummyPin);


// --- Private function declarations ---
Expand Down
7 changes: 5 additions & 2 deletions Sts1CobcSw/Periphery/Fram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ constexpr auto readDeviceId = 0x9F_b;
}

auto csGpioPin = hal::GpioPin(hal::framCsPin);
auto spi = RODOS::HAL_SPI(
hal::framEpsSpiIndex, hal::framEpsSpiSckPin, hal::framEpsSpiMisoPin, hal::framEpsSpiMosiPin);
auto spi = RODOS::HAL_SPI(hal::framEpsSpiIndex,
hal::framEpsSpiSckPin,
hal::framEpsSpiMisoPin,
hal::framEpsSpiMosiPin,
hal::spiNssDummyPin);


// --- Private function declarations ---
Expand Down
3 changes: 2 additions & 1 deletion Sts1CobcSw/Periphery/Rf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ constexpr std::uint8_t morse9 = (5U << maxMorseLetterLength) | 0b00001U;
constexpr std::uint8_t morse0 = (5U << maxMorseLetterLength) | 0b00000U;
constexpr std::uint8_t morseSpace = 0;

auto spi = RODOS::HAL_SPI(hal::rfSpiIndex, hal::rfSpiSckPin, hal::rfSpiMisoPin, hal::rfSpiMosiPin);
auto spi = RODOS::HAL_SPI(
hal::rfSpiIndex, hal::rfSpiSckPin, hal::rfSpiMisoPin, hal::rfSpiMosiPin, hal::spiNssDummyPin);
auto csGpioPin = hal::GpioPin(hal::rfCsPin);
auto nirqGpioPin = hal::GpioPin(hal::rfNirqPin);
auto sdnGpioPin = hal::GpioPin(hal::rfSdnPin);
Expand Down
3 changes: 2 additions & 1 deletion Sts1CobcSw/Periphery/RfDeprecated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ using RODOS::NOW;

// --- Globals ---

auto spi = RODOS::HAL_SPI(hal::rfSpiIndex, hal::rfSpiSckPin, hal::rfSpiMisoPin, hal::rfSpiMosiPin);
auto spi = RODOS::HAL_SPI(
hal::rfSpiIndex, hal::rfSpiSckPin, hal::rfSpiMisoPin, hal::rfSpiMosiPin, hal::spiNssDummyPin);
auto csGpioPin = hal::GpioPin(hal::rfCsPin);
auto nirqGpioPin = hal::GpioPin(hal::rfNirqPin);
auto sdnGpioPin = hal::GpioPin(hal::rfSdnPin);
Expand Down
5 changes: 3 additions & 2 deletions Tests/HardwareTests/RfSimple.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
namespace sts1cobcsw
{

// auto rfSpi =
// RODOS::HAL_SPI(hal::rfSpiIndex, hal::rfSpiSckPin, hal::rfSpiMisoPin, hal::rfSpiMosiPin);
// auto rfSpi = RODOS::HAL_SPI(
// hal::rfSpiIndex, hal::rfSpiSckPin, hal::rfSpiMisoPin, hal::rfSpiMosiPin,
// hal::spiNssDummyPin);


class RfSimpleTest : public RODOS::StaticThread<>
Expand Down
22 changes: 15 additions & 7 deletions Tests/HardwareTests/Spi.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@ using RODOS::PRINTF;

namespace sts1cobcsw
{
auto spis = std::array{
HAL_SPI(hal::flashSpiIndex, hal::flashSpiSckPin, hal::flashSpiMisoPin, hal::flashSpiMosiPin),
HAL_SPI(hal::rfSpiIndex, hal::rfSpiSckPin, hal::rfSpiMisoPin, hal::rfSpiMosiPin),
HAL_SPI(hal::framEpsSpiIndex,
hal::framEpsSpiSckPin,
hal::framEpsSpiMisoPin,
hal::framEpsSpiMosiPin)};
auto spis = std::array{HAL_SPI(hal::flashSpiIndex,
hal::flashSpiSckPin,
hal::flashSpiMisoPin,
hal::flashSpiMosiPin,
hal::spiNssDummyPin),
HAL_SPI(hal::rfSpiIndex,
hal::rfSpiSckPin,
hal::rfSpiMisoPin,
hal::rfSpiMosiPin,
hal::spiNssDummyPin),
HAL_SPI(hal::framEpsSpiIndex,
hal::framEpsSpiSckPin,
hal::framEpsSpiMisoPin,
hal::framEpsSpiMosiPin,
hal::spiNssDummyPin)};


class SpiTest : public RODOS::StaticThread<>
Expand Down

0 comments on commit a082264

Please sign in to comment.