rdif_base/
lib.rs

1#![no_std]
2
3extern crate alloc;
4
5use alloc::string::String;
6
7#[macro_use]
8mod _macro;
9
10pub mod io;
11pub mod lock;
12
13#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)]
14pub enum ErrorBase {
15    #[error("IO error")]
16    Io,
17    #[error("No memory")]
18    NoMem,
19    #[error("Try Again")]
20    Again,
21    #[error("Busy")]
22    Busy,
23    #[error("Bad Address: {0:#x}")]
24    BadAddr(usize),
25    #[error("Invalid Argument `{name}`: [{val}]")]
26    InvalidArg { name: &'static str, val: String },
27}
28
29pub trait DriverGeneric: Send {
30    fn open(&mut self) -> Result<(), ErrorBase>;
31    fn close(&mut self) -> Result<(), ErrorBase>;
32}
33
34custom_type!(IrqId, usize, "{:#x}");
35
36/// The trigger configuration for an interrupt.
37#[derive(Copy, Clone, Debug, Eq, PartialEq)]
38pub enum Trigger {
39    EdgeBoth,
40    EdgeRising,
41    EdgeFailling,
42    LevelHigh,
43    LevelLow,
44}
45
46#[derive(Debug, Clone)]
47pub struct IrqConfig {
48    pub irq: IrqId,
49    pub trigger: Trigger,
50}