added IRS abstraction

This commit is contained in:
Robin Müller 2021-06-03 15:12:34 +02:00
parent 21414c3594
commit 78a66e1b67
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
7 changed files with 124 additions and 29 deletions

View File

@ -1,2 +1,6 @@
add_subdirectory(spi)
add_subdirectory(devicetest)
target_sources(${TARGET_NAME} PRIVATE
interrupts.c
)

35
stm32h7/interrupts.c Normal file
View File

@ -0,0 +1,35 @@
#include "interrupts.h"
#include <stddef.h>
void Default_Handler();
void (*dma2_stream3_user_handler) (void* args) = NULL;
void * dma2_stream3_user_args = NULL;
void (*dma2_stream2_user_handler) (void* args) = NULL;
void * dma2_stream2_user_args = NULL;
void assign_dma2_stream2_user_handler(user_handler_t user_handler, user_args_t user_args) {
dma2_stream2_user_handler = user_handler;
dma2_stream2_user_args = user_args;
}
void assign_dma2_stream3_user_handler(user_handler_t user_handler, user_args_t user_args) {
dma2_stream3_user_handler = user_handler;
dma2_stream3_user_args = user_args;
}
void DMA2_Stream3_IRQHandler() {
if(dma2_stream3_user_handler != NULL) {
dma2_stream3_user_handler(dma2_stream3_user_args);
}
Default_Handler();
}
void DMA2_Stream2_IRQHandler() {
if(dma2_stream2_user_handler != NULL) {
dma2_stream2_user_handler(dma2_stream2_user_args);
}
Default_Handler();
}

23
stm32h7/interrupts.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef FSFW_HAL_STM32H7_INTERRUPTS_H_
#define FSFW_HAL_STM32H7_INTERRUPTS_H_
#ifdef __cplusplus
extern "C" {
#endif
/**
* Default handler which is defined in startup file as assembly code.
*/
extern void Default_Handler();
typedef void (*user_handler_t) (void*);
typedef void* user_args_t;
void assign_dma2_stream2_user_handler(user_handler_t user_handler, user_args_t user_args);
void assign_dma2_stream3_user_handler(user_handler_t user_handler, user_args_t user_args);
#ifdef __cplusplus
}
#endif
#endif /* FSFW_HAL_STM32H7_INTERRUPTS_H_ */

View File

@ -1,4 +1,5 @@
target_sources(${TARGET_NAME} PRIVATE
spiCore.c
spiDefinitions.cpp
interrupts.c
)

12
stm32h7/spi/interrupts.c Normal file
View File

@ -0,0 +1,12 @@
#include "interrupts.h"
#include <stddef.h>
void SPI1_IRQHandler() {
}
void SPI2_IRQHandler() {
}

8
stm32h7/spi/interrupts.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef FSFW_HAL_STM32H7_INTERRUPTS_H_
#define FSFW_HAL_STM32H7_INTERRUPTS_H_
#endif /* FSFW_HAL_STM32H7_INTERRUPTS_H_ */

View File

@ -25,32 +25,44 @@ SPI_HandleTypeDef* getSpiHandle() {
return spiHandle;
}
/**
* @brief This function handles DMA Rx interrupt request.
* @param None
* @retval None
*/
void SPIx_DMA_RX_IRQHandler(void)
{
HAL_DMA_IRQHandler(spiHandle->hdmarx);
}
/**
* @brief This function handles DMA Tx interrupt request.
* @param None
* @retval None
*/
void SPIx_DMA_TX_IRQHandler(void)
{
HAL_DMA_IRQHandler(spiHandle->hdmatx);
}
/**
* @brief This function handles SPIx interrupt request.
* @param None
* @retval None
*/
void SPIx_IRQHandler(void)
{
HAL_SPI_IRQHandler(spiHandle);
}
///**
// * @brief This function handles DMA Rx interrupt request.
// * @param None
// * @retval None
// */
//void SPIx_DMA_RX_IRQHandler(void)
//{
// HAL_DMA_IRQHandler(spiHandle->hdmarx);
//}
//
///**
// * @brief This function handles DMA Tx interrupt request.
// * @param None
// * @retval None
// */
//void SPIx_DMA_TX_IRQHandler(void)
//{
// HAL_DMA_IRQHandler(spiHandle->hdmatx);
//}
//
//void DMA2_Stream3_IRQHandler() {
// SPIx_DMA_TX_IRQHandler();
//}
//
//void DMA2_Stream2_IRQHandler() {
// SPIx_DMA_RX_IRQHandler();
//}
//
///**
// * @brief This function handles SPIx interrupt request.
// * @param None
// * @retval None
// */
//void SPIx_IRQHandler(void)
//{
// HAL_SPI_IRQHandler(spiHandle);
//}
//
//void SPI1_IRQHandler(void) {
// SPIx_IRQHandler();
//}