aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZach Eveland <zeveland@blacklabel-development.com>2011-09-08 20:26:47 -0400
committerZach Eveland <zeveland@blacklabel-development.com>2011-09-08 20:26:47 -0400
commitc0ad36ad4341b90a0bd3acde1e50ce85dfd2f4a8 (patch)
treece305833da2f7cac516d33bcb6bd7cebeb2d0adb
parente52cf0e4203bd6dda76c2544b0479548f465a0c7 (diff)
parent8b13206e655cd9c1123d842cab1fdd0afd6edc8b (diff)
Merge branch 'new-extension' of https://github.com/arduino/Arduino into new-extension
Conflicts: build/linux/dist/tools/avrdude.conf
-rw-r--r--cores/arduino/Client.h1
-rw-r--r--cores/arduino/HardwareSerial.cpp37
-rw-r--r--cores/arduino/HardwareSerial.h2
-rwxr-xr-xcores/arduino/Print.cpp10
-rwxr-xr-xcores/arduino/Print.h2
-rw-r--r--cores/arduino/Server.h2
-rw-r--r--cores/arduino/Udp.h2
-rwxr-xr-xcores/arduino/main.cpp2
8 files changed, 8 insertions, 50 deletions
diff --git a/cores/arduino/Client.h b/cores/arduino/Client.h
index ed9e9b4..ea13483 100644
--- a/cores/arduino/Client.h
+++ b/cores/arduino/Client.h
@@ -10,7 +10,6 @@ public:
virtual int connect(IPAddress ip, uint16_t port) =0;
virtual int connect(const char *host, uint16_t port) =0;
virtual size_t write(uint8_t) =0;
- virtual size_t write(const char *str) =0;
virtual size_t write(const uint8_t *buf, size_t size) =0;
virtual int available() = 0;
virtual int read() = 0;
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp
index 613f252..b5992ad 100644
--- a/cores/arduino/HardwareSerial.cpp
+++ b/cores/arduino/HardwareSerial.cpp
@@ -95,7 +95,6 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
#else
void serialEvent() __attribute__((weak));
void serialEvent() {}
- volatile static unsigned char serialEvent_flag = 0;
#define serialEvent_implemented
#if defined(USART_RX_vect)
SIGNAL(USART_RX_vect)
@@ -117,7 +116,6 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
#error UDR not defined
#endif
store_char(c, &rx_buffer);
- serialEvent_flag = 1;
}
#endif
#endif
@@ -125,13 +123,11 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
#if defined(USART1_RX_vect)
void serialEvent1() __attribute__((weak));
void serialEvent1() {}
- volatile static unsigned char serialEvent1_flag = 0;
#define serialEvent1_implemented
SIGNAL(USART1_RX_vect)
{
unsigned char c = UDR1;
store_char(c, &rx_buffer1);
- serialEvent1_flag = 1;
}
#elif defined(SIG_USART1_RECV)
#error SIG_USART1_RECV
@@ -140,13 +136,11 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
#if defined(USART2_RX_vect) && defined(UDR2)
void serialEvent2() __attribute__((weak));
void serialEvent2() {}
- volatile static unsigned char serialEvent2_flag = 0;
#define serialEvent2_implemented
SIGNAL(USART2_RX_vect)
{
unsigned char c = UDR2;
store_char(c, &rx_buffer2);
- serialEvent2_flag = 1;
}
#elif defined(SIG_USART2_RECV)
#error SIG_USART2_RECV
@@ -155,13 +149,11 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
#if defined(USART3_RX_vect) && defined(UDR3)
void serialEvent3() __attribute__((weak));
void serialEvent3() {}
- volatile static unsigned char serialEvent3_flag = 0;
#define serialEvent3_implemented
SIGNAL(USART3_RX_vect)
{
unsigned char c = UDR3;
store_char(c, &rx_buffer3);
- serialEvent3_flag = 1;
}
#elif defined(SIG_USART3_RECV)
#error SIG_USART3_RECV
@@ -169,38 +161,17 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
void serialEventRun(void)
{
- unsigned char flag, oldSREG;
#ifdef serialEvent_implemented
- oldSREG = SREG;
- noInterrupts();
- flag = serialEvent_flag;
- serialEvent_flag = 0;
- SREG = oldSREG;
- if (flag) serialEvent();
+ if (Serial.available()) serialEvent();
#endif
#ifdef serialEvent1_implemented
- oldSREG = SREG;
- noInterrupts();
- flag = serialEvent1_flag;
- serialEvent1_flag = 0;
- SREG = oldSREG;
- if (flag) serialEvent1();
+ if (Serial1.available()) serialEvent1();
#endif
#ifdef serialEvent2_implemented
- oldSREG = SREG;
- noInterrupts();
- flag = serialEvent2_flag;
- serialEvent2_flag = 0;
- SREG = oldSREG;
- if (flag) serialEvent2();
+ if (Serial2.available()) serialEvent2();
#endif
#ifdef serialEvent3_implemented
- oldSREG = SREG;
- noInterrupts();
- flag = serialEvent3_flag;
- serialEvent3_flag = 0;
- SREG = oldSREG;
- if (flag) serialEvent3();
+ if (Serial3.available()) serialEvent3();
#endif
}
diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h
index d0dca06..176abe1 100644
--- a/cores/arduino/HardwareSerial.h
+++ b/cores/arduino/HardwareSerial.h
@@ -75,6 +75,6 @@ class HardwareSerial : public Stream
extern HardwareSerial Serial3;
#endif
-extern void serialEventRun(void);
+extern void serialEventRun(void) __attribute__((weak));
#endif
diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp
index 8190d4f..500de8c 100755
--- a/cores/arduino/Print.cpp
+++ b/cores/arduino/Print.cpp
@@ -30,16 +30,6 @@
// Public Methods //////////////////////////////////////////////////////////////
/* default implementation: may be overridden */
-size_t Print::write(const char *str)
-{
- size_t n = 0;
- while (*str) {
- n += write(*str++);
- }
- return n;
-}
-
-/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
diff --git a/cores/arduino/Print.h b/cores/arduino/Print.h
index 8530b03..1af6b72 100755
--- a/cores/arduino/Print.h
+++ b/cores/arduino/Print.h
@@ -46,7 +46,7 @@ class Print
void clearWriteError() { setWriteError(0); }
virtual size_t write(uint8_t) = 0;
- virtual size_t write(const char *str);
+ size_t write(const char *str) { return write((const uint8_t *)str, strlen(str)); }
virtual size_t write(const uint8_t *buffer, size_t size);
size_t print(const __FlashStringHelper *);
diff --git a/cores/arduino/Server.h b/cores/arduino/Server.h
index edab726..9674c76 100644
--- a/cores/arduino/Server.h
+++ b/cores/arduino/Server.h
@@ -1,7 +1,7 @@
#ifndef server_h
#define server_h
-class Server {
+class Server : public Print {
public:
virtual void begin() =0;
};
diff --git a/cores/arduino/Udp.h b/cores/arduino/Udp.h
index 1fb9cd3..dc5644b 100644
--- a/cores/arduino/Udp.h
+++ b/cores/arduino/Udp.h
@@ -57,8 +57,6 @@ public:
virtual int endPacket() =0;
// Write a single byte into the packet
virtual size_t write(uint8_t) =0;
- // Write a string of characters into the packet
- virtual size_t write(const char *str) =0;
// Write size bytes from buffer into the packet
virtual size_t write(const uint8_t *buffer, size_t size) =0;
diff --git a/cores/arduino/main.cpp b/cores/arduino/main.cpp
index 097f5ed..0ef5256 100755
--- a/cores/arduino/main.cpp
+++ b/cores/arduino/main.cpp
@@ -13,7 +13,7 @@ int main(void)
for (;;) {
loop();
- serialEventRun();
+ if (serialEventRun) serialEventRun();
}
return 0;