Skip to content

Commit e928558

Browse files
committed
SerialUSB: shadow mbed object
1 parent 2a8604a commit e928558

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

cores/arduino/Arduino.h

Lines changed: 1 addition & 0 deletions
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

Lines changed: 13 additions & 13 deletions
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,37 +206,37 @@ UART::operator bool() {
206206
#if defined(SERIAL_CDC)
207207
uint32_t UART::baud() {
208208
if (is_usb) {
209-
return SerialUSB.baud();
209+
return _SerialUSB.baud();
210210
}
211211
return 0;
212212
}
213213
uint8_t UART::stopbits() {
214214
if (is_usb) {
215-
return SerialUSB.stopbits();
215+
return _SerialUSB.stopbits();
216216
}
217217
return 0;
218218
}
219219
uint8_t UART::paritytype() {
220220
if (is_usb) {
221-
return SerialUSB.paritytype();
221+
return _SerialUSB.paritytype();
222222
}
223223
return 0;
224224
}
225225
uint8_t UART::numbits() {
226226
if (is_usb) {
227-
return SerialUSB.numbits();
227+
return _SerialUSB.numbits();
228228
}
229229
return 0;
230230
}
231231
bool UART::dtr() {
232232
if (is_usb) {
233-
return SerialUSB.dtr();
233+
return _SerialUSB.dtr();
234234
}
235235
return false;
236236
}
237237
bool UART::rts() {
238238
if (is_usb) {
239-
return SerialUSB.rts();
239+
return _SerialUSB.rts();
240240
}
241241
return false;
242242
}

cores/arduino/USB/PluggableUSBSerial.h

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy