1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use core::cell::UnsafeCell;
use core::ptr;
use volatile_register::{RO, RW, WO};
#[repr(C)]
pub struct RegisterBlock {
pub stim: [Stim; 256],
reserved0: [u32; 640],
pub ter: [RW<u32>; 8],
reserved1: [u32; 8],
pub tpr: RW<u32>,
reserved2: [u32; 15],
pub tcr: RW<u32>,
reserved3: [u32; 75],
pub lar: WO<u32>,
pub lsr: RO<u32>,
}
pub struct Stim {
register: UnsafeCell<u32>,
}
impl Stim {
pub fn write_u8(&mut self, value: u8) {
unsafe { ptr::write_volatile(self.register.get() as *mut u8, value) }
}
pub fn write_u16(&mut self, value: u16) {
unsafe { ptr::write_volatile(self.register.get() as *mut u16, value) }
}
pub fn write_u32(&mut self, value: u32) {
unsafe { ptr::write_volatile(self.register.get(), value) }
}
pub fn is_fifo_ready(&self) -> bool {
unsafe { ptr::read_volatile(self.register.get()) == 1 }
}
}