Skip to main content

cc1101_embassy/
error.rs

1//! Error types for the CC1101 driver.
2
3/// All errors that can be returned by the CC1101 driver.
4#[derive(Debug)]
5#[cfg_attr(feature = "defmt", derive(defmt::Format))]
6pub enum Error<SpiError> {
7    /// An error occurred on the SPI bus
8    Spi(SpiError),
9
10    /// The RX FIFO overflowed before we could read it.
11    /// The driver will automatically flush the FIFO and return to IDLE.
12    RxFifoOverflow,
13
14    /// The TX FIFO underflowed during transmission.
15    TxFifoUnderflow,
16
17    /// A packet was received but the hardware CRC check failed.
18    /// Only returned when `crc_enable` is set in [`RadioConfig`].
19    CrcError,
20
21    /// The provided payload exceeds the maximum packet length.
22    /// For variable-length mode, max is 61 bytes; fixed-length is set at config time.
23    PayloadTooLong,
24
25    /// The chip did not respond correctly during initialisation.
26    /// Check your SPI wiring and that the CC1101 is powered.
27    InvalidChip {
28        /// Raw value of the PARTNUM status register (expected 0x00)
29        part: u8,
30        /// Raw value of the VERSION status register (expected 0x04 or 0x14)
31        version: u8,
32    },
33
34    /// The chip was in an unexpected state when an operation was attempted.
35    UnexpectedState {
36        /// Raw MARCSTATE register value at the time of the error
37        state: u8,
38    },
39}
40
41impl<E> From<E> for Error<E> {
42    fn from(e: E) -> Self {
43        Error::Spi(e)
44    }
45}