85 lines
2.2 KiB
C
85 lines
2.2 KiB
C
|
#include "dma_interrupts.h"
|
||
|
|
||
|
#include <stdint.h>
|
||
|
#include <stddef.h>
|
||
|
|
||
|
user_handler_t DMA_1_USER_HANDLERS[8];
|
||
|
user_args_t DMA_1_USER_ARGS[8];
|
||
|
|
||
|
user_handler_t DMA_2_USER_HANDLERS[8];
|
||
|
user_args_t DMA_2_USER_ARGS[8];
|
||
|
|
||
|
void assign_dma_user_handler(DMAIndexes dma_idx, DMAStreams stream_idx,
|
||
|
user_handler_t user_handler, user_args_t user_args) {
|
||
|
if(dma_idx == DMA_1) {
|
||
|
DMA_1_USER_HANDLERS[stream_idx] = user_handler;
|
||
|
DMA_1_USER_ARGS[stream_idx] = user_args;
|
||
|
}
|
||
|
else if(dma_idx == DMA_2) {
|
||
|
DMA_2_USER_HANDLERS[stream_idx] = user_handler;
|
||
|
DMA_2_USER_ARGS[stream_idx] = user_args;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// The interrupt handlers in the format required for the IRQ vector table
|
||
|
|
||
|
/* 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! */
|
||
|
|
||
|
#define GENERIC_DMA_IRQ_HANDLER(DMA_IDX, STREAM_IDX) \
|
||
|
if(DMA_##DMA_IDX##_USER_HANDLERS[STREAM_IDX] != NULL) { \
|
||
|
DMA_##DMA_IDX##_USER_HANDLERS[STREAM_IDX](DMA_##DMA_IDX##_USER_ARGS[STREAM_IDX]); \
|
||
|
return; \
|
||
|
} \
|
||
|
Default_Handler() \
|
||
|
|
||
|
void DMA1_Stream0_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(1, 0);
|
||
|
}
|
||
|
void DMA1_Stream1_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(1, 1);
|
||
|
}
|
||
|
void DMA1_Stream2_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(1, 2);
|
||
|
}
|
||
|
void DMA1_Stream3_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(1, 3);
|
||
|
}
|
||
|
void DMA1_Stream4_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(1, 4);
|
||
|
}
|
||
|
void DMA1_Stream5_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(1, 5);
|
||
|
}
|
||
|
void DMA1_Stream6_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(1, 6);
|
||
|
}
|
||
|
void DMA1_Stream7_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(1, 7);
|
||
|
}
|
||
|
|
||
|
void DMA2_Stream0_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(2, 0);
|
||
|
}
|
||
|
void DMA2_Stream1_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(2, 1);
|
||
|
}
|
||
|
void DMA2_Stream2_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(2, 2);
|
||
|
}
|
||
|
void DMA2_Stream3_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(2, 3);
|
||
|
}
|
||
|
void DMA2_Stream4_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(2, 4);
|
||
|
}
|
||
|
void DMA2_Stream5_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(2, 5);
|
||
|
}
|
||
|
void DMA2_Stream6_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(2, 6);
|
||
|
}
|
||
|
void DMA2_Stream7_IRQHandler() {
|
||
|
GENERIC_DMA_IRQ_HANDLER(2, 7);
|
||
|
}
|