more cleaning up

This commit is contained in:
Robin Müller 2021-10-27 18:11:56 +02:00
parent cb7399b999
commit 7c855592d0
4 changed files with 15 additions and 16 deletions

View File

@ -4,7 +4,7 @@
#include "fsfw_hal/stm32h7/spi/spiDefinitions.h" #include "fsfw_hal/stm32h7/spi/spiDefinitions.h"
#include "fsfw_hal/stm32h7/spi/spiCore.h" #include "fsfw_hal/stm32h7/spi/spiCore.h"
#include "fsfw_hal/stm32h7/spi/spiInterrupts.h" #include "fsfw_hal/stm32h7/spi/spiInterrupts.h"
#include "fsfw_hal/stm32h7/spi/stm32h743ziSpi.h" #include "fsfw_hal/stm32h7/spi/stm32h743zi.h"
#include "fsfw/tasks/TaskFactory.h" #include "fsfw/tasks/TaskFactory.h"
#include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/ServiceInterface.h"
@ -33,20 +33,20 @@ GyroL3GD20H::GyroL3GD20H(SPI_HandleTypeDef *spiHandle, spi::TransferModes transf
mspCfg = new spi::MspDmaConfigStruct(); mspCfg = new spi::MspDmaConfigStruct();
auto typedCfg = dynamic_cast<spi::MspDmaConfigStruct*>(mspCfg); auto typedCfg = dynamic_cast<spi::MspDmaConfigStruct*>(mspCfg);
spi::setDmaHandles(txDmaHandle, rxDmaHandle); spi::setDmaHandles(txDmaHandle, rxDmaHandle);
spi::h743zi::standardDmaCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS, stm32h7::h743zi::standardDmaCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS,
IrqPriorities::HIGHEST_FREERTOS, IrqPriorities::HIGHEST_FREERTOS); IrqPriorities::HIGHEST_FREERTOS, IrqPriorities::HIGHEST_FREERTOS);
spi::setSpiDmaMspFunctions(typedCfg); spi::setSpiDmaMspFunctions(typedCfg);
} }
else if(transferMode == spi::TransferModes::INTERRUPT) { else if(transferMode == spi::TransferModes::INTERRUPT) {
mspCfg = new spi::MspIrqConfigStruct(); mspCfg = new spi::MspIrqConfigStruct();
auto typedCfg = dynamic_cast<spi::MspIrqConfigStruct*>(mspCfg); auto typedCfg = dynamic_cast<spi::MspIrqConfigStruct*>(mspCfg);
spi::h743zi::standardInterruptCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS); stm32h7::h743zi::standardInterruptCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS);
spi::setSpiIrqMspFunctions(typedCfg); spi::setSpiIrqMspFunctions(typedCfg);
} }
else if(transferMode == spi::TransferModes::POLLING) { else if(transferMode == spi::TransferModes::POLLING) {
mspCfg = new spi::MspPollingConfigStruct(); mspCfg = new spi::MspPollingConfigStruct();
auto typedCfg = dynamic_cast<spi::MspPollingConfigStruct*>(mspCfg); auto typedCfg = dynamic_cast<spi::MspPollingConfigStruct*>(mspCfg);
spi::h743zi::standardPollingCfg(*typedCfg); stm32h7::h743zi::standardPollingCfg(*typedCfg);
spi::setSpiPollingMspFunctions(typedCfg); spi::setSpiPollingMspFunctions(typedCfg);
} }

View File

@ -5,5 +5,5 @@ target_sources(${LIB_FSFW_NAME} PRIVATE
mspInit.cpp mspInit.cpp
SpiCookie.cpp SpiCookie.cpp
SpiComIF.cpp SpiComIF.cpp
stm32h743ziSpi.cpp stm32h743zi.cpp
) )

View File

