From febcb5a93316b2dc0b8c1c9daf046b03c5e7beeb Mon Sep 17 00:00:00 2001 From: jaseg Date: Wed, 6 Sep 2017 14:03:07 +0200 Subject: Fixes for second prototype (v0.3) --- fw/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'fw/main.c') diff --git a/fw/main.c b/fw/main.c index 704ac04..4cd8438 100644 --- a/fw/main.c +++ b/fw/main.c @@ -239,7 +239,8 @@ enum Command { N_CMDS }; -enum { +volatile enum { + PROT_ZERO_INVALID, PROT_ADDR_IDLE, PROT_ADDR_ERR, PROT_ADDR_COMPLETE, @@ -305,6 +306,7 @@ void USART1_IRQHandler() { USART1->CR3 &= ~USART_CR3_DMAR_Msk; DMA1_Channel3->CCR &= ~DMA_CCR_EN_Msk; DMA1->IFCR |= DMA_IFCR_CGIF3; + NVIC_ClearPendingIRQ(DMA1_Channel2_3_IRQn); protocol_state = PROT_ADDR_IDLE; USART1->RQR |= USART_RQR_RXFRQ; USART1->CR1 |= USART_CR1_RXNEIE; @@ -340,12 +342,12 @@ void USART1_IRQHandler() { /* if (fb_op != FB_WRITE) FIXME DEBUG put this back goto errout; */ - kickoff_uart_rx_dma(&rx_buf, payload_len); DMA1_Channel5->CNDTR = payload_len; protocol_state = PROT_CRC; + kickoff_uart_rx_dma(&rx_buf, payload_len); } else { - kickoff_uart_rx_dma(&rx_crc, sizeof(rx_crc)); protocol_state = PROT_COMPLETE; + kickoff_uart_rx_dma(&rx_crc, sizeof(rx_crc)); } break; default: -- cgit