added spi transfer modes

This commit is contained in:
Robin Müller 2021-06-03 21:53:52 +02:00
parent 66a7a4dbbe
commit ff7421e1dd
No known key found for this signature in database
GPG Key ID: BE6480244DFE612C
3 changed files with 11 additions and 2 deletions

View File

@ -16,7 +16,8 @@ TransferStates transferState = TransferStates::IDLE;
DMA_HandleTypeDef txDmaHandle; DMA_HandleTypeDef txDmaHandle;
DMA_HandleTypeDef rxDmaHandle; 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_dma_handles(&txDmaHandle, &rxDmaHandle);
set_spi_msp_functions(&hal_spi_msp_init_dma, spiHandle, &hal_spi_msp_deinit_dma, spiHandle); set_spi_msp_functions(&hal_spi_msp_init_dma, spiHandle, &hal_spi_msp_deinit_dma, spiHandle);
GPIO_InitTypeDef chipSelect = {}; GPIO_InitTypeDef chipSelect = {};

View File

@ -4,6 +4,7 @@
#include "stm32h7xx_hal.h" #include "stm32h7xx_hal.h"
#include "stm32h7xx_hal_spi.h" #include "stm32h7xx_hal_spi.h"
#include "../spi/spiDefinitions.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include <cstdint> #include <cstdint>
@ -18,7 +19,7 @@ enum class TransferStates {
class GyroL3GD20H { class GyroL3GD20H {
public: public:
GyroL3GD20H(SPI_HandleTypeDef* spiHandle); GyroL3GD20H(SPI_HandleTypeDef* spiHandle, spi::TransferModes transferMode);
ReturnValue_t initialize(); ReturnValue_t initialize();
ReturnValue_t performOperation(); ReturnValue_t performOperation();
@ -26,6 +27,7 @@ public:
private: private:
SPI_HandleTypeDef* spiHandle; SPI_HandleTypeDef* spiHandle;
spi::TransferModes transferMode;
static constexpr size_t recvBufferSize = 32 * 10; static constexpr size_t recvBufferSize = 32 * 10;
static std::array<uint8_t, recvBufferSize> rxBuffer; static std::array<uint8_t, recvBufferSize> rxBuffer;
std::array<uint8_t, 32> txBuffer; std::array<uint8_t, 32> txBuffer;

View File

@ -8,6 +8,12 @@
namespace spi { namespace spi {
enum TransferModes {
POLLING,
INTERRUPT,
DMA
};
void assignSpiMode(SpiModes spiMode, SPI_HandleTypeDef* spiHandle); void assignSpiMode(SpiModes spiMode, SPI_HandleTypeDef* spiHandle);
/** /**