@ -1,4 +1,4 @@
#include "fsfw_hal/stm32h7/spi/stm32h743ziSpi.h" #include "fsfw_hal/stm32h7/spi/stm32h743zi.h"
#include "fsfw_hal/stm32h7/spi/spiCore.h" #include "fsfw_hal/stm32h7/spi/spiCore.h"
#include "fsfw_hal/stm32h7/spi/spiInterrupts.h" #include "fsfw_hal/stm32h7/spi/spiInterrupts.h"
@ -22,7 +22,7 @@ void spiDmaClockEnableWrapper() {
__HAL_RCC_DMA2_CLK_ENABLE(); __HAL_RCC_DMA2_CLK_ENABLE();
} }
void spi::h743zi::standardPollingCfg(MspPollingConfigStruct& cfg) { void stm32h7::h743zi::standardPollingCfg(spi::MspPollingConfigStruct& cfg) {
cfg.setupCb = &spiSetupWrapper; cfg.setupCb = &spiSetupWrapper;
cfg.cleanupCb = &spiCleanUpWrapper; cfg.cleanupCb = &spiCleanUpWrapper;
cfg.sck.port = GPIOA; cfg.sck.port = GPIOA;
@ -36,13 +36,13 @@ void spi::h743zi::standardPollingCfg(MspPollingConfigStruct& cfg) {
cfg.miso.altFnc = GPIO_AF5_SPI1; cfg.miso.altFnc = GPIO_AF5_SPI1;
} }
void spi::h743zi::standardInterruptCfg(MspIrqConfigStruct& cfg, IrqPriorities spiIrqPrio, void stm32h7::h743zi::standardInterruptCfg(spi::MspIrqConfigStruct& cfg, IrqPriorities spiIrqPrio,
IrqPriorities spiSubprio) { IrqPriorities spiSubprio) {
// High, but works on FreeRTOS as well (priorities range from 0 to 15) // High, but works on FreeRTOS as well (priorities range from 0 to 15)
cfg.preEmptPriority = spiIrqPrio; cfg.preEmptPriority = spiIrqPrio;
cfg.subpriority = spiSubprio; cfg.subpriority = spiSubprio;
cfg.spiIrqNumber = SPI1_IRQn; cfg.spiIrqNumber = SPI1_IRQn;
cfg.spiBus = SpiBus::SPI_1; cfg.spiBus = spi::SpiBus::SPI_1;
user_handler_t spiUserHandler = nullptr; user_handler_t spiUserHandler = nullptr;
user_args_t spiUserArgs = nullptr; user_args_t spiUserArgs = nullptr;
getSpiUserHandler(spi::SpiBus::SPI_1, &spiUserHandler, &spiUserArgs); getSpiUserHandler(spi::SpiBus::SPI_1, &spiUserHandler, &spiUserArgs);
@ -55,7 +55,7 @@ void spi::h743zi::standardInterruptCfg(MspIrqConfigStruct& cfg, IrqPriorities sp
standardPollingCfg(cfg); standardPollingCfg(cfg);
} }
void spi::h743zi::standardDmaCfg(MspDmaConfigStruct& cfg, IrqPriorities spiIrqPrio, void stm32h7::h743zi::standardDmaCfg(spi::MspDmaConfigStruct& cfg, IrqPriorities spiIrqPrio,
IrqPriorities txIrqPrio, IrqPriorities rxIrqPrio, IrqPriorities spiSubprio, IrqPriorities txIrqPrio, IrqPriorities rxIrqPrio, IrqPriorities spiSubprio,
IrqPriorities txSubprio, IrqPriorities rxSubprio) { IrqPriorities txSubprio, IrqPriorities rxSubprio) {
cfg.dmaClkEnableWrapper = &spiDmaClockEnableWrapper; cfg.dmaClkEnableWrapper = &spiDmaClockEnableWrapper;

View File

@ -3,21 +3,20 @@
#include "mspInit.h" #include "mspInit.h"
namespace spi { namespace stm32h7 {
namespace h743zi { namespace h743zi {
void standardPollingCfg(MspPollingConfigStruct& cfg); void standardPollingCfg(spi::MspPollingConfigStruct& cfg);
void standardInterruptCfg(MspIrqConfigStruct& cfg, IrqPriorities spiIrqPrio, void standardInterruptCfg(spi::MspIrqConfigStruct& cfg, IrqPriorities spiIrqPrio,
IrqPriorities spiSubprio = HIGHEST); IrqPriorities spiSubprio = HIGHEST);
void standardDmaCfg(MspDmaConfigStruct& cfg, IrqPriorities spiIrqPrio, void standardDmaCfg(spi::MspDmaConfigStruct& cfg, IrqPriorities spiIrqPrio,
IrqPriorities txIrqPrio, IrqPriorities rxIrqPrio, IrqPriorities txIrqPrio, IrqPriorities rxIrqPrio,
IrqPriorities spiSubprio = HIGHEST, IrqPriorities txSubPrio = HIGHEST, IrqPriorities spiSubprio = HIGHEST, IrqPriorities txSubPrio = HIGHEST,
IrqPriorities rxSubprio = HIGHEST); IrqPriorities rxSubprio = HIGHEST);
} }
} }
#endif /* FSFW_HAL_STM32H7_SPI_STM32H743ZISPI_H_ */ #endif /* FSFW_HAL_STM32H7_SPI_STM32H743ZISPI_H_ */