Skip to main content

rfm69_async/
error.rs

1// SPDX-License-Identifier: AGPL-3.0-only
2
3use crate::traits::TrxError;
4
5/// Error for rfm69 transceiver
6#[allow(clippy::upper_case_acronyms)]
7#[derive(Debug)]
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9pub enum Error<SPI, RESET, DIO0> {
10    VersionMismatch(u8),
11    Reset(RESET),
12    SPI(SPI),
13    DIO0(DIO0),
14    SyncSize,
15    WrongPacketFormat,
16}
17
18impl<SPI, RESET, DIO0> From<Error<SPI, RESET, DIO0>> for TrxError {
19    fn from(error: Error<SPI, RESET, DIO0>) -> Self {
20        match error {
21            Error::VersionMismatch(_) => TrxError::TrxNotFound,
22            Error::Reset(_) => TrxError::Reset,
23            Error::SPI(_) => TrxError::Spi,
24            Error::DIO0(_) => TrxError::Gpio,
25            Error::SyncSize => TrxError::Config,
26            Error::WrongPacketFormat => TrxError::WrongPacketFormat,
27        }
28    }
29}