diff options
author | Matthijs Kooijman <matthijs@stdin.nl> | 2013-12-01 17:21:54 +0100 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2014-01-22 09:38:34 +0100 |
commit | 99f7ef7c673e02d559eb55d064f38a105393c8f6 (patch) | |
tree | 1fff463c237324630e68b6cd4961b7786d905446 /cores/arduino/HardwareSerial.h | |
parent | f1cd85da7ad0030d1fb1102aa9e3119851e1c4aa (diff) |
Centrally decide which hardware UARTS are available
Before, this decision was made in few different places, based on
sometimes different register defines.
Now, HardwareSerial.h decides wich UARTS are available, defines
USE_HWSERIALn macros and HardwareSerial.cpp simply checks these macros
(together with some #ifs to decide which registers to use for UART 0).
For consistency, USBAPI.h also defines a HAVE_CDCSERIAL macro when
applicable.
For supported targets, this should change any behaviour. For unsupported
targets, the error messages might subtly change because some checks are
moved or changed.
Additionally, this moves the USBAPI.h include form HardareSerial.h into
Arduino.h and raises an error when both CDC serial and UART0 are
available (previously this would silently use UART0 instead of CDC, but
there is not currently any Atmel chip available for which this would
occur).
Diffstat (limited to 'cores/arduino/HardwareSerial.h')
-rw-r--r-- | cores/arduino/HardwareSerial.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index 0ae51f4..da9efbc 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -113,18 +113,19 @@ class HardwareSerial : public Stream #if defined(UBRRH) || defined(UBRR0H) extern HardwareSerial Serial; -#elif defined(USBCON) - #include "USBAPI.h" -// extern HardwareSerial Serial_; + #define HAVE_HWSERIAL0 #endif #if defined(UBRR1H) extern HardwareSerial Serial1; + #define HAVE_HWSERIAL1 #endif #if defined(UBRR2H) extern HardwareSerial Serial2; + #define HAVE_HWSERIAL2 #endif #if defined(UBRR3H) extern HardwareSerial Serial3; + #define HAVE_HWSERIAL3 #endif extern void serialEventRun(void) __attribute__((weak)); |