@@ -70,17 +70,14 @@ void SerialPort::end() {
7070}
7171
7272void SerialPort::flush () const {
73- while (bit_is_clear (UCSR0A, TXC0)) {}
73+ while (bit_is_clear (UCSR0A, TXC0)) {
74+ }
7475 // if we get here the hardware finished tranmission (TXC is set)
7576}
7677
7778int16_t SerialPort::read () {
7879 ExecuteAtomic<std::is_same<uint8_t , rx_buf_idx_t >::value> x;
79- const rx_buf_idx_t head {
80- x ([this ]() {
81- return rx_buf_head_;
82- })
83- };
80+ const rx_buf_idx_t head { x ([this ]() { return rx_buf_head_; }) };
8481
8582 if (head == rx_buf_tail_) {
8683 // if the head isn't ahead of the tail, we don't have any characters
@@ -90,17 +87,15 @@ int16_t SerialPort::read() {
9087 const rx_buf_idx_t new_tail { static_cast <rx_buf_idx_t >(static_cast <rx_buf_idx_t >(rx_buf_tail_ + 1U ) % sizeof (rx_buffer_)) };
9188
9289 ExecuteAtomic<std::is_same<uint8_t , rx_buf_idx_t >::value> x;
93- x ([this , new_tail]() {
94- rx_buf_tail_ = new_tail;
95- });
90+ x ([this , new_tail]() { rx_buf_tail_ = new_tail; });
9691
9792 return static_cast <int16_t >(c);
9893 }
9994}
10095
10196int16_t SerialPort::read (void * buffer, const size_t length) {
10297 uint8_t * ptr { reinterpret_cast <uint8_t *>(buffer) };
103- size_t n { 0 };
98+ size_t n {};
10499 while (n < length) {
105100 const int16_t c { read () };
106101 if (c < 0 ) {
@@ -114,7 +109,8 @@ int16_t SerialPort::read(void* buffer, const size_t length) {
114109
115110int16_t SerialPort::write (uint8_t data) const {
116111 /* wait for empty transmit buffer */
117- while (! (UCSR0A & (1 << UDRE0))) {}
112+ while (!(UCSR0A & (1 << UDRE0))) {
113+ }
118114
119115 /* put data into buffer, sends the data */
120116 UDR0 = data;
@@ -127,11 +123,11 @@ int16_t SerialPort::write(uint8_t data) const {
127123
128124int16_t SerialPort::write (const void * buffer, const size_t length) const {
129125 const uint8_t * ptr { reinterpret_cast <const uint8_t *>(buffer) };
130- for (size_t i ( 0U ) ; i < length; ++i) {
126+ for (size_t i {} ; i < length; ++i) {
131127 write (*ptr++);
132128 }
133129 return length;
134- }
130+ } // namespace avr
135131
136132inline __attribute__ ((always_inline)) void SerialPort::isr() {
137133 if (bit_is_clear (UCSR0A, UPE0)) {
0 commit comments