Skip to content

Commit 012d86c

Browse files
ladyadadeanm1278
authored andcommitted
make it so native USB is Serial
1 parent cf623ef commit 012d86c

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

cores/arduino/USB/CDC.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ Serial_::operator bool()
243243
return result;
244244
}
245245

246+
<<<<<<< HEAD
246247
int32_t Serial_::readBreak() {
247248
uint8_t enableInterrupts = ((__get_PRIMASK() & 0x1) == 0);
248249

@@ -288,5 +289,8 @@ bool Serial_::rts() {
288289
}
289290

290291
Serial_ SerialUSB(USBDevice);
292+
=======
293+
Serial_ Serial(USBDevice);
294+
>>>>>>> make it so native USB is Serial
291295

292296
#endif

cores/arduino/USB/USBAPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class Serial_ : public Stream
177177
RingBuffer *_cdc_rx_buffer;
178178
bool stalled;
179179
};
180-
extern Serial_ SerialUSB;
180+
extern Serial_ Serial;
181181

182182
//================================================================================
183183
//================================================================================

cores/arduino/USB/USBCore.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,15 @@ void USBDeviceClass::standby() {
280280
void USBDeviceClass::handleEndpoint(uint8_t ep)
281281
{
282282
#if defined(CDC_ENABLED)
283+
if (ep == CDC_ENDPOINT_OUT)
284+
{
285+
// The RAM Buffer is empty: we can receive data
286+
//usbd.epBank0ResetReady(CDC_ENDPOINT_OUT);
287+
288+
// Handle received bytes
289+
if (available(CDC_ENDPOINT_OUT))
290+
Serial.accept();
291+
}
283292
if (ep == CDC_ENDPOINT_IN)
284293
{
285294
// NAK on endpoint IN, the bank is not yet filled in.

variants/arduino_zero/variant.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,14 @@ SERCOM sercom4( SERCOM4 ) ;
208208
SERCOM sercom5( SERCOM5 ) ;
209209

210210
Uart Serial1( &sercom0, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX ) ;
211-
Uart Serial( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX, PAD_SERIAL_RX, PAD_SERIAL_TX ) ;
211+
Uart Serial5( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX, PAD_SERIAL_RX, PAD_SERIAL_TX ) ;
212212
void SERCOM0_Handler()
213213
{
214214
Serial1.IrqHandler();
215215
}
216216

217217
void SERCOM5_Handler()
218218
{
219-
Serial.IrqHandler();
219+
Serial5.IrqHandler();
220220
}
221221

variants/arduino_zero/variant.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ extern SERCOM sercom3;
197197
extern SERCOM sercom4;
198198
extern SERCOM sercom5;
199199

200-
extern Uart Serial;
200+
extern Uart Serial5;
201201
extern Uart Serial1;
202202

203203
#endif
@@ -217,7 +217,7 @@ extern Uart Serial1;
217217
//
218218
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
219219
// pins are NOT connected to anything by default.
220-
#define SERIAL_PORT_USBVIRTUAL SerialUSB
220+
#define SERIAL_PORT_USBVIRTUAL Serial
221221
#define SERIAL_PORT_MONITOR Serial
222222
// Serial has no physical pins broken out, so it's not listed as HARDWARE port
223223
#define SERIAL_PORT_HARDWARE Serial1

0 commit comments

Comments
 (0)