Skip to content

Commit ccddc1f

Browse files
2 parents 437834a + 8c433e3 commit ccddc1f

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

STM32F1/cores/maple/HardwareSerial.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ size_t HardwareSerial::write(unsigned char ch) {
193193
return 1;
194194
}
195195

196+
/* edogaldo: Waits for the transmission of outgoing serial data to complete (Arduino 1.0 api specs) */
196197
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
199200
}

STM32F1/system/libmaple/include/libmaple/ring_buffer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ extern "C"{
5252
* One byte is left free to distinguish empty from full. */
5353
typedef struct ring_buffer {
5454
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 */
5858
} ring_buffer;
5959

6060
/**

STM32F1/variants/generic_stm32f103t/wirish/boards.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ nvic_init((uint32)VECT_TAB_ADDR, 0);
179179
*/
180180
}
181181

182-
static void adc_default_config(const adc_dev *dev) {
182+
static void adc_default_config(adc_dev *dev) {
183183
adc_enable_single_swstart(dev);
184184
adc_set_sample_rate(dev, wirish::priv::w_adc_smp);
185185
}

0 commit comments

Comments
 (0)