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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#[allow(unused_imports)]
use cortex_m_semihosting::{dbg, hprint, hprintln};
use core::ops::Deref;
use crate::{
peripherals::{
syscon,
},
traits,
typestates::{
init_state,
},
};
pub struct Gint<State: init_state::InitState = init_state::Unknown> {
pub(crate) raw_gint0: raw::GINT0,
pub(crate) raw_gint1: raw::GINT1,
_state: State,
}
impl Gint {
pub fn new(raw_gint0: raw::GINT0, raw_gint1: raw::GINT1) -> Self {
Gint {
raw_gint0,
raw_gint1,
_state: init_state::Unknown,
}
}
}
pub struct Gint0<State: init_state::InitState = init_state::Enabled> {
pub(crate) raw: raw::GINT0,
_state: State,
}
impl Deref for Gint0 {
type Target = raw::gint0::RegisterBlock;
fn deref(&self) -> &Self::Target {
&self.raw
}
}
impl traits::Gint for Gint0 {}
pub type EnabledGint0 = Gint0<init_state::Enabled>;
pub struct Gint1<State: init_state::InitState = init_state::Enabled> {
pub(crate) raw: raw::GINT1,
_state: State,
}
impl Deref for Gint1 {
type Target = raw::gint0::RegisterBlock;
fn deref(&self) -> &Self::Target {
&self.raw
}
}
impl traits::Gint for Gint1 {}
pub type EnabledGint1 = Gint1<init_state::Enabled>;
impl<State: init_state::InitState> Gint<State> {
pub fn release(self) -> (raw::GINT0, raw::GINT1) {
(self.raw_gint0, self.raw_gint1)
}
pub fn enabled(
mut self,
syscon: &mut syscon::Syscon,
) -> (Gint0, Gint1) {
syscon.enable_clock(&mut (&mut self.raw_gint0, &mut self.raw_gint1));
(
Gint0 {
raw: self.raw_gint0,
_state: init_state::Enabled(()),
},
Gint1 {
raw: self.raw_gint1,
_state: init_state::Enabled(()),
},
)
}
}
impl From<(raw::GINT0, raw::GINT1)> for Gint {
fn from(raw: (raw::GINT0, raw::GINT1)) -> Self {
Gint::new(raw.0, raw.1)
}
}