Slight changes

This commit is contained in:
edogaldo 2016-07-19 12:56:11 +02:00
parent 7ba9065895
commit d353dd3022
2 changed files with 4 additions and 3 deletions

View File

@ -105,7 +105,7 @@ uint32 usart_tx(usart_dev *dev, const uint8 *buf, uint32 len) {
else
break;
}
if (rb_full_count(dev->wb) > 0) {
if (!rb_is_empty(dev->wb)) {
regs->CR1 |= USART_CR1_TXEIE;
}
return txed;

View File

@ -55,8 +55,9 @@ static inline __always_inline void usart_irq(ring_buffer *rb, ring_buffer *wb, u
}
/* TXE signifies readiness to send a byte to DR. */
if ((regs->CR1 & USART_CR1_TXEIE) && (regs->SR & USART_SR_TXE)) {
regs->DR=rb_remove(wb);
if (rb_is_empty(wb))
if (!rb_is_empty(wb))
regs->DR=rb_remove(wb);
else
regs->CR1 &= ~((uint32)USART_CR1_TXEIE); // disable TXEIE
}
}