Skip to content

Commit 7dbf56e

Browse files
committed
UART: fix ringbuffer TX
1 parent 068d62b commit 7dbf56e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cores/arduino/Serial.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ class UART : public arduino::HardwareSerial {
132132
volatile bool _begin;
133133

134134
private:
135-
inline void inc(int &x,int _max) { x = ++x % _max; }
135+
inline void inc(volatile int &x,int _max) { x = ++x % _max; }
136136
inline int previous(int x, int _max) { return ((--x) >= 0) ? x : _max -1; }
137-
137+
138138
int channel;
139139
TxStatus_t tx_st;
140140
void set_tx_status(TxStatus_t st) { tx_st = st; }
@@ -151,8 +151,8 @@ class UART : public arduino::HardwareSerial {
151151
uint8_t rx_buffer[SERIAL_RX_BUFFER_SIZE];
152152
/* tx STUFF.... */
153153
uint8_t tx_buffer[SERIAL_TX_BUFFER_SIZE];
154-
int tx_head_index = -1;
155-
int tx_tail_index = -1;
154+
volatile int tx_head_index = -1;
155+
volatile int tx_tail_index = -1;
156156
int get_tx_head_index() { return tx_head_index; }
157157
int get_tx_tail_index() { return tx_tail_index; }
158158
void inc_tx_head_index() { inc(tx_head_index,SERIAL_TX_BUFFER_SIZE); }

0 commit comments

Comments
 (0)