From cdb7dbff07a9e71579d1a5e3e166ea960f70f751 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Jun 2021 21:31:42 +0200 Subject: [PATCH] moved msp init to user --- bsp_stm32_freertos/core/ObjectFactory.cpp | 36 +++++++++++++++++++---- fsfw_hal | 2 +- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/bsp_stm32_freertos/core/ObjectFactory.cpp b/bsp_stm32_freertos/core/ObjectFactory.cpp index 44849c3..f30b35d 100644 --- a/bsp_stm32_freertos/core/ObjectFactory.cpp +++ b/bsp_stm32_freertos/core/ObjectFactory.cpp @@ -10,8 +10,6 @@ #include #include - - #include #include #include @@ -19,11 +17,15 @@ #include #include + #if OBSW_PERFORM_L3GD20H_TEST == 1 #include "fsfw_hal/stm32h7/spi/SpiCookie.h" #include "fsfw_hal/stm32h7/spi/SpiComIF.h" #include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" - +#include "fsfw_hal/stm32h7/spi/stm32h743ziSpi.h" +#include "fsfw_hal/stm32h7/spi/spiCore.h" +DMA_HandleTypeDef* txHandle = nullptr; +DMA_HandleTypeDef* rxHandle = nullptr; #endif void ObjectFactory::produce(void* args) { @@ -65,9 +67,31 @@ void ObjectFactory::produce(void* args) { #if OBSW_PERFORM_L3GD20H_TEST == 1 - new SpiComIF(objects::SPI_COM_IF, spi::TransferModes::INTERRUPT); - auto spiCookie = new SpiCookie(0, spi::SpiBus::SPI_1, SPI1, 3900000, spi::SpiModes::MODE_3, - GPIO_PIN_14, GPIOD, 32); + spi::MspCfgBase* mspCfg = nullptr; + spi::TransferModes transferMode = spi::TransferModes::INTERRUPT; + if(transferMode == spi::TransferModes::POLLING) { + auto typedCfg = new spi::MspPollingConfigStruct(); + spi::h743zi::standardPollingCfg(*typedCfg); + mspCfg = typedCfg; + } + else if(transferMode == spi::TransferModes::INTERRUPT) { + auto typedCfg = new spi::MspIrqConfigStruct(); + spi::h743zi::standardInterruptCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS); + mspCfg = typedCfg; + } + else if(transferMode == spi::TransferModes::DMA) { + auto typedCfg = new spi::MspDmaConfigStruct(); + txHandle = new DMA_HandleTypeDef(); + rxHandle = new DMA_HandleTypeDef(); + spi::setDmaHandles(txHandle, rxHandle); + spi::h743zi::standardDmaCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS, + IrqPriorities::HIGHEST_FREERTOS, IrqPriorities::HIGHEST_FREERTOS); + mspCfg = typedCfg; + } + + new SpiComIF(objects::SPI_COM_IF); + auto spiCookie = new SpiCookie(0, spi::SpiBus::SPI_1, transferMode, mspCfg, 3900000, + spi::SpiModes::MODE_3, GPIO_PIN_14, GPIOD, 32); auto gyroDevice = new GyroHandlerL3GD20H(objects::SPI_DEVICE_TEST, objects::SPI_COM_IF, spiCookie); gyroDevice->setStartUpImmediately(); diff --git a/fsfw_hal b/fsfw_hal index 8f61c23..621fe97 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit 8f61c23e624e55e44c3410f0204010559e2bd7d9 +Subproject commit 621fe97d5d06cc358e46caf76e8a9f8826e5b919