Skip to content

Commit

Permalink
FIX: trigger DMA interrupt instead of handling rx in USART interrupt …
Browse files Browse the repository at this point in the history
…handlers
  • Loading branch information
r2axz committed Dec 1, 2020
1 parent ad768fc commit 84c04e3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions usb_cdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ void DMA1_Channel2_IRQHandler() {

/* USART Interrupt Handlers */

__attribute__((always_inline)) inline static void usb_cdc_usart_irq_handler(int port, USART_TypeDef * usart, gpio_pin_t *txa_pin) {
__attribute__((always_inline)) inline static void usb_cdc_usart_irq_handler(int port, USART_TypeDef * usart, gpio_pin_t *txa_pin, uint8_t dma_irqn) {
uint32_t wait_rxne = 0;
uint32_t status = usart->SR;
if (status & USART_SR_TC) {
Expand All @@ -544,25 +544,25 @@ __attribute__((always_inline)) inline static void usb_cdc_usart_irq_handler(int
usb_cdc_notify_port_overrun(port);
}
if (status & USART_SR_IDLE) {
usb_cdc_port_rx_interrupt(port);
NVIC_SetPendingIRQ(dma_irqn);
}
while (wait_rxne && (usart->SR & USART_SR_RXNE));
(void)usart->DR;
}

void USART1_IRQHandler() {
(void)USART1_IRQHandler;
usb_cdc_usart_irq_handler(0, usb_cdc_port_usarts[0], usb_cdc_states[0].txa_pin);
usb_cdc_usart_irq_handler(0, usb_cdc_port_usarts[0], usb_cdc_states[0].txa_pin, DMA1_Channel5_IRQn);
}

void USART2_IRQHandler() {
(void)USART2_IRQHandler;
usb_cdc_usart_irq_handler(1, usb_cdc_port_usarts[1], usb_cdc_states[1].txa_pin);
usb_cdc_usart_irq_handler(1, usb_cdc_port_usarts[1], usb_cdc_states[1].txa_pin, DMA1_Channel6_IRQn);
}

void USART3_IRQHandler() {
(void)USART3_IRQHandler;
usb_cdc_usart_irq_handler(2, usb_cdc_port_usarts[2], usb_cdc_states[2].txa_pin);
usb_cdc_usart_irq_handler(2, usb_cdc_port_usarts[2], usb_cdc_states[2].txa_pin, DMA1_Channel3_IRQn);
}

/* Port Configuration & Control Lines Functions */
Expand Down

0 comments on commit 84c04e3

Please sign in to comment.