From 3d5c54e344ee8d8f769c318d034dd567da6ba25f Mon Sep 17 00:00:00 2001 From: edogaldo Date: Tue, 16 May 2017 00:00:59 +0200 Subject: [PATCH] Make HardwareSerial.flush() compatible with Arduino 1.0 api --- STM32F1/cores/maple/HardwareSerial.cpp | 5 +++-- STM32F1/system/libmaple/include/libmaple/ring_buffer.h | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/STM32F1/cores/maple/HardwareSerial.cpp b/STM32F1/cores/maple/HardwareSerial.cpp index c993bdf..024efbc 100644 --- a/STM32F1/cores/maple/HardwareSerial.cpp +++ b/STM32F1/cores/maple/HardwareSerial.cpp @@ -193,7 +193,8 @@ size_t HardwareSerial::write(unsigned char ch) { return 1; } +/* edogaldo: Waits for the transmission of outgoing serial data to complete (Arduino 1.0 api specs) */ void HardwareSerial::flush(void) { - usart_reset_rx(this->usart_device); - usart_reset_tx(this->usart_device); + while(!rb_is_empty(this->usart_device->wb)); // wait for TX buffer empty + while(!((this->usart_device->regs->SR) & (1<