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