Skip to content

Commit

Permalink
ok, it's fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
geohot committed Jan 28, 2018
1 parent 915cd84 commit 1465aa4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion board/drivers/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ void uart_dma_drain() {
// disable DMA
q->uart->CR3 &= ~USART_CR3_DMAR;
DMA2_Stream5->CR &= ~DMA_SxCR_EN;
while (DMA2_Stream5->CR & DMA_SxCR_EN);

int i;
for (i = 0; i < USART1_DMA_LEN - DMA2_Stream5->NDTR; i++) {
Expand All @@ -188,6 +189,7 @@ void uart_dma_drain() {

// clear interrupts
DMA2->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5;
//DMA2->HIFCR = DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5;

// enable DMA
DMA2_Stream5->CR |= DMA_SxCR_EN;
Expand All @@ -199,6 +201,7 @@ void uart_dma_drain() {
void DMA2_Stream5_IRQHandler(void) {
//set_led(LED_BLUE, 1);
uart_dma_drain();
//set_led(LED_BLUE, 0);
}

void uart_init(USART_TypeDef *u, int baud) {
Expand All @@ -224,7 +227,7 @@ void uart_init(USART_TypeDef *u, int baud) {

// channel4, increment memory, periph -> memory, enable
DMA2_Stream5->CR = DMA_SxCR_CHSEL_2 | DMA_SxCR_MINC | DMA_SxCR_EN;
DMA2_Stream5->CR |= DMA_SxCR_TCIE | DMA_SxCR_HTIE;
DMA2_Stream5->CR |= DMA_SxCR_HTIE;

// this one uses DMA receiver
u->CR3 = USART_CR3_DMAR;
Expand Down

0 comments on commit 1465aa4

Please sign in to comment.