fsfw-hal/stm32h7/spi/spiInterrupts.cpp

75 lines
1.7 KiB
C++
Raw Normal View History

2021-06-04 16:34:38 +02:00
#include "spiInterrupts.h"
2021-06-03 15:12:34 +02:00
2021-06-04 15:50:02 +02:00
#include "stm32h7xx_hal.h"
#include "stm32h7xx_hal_dma.h"
#include "stm32h7xx_hal_spi.h"
2021-06-03 15:12:34 +02:00
#include <stddef.h>
2021-06-05 13:29:43 +02:00
user_handler_t spi1UserHandler = nullptr;
user_args_t spi1UserArgs = nullptr;
2021-06-04 15:50:02 +02:00
2021-06-05 13:29:43 +02:00
user_handler_t spi2UserHandler = nullptr;
user_args_t spi2UserArgs = nullptr;
2021-06-04 15:50:02 +02:00
/**
* @brief This function handles DMA Rx interrupt request.
* @param None
* @retval None
*/
2021-06-05 13:29:43 +02:00
void spi::dmaRxIrqHandler(void* dmaHandle) {
HAL_DMA_IRQHandler((DMA_HandleTypeDef *) dmaHandle);
2021-06-04 15:50:02 +02:00
}
/**
* @brief This function handles DMA Rx interrupt request.
* @param None
* @retval None
*/
2021-06-05 13:29:43 +02:00
void spi::dmaTxIrqHandler(void* dmaHandle) {
HAL_DMA_IRQHandler((DMA_HandleTypeDef *) dmaHandle);
2021-06-04 15:50:02 +02:00
}
/**
* @brief This function handles SPIx interrupt request.
* @param None
* @retval None
*/
2021-06-05 13:29:43 +02:00
void spi::spi1IrqHandler(void* spiHandle)
2021-06-04 15:50:02 +02:00
{
2021-06-05 13:29:43 +02:00
HAL_SPI_IRQHandler((SPI_HandleTypeDef *) spiHandle);
2021-06-04 15:50:02 +02:00
}
2021-06-05 13:29:43 +02:00
void spi::assignSpiUserHandler(spi::SpiBus spiIdx, user_handler_t userHandler,
user_args_t userArgs) {
if(spiIdx == spi::SpiBus::SPI_1) {
spi1UserHandler = userHandler;
spi1UserArgs = userArgs;
2021-06-04 16:34:38 +02:00
}
else {
2021-06-05 13:29:43 +02:00
spi2UserHandler = userHandler;
spi2UserArgs = userArgs;
2021-06-04 16:34:38 +02:00
}
}
/* Do not change these function names! They need to be exactly equal to the name of the functions
defined in the startup_stm32h743xx.s files! */
extern "C" void SPI1_IRQHandler() {
2021-06-05 13:29:43 +02:00
if(spi1UserHandler != NULL) {
spi1UserHandler(spi1UserArgs);
2021-06-04 16:34:38 +02:00
return;
}
Default_Handler();
}
extern "C" void SPI2_IRQHandler() {
2021-06-05 13:29:43 +02:00
if(spi2UserHandler != nullptr) {
spi2UserHandler(spi2UserArgs);
2021-06-04 16:34:38 +02:00
return;
}
Default_Handler();
}