usbuart: Moved the aux UART RX interrupt handling into aux_serial.c

This commit is contained in:
dragonmux 2022-08-20 16:13:23 +01:00 committed by Piotr Esden-Tempski
parent a3703186be
commit 5d94ea3017
2 changed files with 53 additions and 69 deletions

View File

@ -265,6 +265,59 @@ void aux_serial_send(const size_t len)
usbuart_set_led_state(TX_LED_ACT, true);
}
}
static void aux_serial_receive_isr(const uint32_t usart, const uint8_t dma_irq)
{
nvic_disable_irq(dma_irq);
/* Get IDLE flag and reset interrupt flags */
const bool is_idle = usart_get_flag(usart, USART_FLAG_IDLE);
usart_recv(usart);
/* If line is now idle, then transmit a packet */
if (is_idle) {
#ifdef USART_ICR
USART_ICR(usart) = USART_ICR_IDLECF;
#endif
debug_uart_run();
}
nvic_enable_irq(dma_irq);
}
#if defined(USBUSART_ISR)
void USBUSART_ISR(void)
{
#if defined(USBUSART_DMA_RXTX_IRQ)
aux_serial_receive_isr(USBUSART, USBUSART_DMA_RXTX_IRQ);
#else
aux_serial_receive_isr(USBUSART, USBUSART_DMA_RX_IRQ);
#endif
}
#endif
#if defined(USBUSART1_ISR)
void USBUSART1_ISR(void)
{
#if defined(USBUSART1_DMA_RXTX_IRQ)
aux_serial_receive_isr(USBUSART1, USBUSART1_DMA_RXTX_IRQ);
#else
aux_serial_receive_isr(USBUSART1, USBUSART1_DMA_RX_IRQ);
#endif
}
#endif
#if defined(USBUSART2_ISR)
void USBUSART2_ISR(void)
{
#if defined(USBUSART2_DMA_RXTX_IRQ)
aux_serial_receive_isr(USBUSART2, USBUSART2_DMA_RXTX_IRQ);
#else
aux_serial_receive_isr(USBUSART2, USBUSART2_DMA_RX_IRQ);
#endif
}
#endif
#elif defined(LM4F)
char *aux_serial_current_transmit_buffer(void)
{

View File

@ -78,75 +78,6 @@ void usbuart_set_led_state(uint8_t ledn, bool state)
}
}
#if defined(USART_ICR)
#define USBUSART_ISR_TEMPLATE(USART, DMA_IRQ) do { \
nvic_disable_irq(DMA_IRQ); \
\
/* Get IDLE flag and reset interrupt flags */ \
const bool isIdle = usart_get_flag(USART, USART_FLAG_IDLE); \
usart_recv(USART); \
\
/* If line is now idle, then transmit a packet */ \
if (isIdle) { \
USART_ICR(USART) = USART_ICR_IDLECF; \
debug_uart_run(); \
} \
\
nvic_enable_irq(DMA_IRQ); \
} while(0)
#else
#define USBUSART_ISR_TEMPLATE(USART, DMA_IRQ) do { \
nvic_disable_irq(DMA_IRQ); \
\
/* Get IDLE flag and reset interrupt flags */ \
const bool isIdle = usart_get_flag(USART, USART_FLAG_IDLE); \
usart_recv(USART); \
\
/* If line is now idle, then transmit a packet */ \
if (isIdle) { \
/* On the older uarts, the sequence "read flags", */ \
/* "read DR" clears the flags */ \
\
debug_uart_run(); \
} \
\
nvic_enable_irq(DMA_IRQ); \
} while(0)
#endif
#if defined(USBUSART_ISR)
void USBUSART_ISR(void)
{
#if defined(USBUSART_DMA_RXTX_IRQ)
USBUSART_ISR_TEMPLATE(USBUSART, USBUSART_DMA_RXTX_IRQ);
#else
USBUSART_ISR_TEMPLATE(USBUSART, USBUSART_DMA_RX_IRQ);
#endif
}
#endif
#if defined(USBUSART1_ISR)
void USBUSART1_ISR(void)
{
#if defined(USBUSART1_DMA_RXTX_IRQ)
USBUSART_ISR_TEMPLATE(USBUSART1, USBUSART1_DMA_RXTX_IRQ);
#else
USBUSART_ISR_TEMPLATE(USBUSART1, USBUSART1_DMA_RX_IRQ);
#endif
}
#endif
#if defined(USBUSART2_ISR)
void USBUSART2_ISR(void)
{
#if defined(USBUSART2_DMA_RXTX_IRQ)
USBUSART_ISR_TEMPLATE(USBUSART2, USBUSART2_DMA_RXTX_IRQ);
#else
USBUSART_ISR_TEMPLATE(USBUSART2, USBUSART2_DMA_RX_IRQ);
#endif
}
#endif
#define USBUSART_DMA_TX_ISR_TEMPLATE(DMA_TX_CHAN) do { \
nvic_disable_irq(USB_IRQ); \
\