diff --git a/api/HardwareSerial.h b/api/HardwareSerial.h index e8f0657a..4473fe13 100644 --- a/api/HardwareSerial.h +++ b/api/HardwareSerial.h @@ -41,6 +41,7 @@ namespace arduino { #define SERIAL_DATA_6 (0x200ul) #define SERIAL_DATA_7 (0x300ul) #define SERIAL_DATA_8 (0x400ul) +#define SERIAL_DATA_9 (0x500ul) #define SERIAL_DATA_MASK (0xF00ul) #define SERIAL_5N1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_NONE | SERIAL_DATA_5) @@ -83,7 +84,12 @@ namespace arduino { #define SERIAL_6S2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_SPACE | SERIAL_DATA_6) #define SERIAL_7S2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_SPACE | SERIAL_DATA_7) #define SERIAL_8S2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_SPACE | SERIAL_DATA_8) - +#define SERIAL_9N1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_NONE | SERIAL_DATA_9) +#define SERIAL_9N2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_NONE | SERIAL_DATA_9) +#define SERIAL_9E1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_EVEN | SERIAL_DATA_9) +#define SERIAL_9E2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_EVEN | SERIAL_DATA_9) +#define SERIAL_9O1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_ODD | SERIAL_DATA_9) +#define SERIAL_9O2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_ODD | SERIAL_DATA_9) class HardwareSerial : public Stream { public: @@ -97,6 +103,9 @@ class HardwareSerial : public Stream virtual size_t write(uint8_t) = 0; using Print::write; // pull in write(str) and write(buf, size) from Print virtual operator bool() = 0; + virtual size_t write9bit(uint8_t) = 0; + virtual void set_tx_mode(void) = 0; + virtual void set_rx_mode(void) = 0; }; // XXX: Are we keeping the serialEvent API? diff --git a/api/RingBuffer.h b/api/RingBuffer.h index 8665cf6a..a5522dad 100644 --- a/api/RingBuffer.h +++ b/api/RingBuffer.h @@ -30,20 +30,20 @@ namespace arduino { // using a ring buffer (I think), in which head is the index of the location // to which to write the next incoming character and tail is the index of the // location from which to read. -#define SERIAL_BUFFER_SIZE 64 +#define SERIAL_BUFFER_SIZE 256 template class RingBufferN { public: - uint8_t _aucBuffer[N] ; + uint16_t _aucBuffer[N] ; volatile int _iHead ; volatile int _iTail ; volatile int _numElems; public: RingBufferN( void ) ; - void store_char( uint8_t c ) ; + void store_char( uint16_t c ) ; void clear(); int read_char(); int available(); @@ -62,12 +62,12 @@ typedef RingBufferN RingBuffer; template RingBufferN::RingBufferN( void ) { - memset( _aucBuffer, 0, N ) ; + memset( _aucBuffer, 0, (N * 2) ) ; clear(); } template -void RingBufferN::store_char( uint8_t c ) +void RingBufferN::store_char( uint16_t c ) { // if we should be storing the received character into the location // just before the tail (meaning that the head would advance to the @@ -77,7 +77,7 @@ void RingBufferN::store_char( uint8_t c ) { _aucBuffer[_iHead] = c ; _iHead = nextIndex(_iHead); - _numElems = _numElems + 1; + _numElems++; } } @@ -95,9 +95,9 @@ int RingBufferN::read_char() if (isEmpty()) return -1; - uint8_t value = _aucBuffer[_iTail]; + uint16_t value = _aucBuffer[_iTail]; _iTail = nextIndex(_iTail); - _numElems = _numElems - 1; + _numElems--; return value; } @@ -138,4 +138,4 @@ bool RingBufferN::isFull() } #endif /* _RING_BUFFER_ */ -#endif /* __cplusplus */ +#endif /* __cplusplus */ \ No newline at end of file