1#![no_std]
2
3#[cfg(feature = "alloc")]
4extern crate alloc;
5
6#[macro_use]
7mod _macro;
8
9pub mod io;
10#[cfg(feature = "alloc")]
11pub mod lock;
12
13#[derive(Debug, Clone, Copy)]
14pub enum Error {
15 NoDev,
16 InvalidIo,
17 Busy,
18 InvalidArgument,
19 NoMemory,
20 Timeout,
21}
22
23impl core::fmt::Display for Error {
24 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
25 write!(f, "{self:?}")
26 }
27}
28
29impl core::error::Error for Error {}
30
31pub type DriverResult<T = ()> = core::result::Result<T, Error>;
32
33pub trait DriverGeneric: Send {
34 fn open(&mut self) -> DriverResult;
35 fn close(&mut self) -> DriverResult;
36}
37
38custom_type!(IrqId, usize, "{:#x}");
39
40#[derive(Copy, Clone, Debug, Eq, PartialEq)]
42pub enum Trigger {
43 EdgeBoth,
44 EdgeRising,
45 EdgeFailling,
46 LevelHigh,
47 LevelLow,
48}
49
50#[derive(Debug, Clone)]
51pub struct IrqConfig {
52 pub irq: IrqId,
53 pub trigger: Trigger,
54}