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-04 15:50:02 +02:00
|
|
|
|
2021-06-04 16:34:38 +02:00
|
|
|
void (*spi1_user_handler) (void* args) = nullptr;
|
|
|
|
void * spi1_user_args = nullptr;
|
2021-06-03 16:11:49 +02:00
|
|
|
|
2021-06-04 16:34:38 +02:00
|
|
|
void (*spi2_user_handler) (void* args) = nullptr;
|
|
|
|
void * spi2_user_args = nullptr;
|
2021-06-03 15:12:34 +02:00
|
|
|
|
2021-06-04 15:50:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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);
|
|
|
|
}
|
|
|
|
|
2021-06-04 16:34:38 +02:00
|
|
|
void assign_spi_user_handler(spi::SpiBus spi_idx, user_handler_t user_handler,
|
|
|
|
user_args_t user_args) {
|
|
|
|
if(spi_idx == spi::SpiBus::SPI_1) {
|
|
|
|
spi1_user_handler = user_handler;
|
|
|
|
spi1_user_args = user_args;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
spi2_user_handler = user_handler;
|
|
|
|
spi2_user_args = user_args;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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() {
|
|
|
|
if(spi1_user_handler != NULL) {
|
|
|
|
spi1_user_handler(spi1_user_args);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Default_Handler();
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void SPI2_IRQHandler() {
|
|
|
|
if(spi2_user_handler != NULL) {
|
|
|
|
spi2_user_handler(spi2_user_args);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Default_Handler();
|
|
|
|
}
|
|
|
|
|
|
|
|
|