mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-01-11 13:01:30 +11:00
Update uart implementation of embedded-hal 1.x to 1.0.0-alpha.6
This commit is contained in:
parent
1294f556e9
commit
9a018ac359
|
@ -82,6 +82,18 @@ pub enum ReadErrorType {
|
||||||
Framing,
|
Framing,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "eh1_0_alpha")]
|
||||||
|
impl eh1_0_alpha::serial::Error for ReadErrorType {
|
||||||
|
fn kind(&self) -> eh1_0_alpha::serial::ErrorKind {
|
||||||
|
match self {
|
||||||
|
ReadErrorType::Overrun => eh1_0_alpha::serial::ErrorKind::Overrun,
|
||||||
|
ReadErrorType::Break => eh1_0_alpha::serial::ErrorKind::Other,
|
||||||
|
ReadErrorType::Parity => eh1_0_alpha::serial::ErrorKind::Parity,
|
||||||
|
ReadErrorType::Framing => eh1_0_alpha::serial::ErrorKind::FrameFormat,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// State of the UART Peripheral.
|
/// State of the UART Peripheral.
|
||||||
pub trait State {}
|
pub trait State {}
|
||||||
|
|
||||||
|
@ -516,6 +528,27 @@ impl<D: UartDevice> eh1::Read<u8> for UartPeripheral<Enabled, D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Same as core::convert::Infallible, but implementing spi::Error
|
||||||
|
///
|
||||||
|
/// For eh 1.0.0-alpha.6, Infallible doesn't implement spi::Error,
|
||||||
|
/// so use a locally defined type instead.
|
||||||
|
#[cfg(feature = "eh1_0_alpha")]
|
||||||
|
pub enum SerialInfallible {}
|
||||||
|
|
||||||
|
#[cfg(feature = "eh1_0_alpha")]
|
||||||
|
impl core::fmt::Debug for SerialInfallible {
|
||||||
|
fn fmt(&self, _f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
|
match *self {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "eh1_0_alpha")]
|
||||||
|
impl eh1_0_alpha::serial::Error for SerialInfallible {
|
||||||
|
fn kind(&self) -> eh1_0_alpha::serial::ErrorKind {
|
||||||
|
match *self {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<D: UartDevice> Write<u8> for UartPeripheral<Enabled, D> {
|
impl<D: UartDevice> Write<u8> for UartPeripheral<Enabled, D> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
|
@ -534,7 +567,7 @@ impl<D: UartDevice> Write<u8> for UartPeripheral<Enabled, D> {
|
||||||
|
|
||||||
#[cfg(feature = "eh1_0_alpha")]
|
#[cfg(feature = "eh1_0_alpha")]
|
||||||
impl<D: UartDevice> eh1::Write<u8> for UartPeripheral<Enabled, D> {
|
impl<D: UartDevice> eh1::Write<u8> for UartPeripheral<Enabled, D> {
|
||||||
type Error = Infallible;
|
type Error = SerialInfallible;
|
||||||
|
|
||||||
fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> {
|
fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> {
|
||||||
if self.write_raw(&[word]).is_err() {
|
if self.write_raw(&[word]).is_err() {
|
||||||
|
@ -545,7 +578,10 @@ impl<D: UartDevice> eh1::Write<u8> for UartPeripheral<Enabled, D> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&mut self) -> nb::Result<(), Self::Error> {
|
fn flush(&mut self) -> nb::Result<(), Self::Error> {
|
||||||
self.transmit_flushed()
|
self.transmit_flushed().map_err(|e| match e {
|
||||||
|
WouldBlock => WouldBlock,
|
||||||
|
Other(v) => match v {},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue