pw_sys_io_arduino: Fix broken while loop in WriteByte

This was causing hangs. Removed since Serial.write will
block under the hood as is.

Change-Id: I4ce5caedbd0f9e371e1c0c916c4ee963f838a6aa
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/31973
Reviewed-by: Stan Iliev <stani@google.com>
Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
Pigweed-Auto-Submit: Anthony DiGirolamo <tonymd@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
This commit is contained in:
Anthony DiGirolamo 2021-02-05 21:57:35 -08:00 committed by CQ Bot Account
parent b6d5d7a537
commit acfc9d130b

View File

@ -44,15 +44,9 @@ Status TryReadByte(std::byte* dest) {
return OkStatus();
}
// Send a byte over USART1. Since this blocks on every byte, it's rather
// inefficient. At the default baud rate of 115200, one byte blocks the CPU for
// ~87 micro seconds. This means it takes only 10 bytes to block the CPU for
// 1ms!
// Send a byte over the default Arduino Serial port.
Status WriteByte(std::byte b) {
// Wait for TX buffer to be empty. When the buffer is empty, we can write
// a value to be dumped out of UART.
while (Serial.availableForWrite() < 1) {
}
// Serial.write() will block until data can be written.
Serial.write((uint8_t)b);
return OkStatus();
}