Make rx tail/head atomic

This commit is contained in:
AnHardt committed 2016-02-24 15:51:34 +01:00
1 parent 9f8e6dce20
commit dc0f41868e
2 files changed
+8 -7

No files matched your search

+2 -2
View File
@@ -33,7 +33,7 @@
#endif
FORCE_INLINE void store_char(unsigned char c) {
int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
uint8_t i = (uint8_t)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
@@ -116,7 +116,7 @@ int MarlinSerial::read(void) {
}
else {
unsigned char c = rx_buffer.buffer[rx_buffer.tail];
rx_buffer.tail = (unsigned int)(rx_buffer.tail + 1) % RX_BUFFER_SIZE;
rx_buffer.tail = (uint8_t)(rx_buffer.tail + 1) % RX_BUFFER_SIZE;
return c;
}
}