IRDA: Use DMA for async TX (#608)

This commit is contained in:
Albert Kharisov
2021-08-06 00:11:35 +03:00
committed by GitHub
parent 9c38efd4ef
commit ba399abb5d
9 changed files with 657 additions and 162 deletions

View File

@@ -5,6 +5,7 @@
#include <stm32wbxx_ll_tim.h>
volatile ApiHalInterruptISR api_hal_tim_tim2_isr = NULL;
volatile ApiHalInterruptISR api_hal_tim_tim1_isr = NULL;
#define API_HAL_INTERRUPT_DMA_COUNT 2
#define API_HAL_INTERRUPT_DMA_CHANNELS_COUNT 8
@@ -32,6 +33,13 @@ void api_hal_interrupt_set_timer_isr(TIM_TypeDef* timer, ApiHalInterruptISR isr)
furi_assert(api_hal_tim_tim2_isr != NULL);
}
api_hal_tim_tim2_isr = isr;
} else if (timer == TIM1) {
if (isr) {
furi_assert(api_hal_tim_tim1_isr == NULL);
} else {
furi_assert(api_hal_tim_tim1_isr != NULL);
}
api_hal_tim_tim1_isr = isr;
} else {
furi_check(0);
}
@@ -43,7 +51,7 @@ void api_hal_interrupt_set_dma_channel_isr(DMA_TypeDef* dma, uint32_t channel, A
furi_check(channel < API_HAL_INTERRUPT_DMA_CHANNELS_COUNT);
if (dma == DMA1) {
api_hal_dma_channel_isr[0][channel] = isr;
} else if (dma == DMA1) {
} else if (dma == DMA2) {
api_hal_dma_channel_isr[1][channel] = isr;
} else {
furi_check(0);
@@ -73,6 +81,15 @@ void TIM2_IRQHandler(void) {
}
}
/* Timer 1 Update */
void TIM1_UP_TIM16_IRQHandler(void) {
if (api_hal_tim_tim1_isr) {
api_hal_tim_tim1_isr();
} else {
HAL_TIM_IRQHandler(&htim1);
}
}
/* DMA 1 */
void DMA1_Channel1_IRQHandler(void) {
if (api_hal_dma_channel_isr[0][0]) api_hal_dma_channel_isr[0][0]();