|
32 | 32 | // using a ring buffer (I think), in which head is the index of the location
|
33 | 33 | // to which to write the next incoming character and tail is the index of the
|
34 | 34 | // location from which to read.
|
| 35 | +#if !(defined(SERIAL_TX_BUFFER_SIZE)&&defined(SERIAL_RX_BUFFER_SIZE)) |
35 | 36 | #if (RAMEND < 1000)
|
36 |
| - #define SERIAL_BUFFER_SIZE 16 |
| 37 | +#define SERIAL_TX_BUFFER_SIZE 16 |
| 38 | +#define SERIAL_RX_BUFFER_SIZE 16 |
37 | 39 | #else
|
38 |
| - #define SERIAL_BUFFER_SIZE 64 |
| 40 | +#define SERIAL_TX_BUFFER_SIZE 64 |
| 41 | +#define SERIAL_RX_BUFFER_SIZE 64 |
| 42 | +#endif |
| 43 | +#endif |
| 44 | +#if (SERIAL_TX_BUFFER_SIZE>255) || (SERIAL_RX_BUFFER_SIZE>255) |
| 45 | +#define BUFPOINTER uint16_t |
| 46 | +#else |
| 47 | +#define BUFPOINTER uint8_t |
39 | 48 | #endif
|
40 | 49 |
|
41 | 50 | // Define config for Serial.begin(baud, config);
|
@@ -76,16 +85,16 @@ class HardwareSerial : public Stream
|
76 | 85 | // Has any byte been written to the UART since begin()
|
77 | 86 | bool _written;
|
78 | 87 |
|
79 |
| - volatile uint8_t _rx_buffer_head; |
80 |
| - volatile uint8_t _rx_buffer_tail; |
81 |
| - volatile uint8_t _tx_buffer_head; |
82 |
| - volatile uint8_t _tx_buffer_tail; |
| 88 | + volatile BUFPOINTER _rx_buffer_head; |
| 89 | + volatile BUFPOINTER _rx_buffer_tail; |
| 90 | + volatile BUFPOINTER _tx_buffer_head; |
| 91 | + volatile BUFPOINTER _tx_buffer_tail; |
83 | 92 |
|
84 | 93 | // Don't put any members after these buffers, since only the first
|
85 | 94 | // 32 bytes of this struct can be accessed quickly using the ldd
|
86 | 95 | // instruction.
|
87 |
| - unsigned char _rx_buffer[SERIAL_BUFFER_SIZE]; |
88 |
| - unsigned char _tx_buffer[SERIAL_BUFFER_SIZE]; |
| 96 | + unsigned char _rx_buffer[SERIAL_RX_BUFFER_SIZE]; |
| 97 | + unsigned char _tx_buffer[SERIAL_TX_BUFFER_SIZE]; |
89 | 98 |
|
90 | 99 | public:
|
91 | 100 | inline HardwareSerial(
|
|
0 commit comments