sel4_pl031_driver/
lib.rs
1#![no_std]
8
9use rtcc::{DateTime, DateTimeAccess, NaiveDateTime};
10
11mod device;
12
13use device::Device;
14
15pub struct Driver {
16 device: Device,
17}
18
19impl Driver {
20 #[allow(clippy::missing_safety_doc)]
21 pub const unsafe fn new_uninit(ptr: *mut ()) -> Self {
22 Self {
23 device: Device::new(ptr),
24 }
25 }
26
27 #[allow(clippy::missing_safety_doc)]
28 pub unsafe fn new(ptr: *mut ()) -> Self {
29 let mut this = Self::new_uninit(ptr);
30 this.init();
31 this
32 }
33
34 pub fn init(&mut self) {}
35}
36
37impl DateTimeAccess for Driver {
38 type Error = Error;
39
40 fn datetime(&mut self) -> Result<NaiveDateTime, Self::Error> {
41 Ok(DateTime::from_timestamp(self.device.get_data().into(), 0)
42 .unwrap()
43 .naive_utc())
44 }
45
46 fn set_datetime(&mut self, _datetime: &NaiveDateTime) -> Result<(), Self::Error> {
47 Err(Error::UnsupportedOperation)
48 }
49}
50
51#[derive(Debug, Clone)]
52pub enum Error {
53 UnsupportedOperation,
54}