From 03a7529cc00b7ede1adb1e1dcbb29a555ea31c8a Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 25 Mar 2013 01:29:42 +0100 Subject: [PATCH] [sam] Added serialEvent*() support --- build/shared/revisions.txt | 1 + .../sam/variants/arduino_due_x/variant.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/build/shared/revisions.txt b/build/shared/revisions.txt index 118678623..ca15e9917 100644 --- a/build/shared/revisions.txt +++ b/build/shared/revisions.txt @@ -11,6 +11,7 @@ ARDUINO 1.5.3 BETA * sam: Fixed delayMicrosecond() when interrupts are disabled * sam: Upgraded libsam, and added missing modules (CAN, ETH, etc.) (Thibaut Viard) * sam: Added compatibility for avr/pgmspace.h (Paul Stoffregen) +* sam: Added serialEvent*() support [libraries] * sam: Added CAN library (still in early stage of development) (Palliser) diff --git a/hardware/arduino/sam/variants/arduino_due_x/variant.cpp b/hardware/arduino/sam/variants/arduino_due_x/variant.cpp index 5458f6118..ab43675ab 100644 --- a/hardware/arduino/sam/variants/arduino_due_x/variant.cpp +++ b/hardware/arduino/sam/variants/arduino_due_x/variant.cpp @@ -301,6 +301,8 @@ extern const PinDescription g_APinDescription[]= RingBuffer rx_buffer1; UARTClass Serial(UART, UART_IRQn, ID_UART, &rx_buffer1); +void serialEvent() __attribute__((weak)); +void serialEvent() { } // IT handlers void UART_Handler(void) @@ -317,8 +319,14 @@ RingBuffer rx_buffer3; RingBuffer rx_buffer4; USARTClass Serial1(USART0, USART0_IRQn, ID_USART0, &rx_buffer2); +void serialEvent1() __attribute__((weak)); +void serialEvent1() { } USARTClass Serial2(USART1, USART1_IRQn, ID_USART1, &rx_buffer3); +void serialEvent2() __attribute__((weak)); +void serialEvent2() { } USARTClass Serial3(USART3, USART3_IRQn, ID_USART3, &rx_buffer4); +void serialEvent3() __attribute__((weak)); +void serialEvent3() { } // IT handlers void USART0_Handler(void) @@ -338,6 +346,16 @@ void USART3_Handler(void) // ---------------------------------------------------------------------------- +void serialEventRun(void) +{ + if (Serial.available()) serialEvent(); + if (Serial1.available()) serialEvent1(); + if (Serial2.available()) serialEvent2(); + if (Serial3.available()) serialEvent3(); +} + +// ---------------------------------------------------------------------------- + #ifdef __cplusplus extern "C" { #endif