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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#[derive(Copy, Clone, Debug)]
pub struct StatusRegister1(pub u8);
impl StatusRegister1 {
pub fn get_busy(&self) -> bool {
self.0 & 0b0000_0001 != 0
}
pub fn get_block_protect(&self) -> (bool, bool, bool) {
let bp = (self.0 & 0b0001_1100) >> 2;
(bp & 0b001 != 0, bp & 0b010 != 0, bp & 0b100 != 0)
}
pub fn set_block_protect(&mut self, bp0: bool, bp1: bool, bp2: bool) {
self.0 &= 0b1110_0011;
self.0 |= ((bp0 as u8) << 2) | ((bp1 as u8) << 3) | ((bp2 as u8) << 4);
}
pub fn get_sec(&self) -> bool {
self.0 & 0b0100_0000 != 0
}
pub fn get_tb(&self) -> bool {
self.0 & 0b0010_0000 != 0
}
pub fn get_srp(&self) -> bool {
self.0 & 0b1000_0000 != 0
}
}
#[derive(Copy, Clone, Debug)]
pub struct StatusRegister2(pub u8);
impl StatusRegister2 {
pub fn get_cmp(&self) -> bool {
self.0 & 0b0100_0000 != 0
}
}
#[derive(Copy, Clone, Debug)]
pub struct StatusRegister3(pub u8);
impl StatusRegister3 {
pub fn get_wps(&self) -> bool {
self.0 & 0b0000_0100 != 0
}
pub fn set_wps(&mut self, wps: bool) {
self.0 &= 0b1111_1011;
self.0 |= (wps as u8) << 2;
}
}