Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stm32] Fix SPI setDataMode() #994

Merged
merged 1 commit into from
Apr 8, 2023
Merged
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
6 changes: 6 additions & 0 deletions src/modm/platform/spi/stm32/spi_hal.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ public:
*/
static void
acknowledgeInterruptFlag(InterruptFlag_t flags);

static void
enableTransfer();

static void
disableTransfer();
};

} // namespace platform
Expand Down
15 changes: 14 additions & 1 deletion src/modm/platform/spi/stm32/spi_hal_impl.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void inline
modm::platform::SpiHal{{ id }}::enable()
{
Rcc::enable<Peripheral::Spi{{id}}>();
SPI{{ id }}->CR1 |= SPI_CR1_SPE; // SPI Enable
enableTransfer();
}

void inline
Expand Down Expand Up @@ -186,3 +186,16 @@ modm::platform::SpiHal{{ id }}::acknowledgeInterruptFlag(InterruptFlag_t /*flags
// TODO: implement; see STM32F3 reference manual p. 736
// SPI{{ id }}->SR = flags.value;
}

void inline
modm::platform::SpiHal{{ id }}::enableTransfer()
{
SPI{{ id }}->CR1 |= SPI_CR1_SPE;
}

void inline
modm::platform::SpiHal{{ id }}::disableTransfer()
{
SPI{{ id }}->CR1 &= ~SPI_CR1_SPE;
__DSB();
}
6 changes: 6 additions & 0 deletions src/modm/platform/spi/stm32/spi_master.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,24 @@ public:
static void
setDataMode(DataMode mode)
{
SpiHal{{ id }}::disableTransfer();
SpiHal{{ id }}::setDataMode(static_cast<SpiHal{{ id }}::DataMode>(mode));
SpiHal{{ id }}::enableTransfer();
}

static void
setDataOrder(DataOrder order)
{
SpiHal{{ id }}::disableTransfer();
SpiHal{{ id }}::setDataOrder(static_cast<SpiHal{{ id }}::DataOrder>(order));
SpiHal{{ id }}::enableTransfer();
}
static void
setDataSize(DataSize size)
{
SpiHal{{ id }}::disableTransfer();
SpiHal{{ id }}::setDataSize(static_cast<SpiHal{{ id }}::DataSize>(size));
SpiHal{{ id }}::enableTransfer();
}


Expand Down