mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-06 01:08:25 +01:00
Use uint8_t for HardwareSerial ringbuffer pointers
Since the buffers aren't bigger than 64 bytes, these values can be smaller. This saves a few bytes of ram, but also saves around 50 bytes of program space, since the values can now be loaded using a single instruction. To prevent problems when people manually increase the buffer size, a compile-time check is added. Closes: #1078
This commit is contained in:
parent
d6a5e41b5c
commit
e0a9a7676b
@ -62,10 +62,14 @@
|
|||||||
struct ring_buffer
|
struct ring_buffer
|
||||||
{
|
{
|
||||||
unsigned char buffer[SERIAL_BUFFER_SIZE];
|
unsigned char buffer[SERIAL_BUFFER_SIZE];
|
||||||
volatile unsigned int head;
|
volatile uint8_t head;
|
||||||
volatile unsigned int tail;
|
volatile uint8_t tail;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if SERIAL_BUFFER_SIZE > 256
|
||||||
|
#error Serial buffer size too big for head and tail pointers
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(USBCON)
|
#if defined(USBCON)
|
||||||
ring_buffer rx_buffer = { { 0 }, 0, 0};
|
ring_buffer rx_buffer = { { 0 }, 0, 0};
|
||||||
ring_buffer tx_buffer = { { 0 }, 0, 0};
|
ring_buffer tx_buffer = { { 0 }, 0, 0};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user