From ae29706781b6ffb5dc2ec6809c148a8a529034c8 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Sat, 4 Apr 2020 17:52:43 +0200 Subject: [PATCH] Use core::convert::Infallible instead of void::Void for USARTs Signed-off-by: Daniel Egger --- src/serial.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/serial.rs b/src/serial.rs index c73268c..1118441 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -61,6 +61,7 @@ use core::{ fmt::{Result, Write}, ops::Deref, + convert::Infallible, }; use embedded_hal::prelude::*; @@ -451,7 +452,7 @@ impl embedded_hal::serial::Write for Tx where USART: Deref, { - type Error = void::Void; + type Error = Infallible; /// Ensures that none of the previously written words are still buffered fn flush(&mut self) -> nb::Result<(), Self::Error> { @@ -470,7 +471,7 @@ where USART: Deref, TXPIN: TxPin, { - type Error = void::Void; + type Error = Infallible; /// Ensures that none of the previously written words are still buffered fn flush(&mut self) -> nb::Result<(), Self::Error> { @@ -538,7 +539,7 @@ where } /// Ensures that none of the previously written words are still buffered -fn flush(usart: *const SerialRegisterBlock) -> nb::Result<(), void::Void> { +fn flush(usart: *const SerialRegisterBlock) -> nb::Result<(), Infallible> { // NOTE(unsafe) atomic read with no side effects let isr = unsafe { (*usart).isr.read() }; @@ -550,8 +551,8 @@ fn flush(usart: *const SerialRegisterBlock) -> nb::Result<(), void::Void> { } /// Tries to write a byte to the UART -/// Fails if the transmit buffer is full -fn write(usart: *const SerialRegisterBlock, byte: u8) -> nb::Result<(), void::Void> { +/// Returns `Err(WouldBlock)` if the transmit buffer is full +fn write(usart: *const SerialRegisterBlock, byte: u8) -> nb::Result<(), Infallible> { // NOTE(unsafe) atomic read with no side effects let isr = unsafe { (*usart).isr.read() };