|
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 | +#if !(defined(SERIAL_TX_BUFFER_SIZE) && defined(SERIAL_RX_BUFFER_SIZE)) |
36 | 36 | #if (RAMEND < 1000)
|
37 | 37 | #define SERIAL_TX_BUFFER_SIZE 16
|
38 | 38 | #define SERIAL_RX_BUFFER_SIZE 16
|
|
41 | 41 | #define SERIAL_RX_BUFFER_SIZE 64
|
42 | 42 | #endif
|
43 | 43 | #endif
|
44 |
| -#if (SERIAL_TX_BUFFER_SIZE>255) || (SERIAL_RX_BUFFER_SIZE>255) |
45 |
| -#define BUFPOINTER uint16_t |
| 44 | +#if (SERIAL_TX_BUFFER_SIZE>256) |
| 45 | +typedef uint16_t tx_buffer_index_t; |
46 | 46 | #else
|
47 |
| -#define BUFPOINTER uint8_t |
| 47 | +typedef uint8_t tx_buffer_index_t; |
| 48 | +#endif |
| 49 | +#if (SERIAL_RX_BUFFER_SIZE>256) |
| 50 | +typedef uint16_t rx_buffer_index_t; |
| 51 | +#else |
| 52 | +typedef uint8_t rx_buffer_index_t; |
48 | 53 | #endif
|
49 | 54 |
|
50 | 55 | // Define config for Serial.begin(baud, config);
|
@@ -85,10 +90,10 @@ class HardwareSerial : public Stream
|
85 | 90 | // Has any byte been written to the UART since begin()
|
86 | 91 | bool _written;
|
87 | 92 |
|
88 |
| - volatile BUFPOINTER _rx_buffer_head; |
89 |
| - volatile BUFPOINTER _rx_buffer_tail; |
90 |
| - volatile BUFPOINTER _tx_buffer_head; |
91 |
| - volatile BUFPOINTER _tx_buffer_tail; |
| 93 | + volatile rx_buffer_index_t _rx_buffer_head; |
| 94 | + volatile rx_buffer_index_t _rx_buffer_tail; |
| 95 | + volatile tx_buffer_index_t _tx_buffer_head; |
| 96 | + volatile tx_buffer_index_t _tx_buffer_tail; |
92 | 97 |
|
93 | 98 | // Don't put any members after these buffers, since only the first
|
94 | 99 | // 32 bytes of this struct can be accessed quickly using the ldd
|
|
0 commit comments