mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2024-12-23 12:41:31 +11:00
Remove unnecessary custom Infallible types
This commit is contained in:
parent
e4deaabb51
commit
fcd6f7c19d
|
@ -192,29 +192,6 @@ impl<D: SpiDevice, const DS: u8> Spi<Enabled, D, DS> {
|
|||
}
|
||||
}
|
||||
|
||||
/// 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.
|
||||
/// This should be removed with the next release of e-h.
|
||||
/// (https://github.com/rust-embedded/embedded-hal/pull/328)
|
||||
#[cfg(feature = "eh1_0_alpha")]
|
||||
pub enum SpiInfallible {}
|
||||
|
||||
#[cfg(feature = "eh1_0_alpha")]
|
||||
impl core::fmt::Debug for SpiInfallible {
|
||||
fn fmt(&self, _f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
match *self {}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "eh1_0_alpha")]
|
||||
impl eh1::Error for SpiInfallible {
|
||||
fn kind(&self) -> eh1::ErrorKind {
|
||||
match *self {}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_write {
|
||||
($type:ident, [$($nr:expr),+]) => {
|
||||
|
||||
|
@ -250,20 +227,20 @@ macro_rules! impl_write {
|
|||
|
||||
#[cfg(feature = "eh1_0_alpha")]
|
||||
impl<D: SpiDevice> eh1::ErrorType for Spi<Enabled, D, $nr> {
|
||||
type Error = SpiInfallible;
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
/* disabled for now - nb was migrated to separate crate
|
||||
#[cfg(feature = "eh1_0_alpha")]
|
||||
impl<D: SpiDevice> eh1::nb::FullDuplex<$type> for Spi<Enabled, D, $nr> {
|
||||
fn read(&mut self) -> Result<$type, nb::Error<SpiInfallible>> {
|
||||
fn read(&mut self) -> Result<$type, nb::Error<Infallible>> {
|
||||
if !self.is_readable() {
|
||||
return Err(nb::Error::WouldBlock);
|
||||
}
|
||||
|
||||
Ok(self.device.sspdr.read().data().bits() as $type)
|
||||
}
|
||||
fn write(&mut self, word: $type) -> Result<(), nb::Error<SpiInfallible>> {
|
||||
fn write(&mut self, word: $type) -> Result<(), nb::Error<Infallible>> {
|
||||
// Write to TX FIFO whilst ignoring RX, then clean up afterward. When RX
|
||||
// is full, PL022 inhibits RX pushes, and sets a sticky flag on
|
||||
// push-on-full, but continues shifting. Safe if SSPIMSC_RORIM is not set.
|
||||
|
|
|
@ -116,26 +116,3 @@ impl Default for UartConfig {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Same as core::convert::Infallible, but implementing serial::Error
|
||||
///
|
||||
/// For eh 1.0.0-alpha.6, Infallible doesn't implement serial::Error,
|
||||
/// so use a locally defined type instead.
|
||||
/// This should be removed with the next release of e-h.
|
||||
/// (https://github.com/rust-embedded/embedded-hal/pull/328)
|
||||
#[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 {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ impl<D: UartDevice, P: ValidUartPinout<D>> Write<u8> for Writer<D, P> {
|
|||
|
||||
#[cfg(feature = "eh1_0_alpha")]
|
||||
impl<D: UartDevice, P: ValidUartPinout<D>> eh1::ErrorType for Writer<D, P> {
|
||||
type Error = super::utils::SerialInfallible;
|
||||
type Error = core::convert::Infallible;
|
||||
}
|
||||
|
||||
/* disabled for now - nb was migrated to separate crate
|
||||
|
|
Loading…
Reference in a new issue