Merge pull request #1863 from matthijskooijman/ide-1.5.x-serial-int

In HardwareSerial, don't use int for buffer indices
This commit is contained in:
Cristian Maglie 2014-02-14 15:42:26 +01:00
commit f4cd0ff0a4
1 changed files with 2 additions and 2 deletions

View File

@ -171,7 +171,7 @@ int HardwareSerial::read(void)
return -1;
} else {
unsigned char c = _rx_buffer[_rx_buffer_tail];
_rx_buffer_tail = (unsigned int)(_rx_buffer_tail + 1) % SERIAL_BUFFER_SIZE;
_rx_buffer_tail = (uint8_t)(_rx_buffer_tail + 1) % SERIAL_BUFFER_SIZE;
return c;
}
}
@ -207,7 +207,7 @@ size_t HardwareSerial::write(uint8_t c)
sbi(*_ucsra, TXC0);
return 1;
}
int i = (_tx_buffer_head + 1) % SERIAL_BUFFER_SIZE;
uint8_t i = (_tx_buffer_head + 1) % SERIAL_BUFFER_SIZE;
// If the output buffer is full, there's nothing for it other than to
// wait for the interrupt handler to empty it a bit