mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-09-27 12:20:37 +00:00
Implement core::error::Error
for STM32 Serial Devices
This commit is contained in:
parent
00ef474b94
commit
27709df94a
@ -44,6 +44,24 @@ pub enum Error {
|
||||
ZeroLengthTransfer,
|
||||
}
|
||||
|
||||
impl core::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
let message = match self {
|
||||
Self::Bus => "Bus Error",
|
||||
Self::Arbitration => "Arbitration Lost",
|
||||
Self::Nack => "ACK Not Received",
|
||||
Self::Timeout => "Request Timed Out",
|
||||
Self::Crc => "CRC Mismatch",
|
||||
Self::Overrun => "Buffer Overrun",
|
||||
Self::ZeroLengthTransfer => "Zero-Length Transfers are not allowed",
|
||||
};
|
||||
|
||||
write!(f, "{}", message)
|
||||
}
|
||||
}
|
||||
|
||||
impl core::error::Error for Error {}
|
||||
|
||||
/// I2C config
|
||||
#[non_exhaustive]
|
||||
#[derive(Copy, Clone)]
|
||||
|
@ -31,6 +31,21 @@ pub enum Error {
|
||||
Overrun,
|
||||
}
|
||||
|
||||
impl core::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
let message = match self {
|
||||
Self::Framing => "Invalid Framing",
|
||||
Self::Crc => "Hardware CRC Check Failed",
|
||||
Self::ModeFault => "Mode Fault",
|
||||
Self::Overrun => "Buffer Overrun",
|
||||
};
|
||||
|
||||
write!(f, "{}", message)
|
||||
}
|
||||
}
|
||||
|
||||
impl core::error::Error for Error {}
|
||||
|
||||
/// SPI bit order
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum BitOrder {
|
||||
|
@ -293,6 +293,22 @@ pub enum Error {
|
||||
BufferTooLong,
|
||||
}
|
||||
|
||||
impl core::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
let message = match self {
|
||||
Self::Framing => "Framing Error",
|
||||
Self::Noise => "Noise Error",
|
||||
Self::Overrun => "RX Buffer Overrun",
|
||||
Self::Parity => "Parity Check Error",
|
||||
Self::BufferTooLong => "Buffer too large for DMA",
|
||||
};
|
||||
|
||||
write!(f, "{}", message)
|
||||
}
|
||||
}
|
||||
|
||||
impl core::error::Error for Error {}
|
||||
|
||||
enum ReadCompletionEvent {
|
||||
// DMA Read transfer completed first
|
||||
DmaCompleted,
|
||||
|
Loading…
x
Reference in New Issue
Block a user