1use core::any::Any;
2
3pub use rdif_base::DriverGeneric;
4
5use crate::Descriptor;
6
7#[macro_use]
8mod _macros;
9
10pub struct Empty;
11
12impl DriverGeneric for Empty {
13 fn open(&mut self) -> Result<(), rdif_base::KError> {
14 Ok(())
15 }
16
17 fn close(&mut self) -> Result<(), rdif_base::KError> {
18 Ok(())
19 }
20}
21
22impl Class for Empty {}
23
24pub struct PlatformDevice {
25 pub descriptor: Descriptor,
26}
27
28impl PlatformDevice {
29 pub(crate) fn new(descriptor: Descriptor) -> Self {
30 Self { descriptor }
31 }
32
33 pub fn register<T: Class>(self, driver: T) {
38 crate::edit(|manager| {
39 manager.dev_container.insert(self.descriptor, driver);
40 });
41 }
42}
43
44pub trait Class: DriverGeneric {
45 fn raw_any(&self) -> Option<&dyn Any> {
46 None
47 }
48 fn raw_any_mut(&mut self) -> Option<&mut dyn Any> {
49 None
50 }
51}
52
53def_driver_rdif!(Intc);
54def_driver_rdif!(Clk);
55def_driver_rdif!(Power);
56def_driver_rdif!(Systick);
57def_driver_rdif!(Serial);
58def_driver_rdif!(Block);