sel4_bcm2835_aux_uart_driver/
lib.rs
1#![no_std]
8
9use core::convert::Infallible;
10
11use embedded_hal_nb::nb;
12use embedded_hal_nb::serial;
13
14mod device;
17
18use device::Device;
19
20pub struct Driver {
21 device: Device,
22}
23
24unsafe impl Send for Driver {}
25unsafe impl Sync for Driver {}
26
27impl Driver {
28 #[allow(clippy::missing_safety_doc)]
29 pub const unsafe fn new_uninit(ptr: *mut ()) -> Self {
30 Self {
31 device: Device::new(ptr.cast()),
32 }
33 }
34
35 #[allow(clippy::missing_safety_doc)]
36 pub unsafe fn new(ptr: *mut ()) -> Self {
37 let mut this = Self::new_uninit(ptr);
38 this.init();
39 this
40 }
41
42 pub fn init(&mut self) {
43 self.device.init();
44 }
45}
46
47impl serial::ErrorType for Driver {
48 type Error = Infallible;
49}
50
51impl serial::Write for Driver {
59 fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> {
60 self.device.put_char(word);
61 Ok(())
62 }
63
64 fn flush(&mut self) -> nb::Result<(), Self::Error> {
65 Ok(())
66 }
67}
68
69