1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
#![no_std] /// This crate contains a variety of universal error types which can be used to universally model /// conditions which can typically arise for certain peripherals. /// /// When used by HAL implementations, they allow drivers and applications alike to generically /// handle those situations without the error handling being specific to the hardware it is /// supposed to run on (which is usually not possible to implement in drivers). /// /// All of the enums in this crate are marked as `#[non_exhaustive]` to allow for additions of new /// error kinds without requiring a breaking change and version bump. /// A SPI specific error. /// /// This error type contains errors specific to SPI peripherals. Also it has an `Impl` kind to pass /// through implementation specific errors occuring while trying to use a SPI peripheral. #[non_exhaustive] pub enum SpiError { /// The peripheral receive buffer was overrun Overrun, /// Multiple devices on the SPI bus are trying across each other, e.g. in a multi-master setup ModeFault, /// CRC does not match the received data CRCError, /// Received data does not conform to the peripheral configuration FrameFormatError, /// Implementation specific error (shared across all peripheral specific error kinds) Impl(ImplError), } /// An I2C specific error. /// /// This error type contains errors specific to I2C peripherals. Also it has an `Impl` kind to pass /// through implementation specific errors occuring while trying to use an I2C peripheral. #[non_exhaustive] pub enum I2cError { /// An unspecific bus error occured BusError, /// The arbitration was lost, e.g. electrical problems with the clock signal ArbitrationLoss, /// A bus operation received a NACK, e.g. due to the addressed device not being available on /// the bus or device not being ready to process any requests at the moment NACK, /// The peripheral receive buffer was overrun Overrun, /// The peripheral send buffer ran out of data Underrun, /// SMBus Error checking byte mismatch PacketErrorChecking, /// SMBus Timeout error Timeout, /// SMBus Alert received Alert, /// Implementation specific error (shared across all peripheral specific error kinds) Impl(ImplError), } /// A universal implementation specific error. /// /// These error kinds can be used to signal implementation specific errors unrelated to the /// specific peripheral. This will be used for all sorts of connectivity problems, e.g. if an /// adapter to the peripheral is used or the target peripheral is connected to indirectly (like bus /// expanders) or an operating system is controlling the access and denying access. #[non_exhaustive] pub enum ImplError { /// Unspecified internal driver error Internal, /// Connection lost, e.g. device adapter was unplugged Disconnected, /// Ran out of memory while trying to allocate required buffers OutOfMemory, /// Operation timed out, please retry TimedOut, /// Peripheral is sleeping or in standby Asleep, /// Peripheral is powered down PowerDown, /// The peripheral cannot work with the specified settings InvalidConfiguration, /// Could not open connection to peripheral CouldNotOpen, /// No sufficient permissions to connect to peripheral PermissionDenied, }