[gnoduino: 41/237] Adding serialEvent(), serialEvent1(), etc.



commit e9c4d0e21afad09dcf5c35663c02ed166f85e8a7
Author: David A. Mellis <d mellis arduino cc>
Date:   Sat May 7 13:04:13 2011 -0400

    Adding serialEvent(), serialEvent1(), etc.
    
    Called from within the serial receive interrupt.  These are implemented as an empty weak function in the core that be overridden by the user's sketch.
    
    http://code.google.com/p/arduino/issues/detail?id=263

 arduino/cores/arduino/HardwareSerial.cpp |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/arduino/cores/arduino/HardwareSerial.cpp b/arduino/cores/arduino/HardwareSerial.cpp
index 91c79d3..9f5ed50 100644
--- a/arduino/cores/arduino/HardwareSerial.cpp
+++ b/arduino/cores/arduino/HardwareSerial.cpp
@@ -86,6 +86,8 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
 	!defined(SIG_UART_RECV)
   #error Don't know what the Data Received vector is called for the first UART
 #else
+  void serialEvent() __attribute__((weak));
+  void serialEvent() {}
 #if defined(USART_RX_vect)
   SIGNAL(USART_RX_vect)
 #elif defined(SIG_USART0_RECV)
@@ -106,36 +108,44 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
     #error UDR not defined
   #endif
     store_char(c, &rx_buffer);
+	serialEvent();
   }
 #endif
 
-//#if defined(SIG_USART1_RECV)
 #if defined(USART1_RX_vect)
-  //SIGNAL(SIG_USART1_RECV)
+  void serialEvent1() __attribute__((weak));
+  void serialEvent1() {}
   SIGNAL(USART1_RX_vect)
   {
     unsigned char c = UDR1;
     store_char(c, &rx_buffer1);
+	serialEvent1();
   }
 #elif defined(SIG_USART1_RECV)
   #error SIG_USART1_RECV
 #endif
 
 #if defined(USART2_RX_vect) && defined(UDR2)
+  void serialEvent2() __attribute__((weak));
+  void serialEvent2() {}
   SIGNAL(USART2_RX_vect)
   {
     unsigned char c = UDR2;
     store_char(c, &rx_buffer2);
+	serialEvent2();
   }
 #elif defined(SIG_USART2_RECV)
   #error SIG_USART2_RECV
 #endif
 
 #if defined(USART3_RX_vect) && defined(UDR3)
+  void serialEvent3() __attribute__((weak));
+  void serialEvent3() {}
   SIGNAL(USART3_RX_vect)
   {
     unsigned char c = UDR3;
     store_char(c, &rx_buffer3);
+	serialEvent3();
   }
 #elif defined(SIG_USART3_RECV)
   #error SIG_USART3_RECV



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]