File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
system/libmaple/include/libmaple Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,8 @@ size_t HardwareSerial::write(unsigned char ch) {
193
193
return 1 ;
194
194
}
195
195
196
+ /* edogaldo: Waits for the transmission of outgoing serial data to complete (Arduino 1.0 api specs) */
196
197
void HardwareSerial::flush (void ) {
197
- usart_reset_rx ( this ->usart_device );
198
- usart_reset_tx ( this ->usart_device );
198
+ while (! rb_is_empty ( this ->usart_device -> wb )); // wait for TX buffer empty
199
+ while (!(( this ->usart_device -> regs -> SR ) & ( 1 <<USART_SR_TC_BIT))); // wait for TC (Transmission Complete) flag set
199
200
}
Original file line number Diff line number Diff line change @@ -52,9 +52,9 @@ extern "C"{
52
52
* One byte is left free to distinguish empty from full. */
53
53
typedef struct ring_buffer {
54
54
volatile uint8 * buf ; /**< Buffer items are stored into */
55
- uint16 head ; /**< Index of the next item to remove */
56
- uint16 tail ; /**< Index where the next item will get inserted */
57
- uint16 size ; /**< Buffer capacity minus one */
55
+ volatile uint16 head ; /**< Index of the next item to remove */
56
+ volatile uint16 tail ; /**< Index where the next item will get inserted */
57
+ volatile uint16 size ; /**< Buffer capacity minus one */
58
58
} ring_buffer ;
59
59
60
60
/**
You can’t perform that action at this time.
0 commit comments