From ff7421e1ddf92f6d35aae6f38dd3876ba719cdc6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 3 Jun 2021 21:53:52 +0200 Subject: [PATCH] added spi transfer modes --- stm32h7/devicetest/GyroL3GD20H.cpp | 3 ++- stm32h7/devicetest/GyroL3GD20H.h | 4 +++- stm32h7/spi/spiDefinitions.h | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/stm32h7/devicetest/GyroL3GD20H.cpp b/stm32h7/devicetest/GyroL3GD20H.cpp index 736ec2f..30bd381 100644 --- a/stm32h7/devicetest/GyroL3GD20H.cpp +++ b/stm32h7/devicetest/GyroL3GD20H.cpp @@ -16,7 +16,8 @@ TransferStates transferState = TransferStates::IDLE; DMA_HandleTypeDef txDmaHandle; DMA_HandleTypeDef rxDmaHandle; -GyroL3GD20H::GyroL3GD20H(SPI_HandleTypeDef *spiHandle): spiHandle(spiHandle) { +GyroL3GD20H::GyroL3GD20H(SPI_HandleTypeDef *spiHandle, spi::TransferModes transferMode): + spiHandle(spiHandle), transferMode(transferMode) { set_dma_handles(&txDmaHandle, &rxDmaHandle); set_spi_msp_functions(&hal_spi_msp_init_dma, spiHandle, &hal_spi_msp_deinit_dma, spiHandle); GPIO_InitTypeDef chipSelect = {}; diff --git a/stm32h7/devicetest/GyroL3GD20H.h b/stm32h7/devicetest/GyroL3GD20H.h index 2a5b991..e9dacb0 100644 --- a/stm32h7/devicetest/GyroL3GD20H.h +++ b/stm32h7/devicetest/GyroL3GD20H.h @@ -4,6 +4,7 @@ #include "stm32h7xx_hal.h" #include "stm32h7xx_hal_spi.h" +#include "../spi/spiDefinitions.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include @@ -18,7 +19,7 @@ enum class TransferStates { class GyroL3GD20H { public: - GyroL3GD20H(SPI_HandleTypeDef* spiHandle); + GyroL3GD20H(SPI_HandleTypeDef* spiHandle, spi::TransferModes transferMode); ReturnValue_t initialize(); ReturnValue_t performOperation(); @@ -26,6 +27,7 @@ public: private: SPI_HandleTypeDef* spiHandle; + spi::TransferModes transferMode; static constexpr size_t recvBufferSize = 32 * 10; static std::array rxBuffer; std::array txBuffer; diff --git a/stm32h7/spi/spiDefinitions.h b/stm32h7/spi/spiDefinitions.h index ae07c7c..e23ea2e 100644 --- a/stm32h7/spi/spiDefinitions.h +++ b/stm32h7/spi/spiDefinitions.h @@ -8,6 +8,12 @@ namespace spi { +enum TransferModes { + POLLING, + INTERRUPT, + DMA +}; + void assignSpiMode(SpiModes spiMode, SPI_HandleTypeDef* spiHandle); /**