Wait for TX completed in usart_disable()

This commit is contained in:
edogaldo 2016-07-14 19:14:56 +02:00
parent 51d2d9e0d9
commit 3a5f8cfc1b
1 changed files with 2 additions and 0 deletions

View File

@ -70,6 +70,8 @@ void usart_disable(usart_dev *dev) {
/* FIXME this misbehaves (on F1) if you try to use PWM on TX afterwards */
usart_reg_map *regs = dev->regs;
while(!rb_is_empty(dev->wb))
; // wait for TX completed
/* TC bit must be high before disabling the USART */
while((regs->CR1 & USART_CR1_UE) && !(regs->SR & USART_SR_TC))
;