Skip to content

Commit d3fee39

Browse files
committed
SerialUSB: shadow mbed object
1 parent 2958bc0 commit d3fee39

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

cores/arduino/Arduino.h

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ extern analogin_config_t adcCurrentConfig;
105105
#include "Serial.h"
106106
#if defined(SERIAL_CDC)
107107
#define Serial _UART_USB_
108+
#define SerialUSB _UART_USB_
108109
#else
109110
#define Serial _UART1_
110111
#endif

cores/arduino/Serial.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void UART::on_rx() {
127127
void UART::end() {
128128
#if defined(SERIAL_CDC)
129129
if (is_usb) {
130-
return SerialUSB.end();
130+
return _SerialUSB.end();
131131
}
132132
#endif
133133
if (_serial->obj != NULL) {
@@ -139,7 +139,7 @@ void UART::end() {
139139
int UART::available() {
140140
#if defined(SERIAL_CDC)
141141
if (is_usb) {
142-
return SerialUSB.available();
142+
return _SerialUSB.available();
143143
}
144144
#endif
145145
return rx_buffer.available();
@@ -148,7 +148,7 @@ int UART::available() {
148148
int UART::peek() {
149149
#if defined(SERIAL_CDC)
150150
if (is_usb) {
151-
return SerialUSB.peek();
151+
return _SerialUSB.peek();
152152
}
153153
#endif
154154
return rx_buffer.peek();
@@ -157,7 +157,7 @@ int UART::peek() {
157157
int UART::read() {
158158
#if defined(SERIAL_CDC)
159159
if (is_usb) {
160-
return SerialUSB.read();
160+
return _SerialUSB.read();
161161
}
162162
#endif
163163
return rx_buffer.read_char();
@@ -170,7 +170,7 @@ void UART::flush() {
170170
size_t UART::write(uint8_t c) {
171171
#if defined(SERIAL_CDC)
172172
if (is_usb) {
173-
return SerialUSB.write(c);
173+
return _SerialUSB.write(c);
174174
}
175175
#endif
176176
while (!_serial->obj->writeable()) {}
@@ -181,7 +181,7 @@ size_t UART::write(uint8_t c) {
181181
size_t UART::write(const uint8_t* c, size_t len) {
182182
#if defined(SERIAL_CDC)
183183
if (is_usb) {
184-
return SerialUSB.write(c, len);
184+
return _SerialUSB.write(c, len);
185185
}
186186
#endif
187187
while (!_serial->obj->writeable()) {}
@@ -197,7 +197,7 @@ void UART::block_tx(int _a) {
197197
UART::operator bool() {
198198
#if defined(SERIAL_CDC)
199199
if (is_usb) {
200-
return SerialUSB;
200+
return _SerialUSB;
201201
}
202202
#endif
203203
return _serial != NULL && _serial->obj != NULL;
@@ -206,7 +206,7 @@ UART::operator bool() {
206206
UART::operator mbed::FileHandle*() {
207207
#if defined(SERIAL_CDC)
208208
if (is_usb) {
209-
return &SerialUSB;
209+
return &_SerialUSB;
210210
}
211211
#endif
212212
}
@@ -215,37 +215,37 @@ UART::operator mbed::FileHandle*() {
215215
#if defined(SERIAL_CDC)
216216
uint32_t UART::baud() {
217217
if (is_usb) {
218-
return SerialUSB.baud();
218+
return _SerialUSB.baud();
219219
}
220220
return 0;
221221
}
222222
uint8_t UART::stopbits() {
223223
if (is_usb) {
224-
return SerialUSB.stopbits();
224+
return _SerialUSB.stopbits();
225225
}
226226
return 0;
227227
}
228228
uint8_t UART::paritytype() {
229229
if (is_usb) {
230-
return SerialUSB.paritytype();
230+
return _SerialUSB.paritytype();
231231
}
232232
return 0;
233233
}
234234
uint8_t UART::numbits() {
235235
if (is_usb) {
236-
return SerialUSB.numbits();
236+
return _SerialUSB.numbits();
237237
}
238238
return 0;
239239
}
240240
bool UART::dtr() {
241241
if (is_usb) {
242-
return SerialUSB.dtr();
242+
return _SerialUSB.dtr();
243243
}
244244
return false;
245245
}
246246
bool UART::rts() {
247247
if (is_usb) {
248-
return SerialUSB.rts();
248+
return _SerialUSB.rts();
249249
}
250250
return false;
251251
}

cores/arduino/USB/PluggableUSBSerial.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,6 @@ class USBSerial: public USBCDC, public ::mbed::Stream, public HardwareSerial {
325325
};
326326
}
327327

328-
extern arduino::USBSerial SerialUSB;
328+
extern arduino::USBSerial _SerialUSB;
329329

330330
#endif

cores/arduino/USB/USBSerial.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static void waitForPortClose() {
3030
// wait for DTR be 0 (port closed) and timeout to be over
3131
long start = millis();
3232
static const int WAIT_TIMEOUT = 200;
33-
while (SerialUSB.connected() || (millis() - start) < WAIT_TIMEOUT) {
33+
while (_SerialUSB.connected() || (millis() - start) < WAIT_TIMEOUT) {
3434
// the delay is needed to handle other "concurrent" IRQ events
3535
delay(1);
3636
}
@@ -122,6 +122,6 @@ bool USBSerial::connected()
122122
return _terminal_connected;
123123
}
124124

125-
USBSerial SerialUSB(false);
125+
USBSerial _SerialUSB(false);
126126

127127
#endif

0 commit comments

Comments
 (0)