1use core::marker::PhantomData;
4
5pub trait IsUnlocked {}
7
8pub trait InputMode {}
10
11pub trait OutputMode {}
13
14pub trait OpenDrainMode {
16 fn pup() -> bool;
18}
19
20pub trait AlternateFunctionChoice {
22 fn number() -> u32;
24}
25
26pub struct Input<MODE>
28where
29 MODE: InputMode,
30{
31 _mode: PhantomData<MODE>,
32}
33impl<MODE> IsUnlocked for Input<MODE> where MODE: InputMode {}
34
35pub struct Floating;
37impl InputMode for Floating {}
38impl OpenDrainMode for Floating {
39 fn pup() -> bool {
41 false
42 }
43}
44
45pub struct PullDown;
47impl InputMode for PullDown {}
48
49pub struct PullUp;
51impl InputMode for PullUp {}
52impl OpenDrainMode for PullUp {
53 fn pup() -> bool {
55 true
56 }
57}
58
59pub struct Tristate;
61impl IsUnlocked for Tristate {}
62
63pub struct Output<MODE>
65where
66 MODE: OutputMode,
67{
68 _mode: PhantomData<MODE>,
69}
70impl<MODE> IsUnlocked for Output<MODE> where MODE: OutputMode {}
71
72pub struct AlternateFunction<AF, MODE>
74where
75 AF: AlternateFunctionChoice,
76 MODE: OutputMode,
77{
78 _func: PhantomData<AF>,
79 _mode: PhantomData<MODE>,
80}
81impl<AF, MODE> IsUnlocked for AlternateFunction<AF, MODE>
82where
83 AF: AlternateFunctionChoice,
84 MODE: OutputMode,
85{
86}
87
88pub struct PushPull;
91impl OutputMode for PushPull {}
92impl OutputMode for PullDown {}
93impl OutputMode for PullUp {}
94
95pub struct OpenDrain<ODM>
98where
99 ODM: OpenDrainMode,
100{
101 _pull: PhantomData<ODM>,
102}
103impl<ODM> OutputMode for OpenDrain<ODM> where ODM: OpenDrainMode {}
104
105pub struct AF1;
107impl AlternateFunctionChoice for AF1 {
108 fn number() -> u32 {
109 1
110 }
111}
112
113pub struct AF2;
115impl AlternateFunctionChoice for AF2 {
116 fn number() -> u32 {
117 2
118 }
119}
120
121pub struct AF3;
123impl AlternateFunctionChoice for AF3 {
124 fn number() -> u32 {
125 3
126 }
127}
128
129pub struct AF4;
131impl AlternateFunctionChoice for AF4 {
132 fn number() -> u32 {
133 4
134 }
135}
136
137pub struct AF5;
139impl AlternateFunctionChoice for AF5 {
140 fn number() -> u32 {
141 5
142 }
143}
144
145pub struct AF6;
147impl AlternateFunctionChoice for AF6 {
148 fn number() -> u32 {
149 6
150 }
151}
152
153pub struct AF7;
155impl AlternateFunctionChoice for AF7 {
156 fn number() -> u32 {
157 7
158 }
159}
160
161pub struct AF8;
163impl AlternateFunctionChoice for AF8 {
164 fn number() -> u32 {
165 8
166 }
167}
168
169pub struct AF9;
171impl AlternateFunctionChoice for AF9 {
172 fn number() -> u32 {
173 9
174 }
175}
176
177pub struct AF14;
181impl AlternateFunctionChoice for AF14 {
182 fn number() -> u32 {
183 14
184 }
185}
186
187pub struct Locked;
189
190pub enum InterruptMode {
192 LevelLow,
194 LevelHigh,
196 EdgeRising,
198 EdgeFalling,
200 EdgeBoth,
202 Disabled,
204}
205
206