fsfw-hal/stm32h7/spi/spiCore.c

55 lines
1.2 KiB
C

#include "spiCore.h"
SPI_HandleTypeDef* spiHandle = NULL;
DMA_HandleTypeDef* hdma_tx = NULL;
DMA_HandleTypeDef* hdma_rx = NULL;
void setDmaHandles(DMA_HandleTypeDef* txHandle, DMA_HandleTypeDef* rxHandle) {
hdma_tx = txHandle;
hdma_rx = rxHandle;
}
void getDmaHandles(DMA_HandleTypeDef** txHandle, DMA_HandleTypeDef** rxHandle) {
*txHandle = hdma_tx;
*rxHandle = hdma_rx;
}
void assignSpiHandle(SPI_HandleTypeDef *spiHandle_) {
if(spiHandle_ == NULL) {
return;
}
spiHandle = spiHandle_;
}
SPI_HandleTypeDef* getSpiHandle() {
return spiHandle;
}
/**
* @brief This function handles DMA Rx interrupt request.
* @param None
* @retval None
*/
void dma_rx_irq_handler(void* dma_handle) {
HAL_DMA_IRQHandler((DMA_HandleTypeDef *) dma_handle);
}
/**
* @brief This function handles DMA Rx interrupt request.
* @param None
* @retval None
*/
void dma_tx_irq_handler(void* dma_handle) {
HAL_DMA_IRQHandler((DMA_HandleTypeDef *) dma_handle);
}
/**
* @brief This function handles SPIx interrupt request.
* @param None
* @retval None
*/
void spi1_irq_handler(void* spi_handle)
{
HAL_SPI_IRQHandler((SPI_HandleTypeDef *) spi_handle);
}