Skip to content

Commit 03a7529

Browse files
committed
[sam] Added serialEvent*() support
1 parent ee0c76f commit 03a7529

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

build/shared/revisions.txt

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ARDUINO 1.5.3 BETA
1111
* sam: Fixed delayMicrosecond() when interrupts are disabled
1212
* sam: Upgraded libsam, and added missing modules (CAN, ETH, etc.) (Thibaut Viard)
1313
* sam: Added compatibility for avr/pgmspace.h (Paul Stoffregen)
14+
* sam: Added serialEvent*() support
1415

1516
[libraries]
1617
* sam: Added CAN library (still in early stage of development) (Palliser)

hardware/arduino/sam/variants/arduino_due_x/variant.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ extern const PinDescription g_APinDescription[]=
301301
RingBuffer rx_buffer1;
302302

303303
UARTClass Serial(UART, UART_IRQn, ID_UART, &rx_buffer1);
304+
void serialEvent() __attribute__((weak));
305+
void serialEvent() { }
304306

305307
// IT handlers
306308
void UART_Handler(void)
@@ -317,8 +319,14 @@ RingBuffer rx_buffer3;
317319
RingBuffer rx_buffer4;
318320

319321
USARTClass Serial1(USART0, USART0_IRQn, ID_USART0, &rx_buffer2);
322+
void serialEvent1() __attribute__((weak));
323+
void serialEvent1() { }
320324
USARTClass Serial2(USART1, USART1_IRQn, ID_USART1, &rx_buffer3);
325+
void serialEvent2() __attribute__((weak));
326+
void serialEvent2() { }
321327
USARTClass Serial3(USART3, USART3_IRQn, ID_USART3, &rx_buffer4);
328+
void serialEvent3() __attribute__((weak));
329+
void serialEvent3() { }
322330

323331
// IT handlers
324332
void USART0_Handler(void)
@@ -338,6 +346,16 @@ void USART3_Handler(void)
338346

339347
// ----------------------------------------------------------------------------
340348

349+
void serialEventRun(void)
350+
{
351+
if (Serial.available()) serialEvent();
352+
if (Serial1.available()) serialEvent1();
353+
if (Serial2.available()) serialEvent2();
354+
if (Serial3.available()) serialEvent3();
355+
}
356+
357+
// ----------------------------------------------------------------------------
358+
341359
#ifdef __cplusplus
342360
extern "C" {
343361
#endif

0 commit comments

Comments
 (0)