adding irq abstraction
This commit is contained in:
parent
0d9c3eef4f
commit
72aa8fec69
@ -43,6 +43,6 @@
|
||||
#define SPIx_DMA_RX_IRQHandler DMA2_Stream2_IRQHandler
|
||||
|
||||
#define SPIx_IRQn SPI1_IRQn
|
||||
#define SPIx_IRQHandler SPI1_IRQHandler
|
||||
#define SPIx_IRQHandler SPIx_IRQHandler
|
||||
|
||||
#endif /* FSFW_HAL_STM32H7_DEVICETEST_SPICONF_H_ */
|
||||
|
@ -7,7 +7,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void setDmaHandles(DMA_HandleTypeDef* txHandle, DMA_HandleTypeDef* rxHandle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "spiConf.h"
|
||||
|
||||
#include "fsfw_hal/stm32h7/spi/spiCore.h"
|
||||
|
||||
#include "stm32h743xx.h"
|
||||
#include "stm32h7xx_hal_spi.h"
|
||||
#include "stm32h7xx_hal_dma.h"
|
||||
@ -7,14 +9,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
DMA_HandleTypeDef* hdma_tx = NULL;
|
||||
DMA_HandleTypeDef* hdma_rx = NULL;
|
||||
SPI_HandleTypeDef* spi_handle = NULL;
|
||||
|
||||
void setDmaHandles(DMA_HandleTypeDef* txHandle, DMA_HandleTypeDef* rxHandle) {
|
||||
hdma_tx = txHandle;
|
||||
hdma_rx = rxHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SPI MSP Initialization
|
||||
@ -33,8 +27,11 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
|
||||
printf("HAL_SPI_MspInit: Invalid SPI handle!\n");
|
||||
return;
|
||||
}
|
||||
spi_handle = hspi;
|
||||
assignSpiHandle(hspi);
|
||||
|
||||
DMA_HandleTypeDef* hdma_tx = NULL;
|
||||
DMA_HandleTypeDef* hdma_rx = NULL;
|
||||
getDmaHandles(&hdma_tx, &hdma_rx);
|
||||
if(hdma_tx == NULL || hdma_rx == NULL) {
|
||||
printf("HAL_SPI_MspInit: Invalid DMA handles. Make sure to call setDmaHandles!\n");
|
||||
return;
|
||||
@ -140,6 +137,8 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
||||
{
|
||||
if(hspi->Instance == SPIx)
|
||||
{
|
||||
|
||||
|
||||
/*##-1- Reset peripherals ##################################################*/
|
||||
SPIx_FORCE_RESET();
|
||||
SPIx_RELEASE_RESET();
|
||||
@ -152,11 +151,19 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
||||
/* Deconfigure SPI MOSI */
|
||||
HAL_GPIO_DeInit(SPIx_MOSI_GPIO_PORT, SPIx_MOSI_PIN);
|
||||
|
||||
DMA_HandleTypeDef* hdma_tx = NULL;
|
||||
DMA_HandleTypeDef* hdma_rx = NULL;
|
||||
getDmaHandles(&hdma_tx, &hdma_rx);
|
||||
if(hdma_tx == NULL || hdma_rx == NULL) {
|
||||
printf("HAL_SPI_MspInit: Invalid DMA handles. Make sure to call setDmaHandles!\n");
|
||||
}
|
||||
else {
|
||||
/*##-3- Disable the DMA ####################################################*/
|
||||
/* De-Initialize the DMA associated to transmission process */
|
||||
HAL_DMA_DeInit(hdma_tx);
|
||||
/* De-Initialize the DMA associated to reception process */
|
||||
HAL_DMA_DeInit(hdma_rx);
|
||||
}
|
||||
|
||||
/*##-4- Disable the NVIC for DMA ###########################################*/
|
||||
HAL_NVIC_DisableIRQ(SPIx_DMA_TX_IRQn);
|
||||
@ -167,32 +174,32 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles DMA Rx interrupt request.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SPIx_DMA_RX_IRQHandler(void)
|
||||
{
|
||||
HAL_DMA_IRQHandler(spi_handle->hdmarx);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles DMA Tx interrupt request.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SPIx_DMA_TX_IRQHandler(void)
|
||||
{
|
||||
HAL_DMA_IRQHandler(spi_handle->hdmatx);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles SPIx interrupt request.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SPIx_IRQHandler(void)
|
||||
{
|
||||
HAL_SPI_IRQHandler(spi_handle);
|
||||
}
|
||||
///**
|
||||
// * @brief This function handles DMA Rx interrupt request.
|
||||
// * @param None
|
||||
// * @retval None
|
||||
// */
|
||||
//void SPIx_DMA_RX_IRQHandler(void)
|
||||
//{
|
||||
// HAL_DMA_IRQHandler(getSpiHandle()->hdmarx);
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * @brief This function handles DMA Tx interrupt request.
|
||||
// * @param None
|
||||
// * @retval None
|
||||
// */
|
||||
//void SPIx_DMA_TX_IRQHandler(void)
|
||||
//{
|
||||
// HAL_DMA_IRQHandler(getSpiHandle()->hdmatx);
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * @brief This function handles SPIx interrupt request.
|
||||
// * @param None
|
||||
// * @retval None
|
||||
// */
|
||||
//void SPIx_IRQHandler(void)
|
||||
//{
|
||||
// HAL_SPI_IRQHandler(getSpiHandle());
|
||||
//}
|
||||
|
2
fsfw_hal
2
fsfw_hal
@ -1 +1 @@
|
||||
Subproject commit dc6327b909005c968a4794c3d8b2f9ac94ad59e1
|
||||
Subproject commit 78a66e1b677ae0daa532db222ecdd0097c01399a
|
Reference in New Issue
Block a user