aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob McWhirter <[email protected]>2021-05-06 14:33:29 -0400
committerBob McWhirter <[email protected]>2021-05-06 14:35:46 -0400
commite8537ca9c2f5f5a202c16da26d214fc0db5e65ab (patch)
treee5dff86fa1e3b3e1629e9488e17184935901cc9b
parent1eb70a7e5d8157041e28caf2c176ac4dde78e4c2 (diff)
Implement async RNG, including rand_core sync traits.
-rw-r--r--embassy-stm32-examples/.cargo/config8
-rw-r--r--embassy-stm32-examples/Cargo.toml6
-rw-r--r--embassy-stm32-examples/src/bin/blinky.rs23
-rw-r--r--embassy-stm32-examples/src/bin/button_exti.rs24
-rw-r--r--embassy-stm32/Cargo.toml3
-rw-r--r--embassy-stm32/gen.py8
-rw-r--r--embassy-stm32/src/lib.rs1
-rw-r--r--embassy-stm32/src/pac/regs.rs5642
-rw-r--r--embassy-stm32/src/rng.rs150
-rw-r--r--embassy-traits/src/rng.rs2
10 files changed, 2992 insertions, 2875 deletions
diff --git a/embassy-stm32-examples/.cargo/config b/embassy-stm32-examples/.cargo/config
index 8713fbae9..7c1d4dfb6 100644
--- a/embassy-stm32-examples/.cargo/config
+++ b/embassy-stm32-examples/.cargo/config
@@ -1,8 +1,5 @@
1[target.'cfg(all(target_arch = "arm", target_os = "none"))'] 1[target.'cfg(all(target_arch = "arm", target_os = "none"))']
2#runner = "probe-run --chip STM32F401CCUx" 2runner = "probe-run --chip STM32F401CCUx"
3#runner = "probe-run --chip STM32L4S5VITx"
4#runner = "probe-run --chip ${PROBE_RUN_CHIP}"
5runner = "probe-run"
6 3
7rustflags = [ 4rustflags = [
8 # LLD (shipped with the Rust toolchain) is used as the default linker 5 # LLD (shipped with the Rust toolchain) is used as the default linker
@@ -28,5 +25,4 @@ rustflags = [
28] 25]
29 26
30[build] 27[build]
31#target = "thumbv7em-none-eabihf" 28target = "thumbv7em-none-eabihf"
32target = "thumbv7em-none-eabi"
diff --git a/embassy-stm32-examples/Cargo.toml b/embassy-stm32-examples/Cargo.toml
index dbc537381..ab6fc6c14 100644
--- a/embassy-stm32-examples/Cargo.toml
+++ b/embassy-stm32-examples/Cargo.toml
@@ -18,11 +18,9 @@ defmt-error = []
18[dependencies] 18[dependencies]
19embassy = { version = "0.1.0", path = "../embassy", features = ["defmt", "defmt-trace"] } 19embassy = { version = "0.1.0", path = "../embassy", features = ["defmt", "defmt-trace"] }
20embassy-traits = { version = "0.1.0", path = "../embassy-traits", features = ["defmt"] } 20embassy-traits = { version = "0.1.0", path = "../embassy-traits", features = ["defmt"] }
21#embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", features = ["defmt", "defmt-trace", "stm32f429zi"] } 21embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", features = ["defmt", "defmt-trace", "stm32f429zi"] }
22embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", features = ["defmt", "defmt-trace", "stm32l4s5vi"] }
23embassy-extras = {version = "0.1.0", path = "../embassy-extras" } 22embassy-extras = {version = "0.1.0", path = "../embassy-extras" }
24#stm32f4 = { version = "0.13", features = ["stm32f429"] } 23stm32f4 = { version = "0.13", features = ["stm32f429"] }
25stm32l4 = { version = "0.13", features = ["stm32l4x5" ] }
26 24
27defmt = "0.2.0" 25defmt = "0.2.0"
28defmt-rtt = "0.2.0" 26defmt-rtt = "0.2.0"
diff --git a/embassy-stm32-examples/src/bin/blinky.rs b/embassy-stm32-examples/src/bin/blinky.rs
index deee52368..9ccd6c01e 100644
--- a/embassy-stm32-examples/src/bin/blinky.rs
+++ b/embassy-stm32-examples/src/bin/blinky.rs
@@ -12,8 +12,7 @@ use embedded_hal::digital::v2::OutputPin;
12use example_common::*; 12use example_common::*;
13 13
14use cortex_m_rt::entry; 14use cortex_m_rt::entry;
15//use stm32f4::stm32f429 as pac; 15use stm32f4::stm32f429 as pac;
16use stm32l4::stm32l4x5 as pac;
17 16
18#[entry] 17#[entry]
19fn main() -> ! { 18fn main() -> ! {
@@ -26,21 +25,21 @@ fn main() -> ! {
26 w.dbg_standby().set_bit(); 25 w.dbg_standby().set_bit();
27 w.dbg_stop().set_bit() 26 w.dbg_stop().set_bit()
28 }); 27 });
29 pp.RCC.ahb1enr.modify(|_, w| w.dma1en().set_bit()); 28 pp.RCC.ahb1enr.modify(|_, w| w.dma1en().enabled());
30 29
31 pp.RCC.ahb2enr.modify(|_, w| { 30 pp.RCC.ahb1enr.modify(|_, w| {
32 w.gpioaen().set_bit(); 31 w.gpioaen().enabled();
33 w.gpioben().set_bit(); 32 w.gpioben().enabled();
34 w.gpiocen().set_bit(); 33 w.gpiocen().enabled();
35 w.gpioden().set_bit(); 34 w.gpioden().enabled();
36 w.gpioeen().set_bit(); 35 w.gpioeen().enabled();
37 w.gpiofen().set_bit(); 36 w.gpiofen().enabled();
38 w 37 w
39 }); 38 });
40 39
41 let p = embassy_stm32::init(Default::default()); 40 let p = embassy_stm32::init(Default::default());
42 41
43 let mut led = Output::new(p.PA5, Level::High); 42 let mut led = Output::new(p.PB7, Level::High);
44 43
45 loop { 44 loop {
46 info!("high"); 45 info!("high");
diff --git a/embassy-stm32-examples/src/bin/button_exti.rs b/embassy-stm32-examples/src/bin/button_exti.rs
index 6b7acdca0..d6f545fa4 100644
--- a/embassy-stm32-examples/src/bin/button_exti.rs
+++ b/embassy-stm32-examples/src/bin/button_exti.rs
@@ -16,8 +16,7 @@ use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
16use example_common::*; 16use example_common::*;
17 17
18use cortex_m_rt::entry; 18use cortex_m_rt::entry;
19//use stm32f4::stm32f429 as pac; 19use stm32f4::stm32f429 as pac;
20use stm32l4::stm32l4x5 as pac;
21 20
22#[embassy::task] 21#[embassy::task]
23async fn main_task() { 22async fn main_task() {
@@ -57,20 +56,19 @@ fn main() -> ! {
57 w.dbg_standby().set_bit(); 56 w.dbg_standby().set_bit();
58 w.dbg_stop().set_bit() 57 w.dbg_stop().set_bit()
59 }); 58 });
60 59 pp.RCC.ahb1enr.modify(|_, w| w.dma1en().enabled());
61 pp.RCC.ahb1enr.modify(|_, w| w.dma1en().set_bit()); 60
62 61 pp.RCC.ahb1enr.modify(|_, w| {
63 pp.RCC.ahb2enr.modify(|_, w| { 62 w.gpioaen().enabled();
64 w.gpioaen().set_bit(); 63 w.gpioben().enabled();
65 w.gpioben().set_bit(); 64 w.gpiocen().enabled();
66 w.gpiocen().set_bit(); 65 w.gpioden().enabled();
67 w.gpioden().set_bit(); 66 w.gpioeen().enabled();
68 w.gpioeen().set_bit(); 67 w.gpiofen().enabled();
69 w.gpiofen().set_bit();
70 w 68 w
71 }); 69 });
72 pp.RCC.apb2enr.modify(|_, w| { 70 pp.RCC.apb2enr.modify(|_, w| {
73 w.syscfgen().set_bit(); 71 w.syscfgen().enabled();
74 w 72 w
75 }); 73 });
76 74
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml
index 9449f636b..6ae96dbca 100644
--- a/embassy-stm32/Cargo.toml
+++ b/embassy-stm32/Cargo.toml
@@ -15,6 +15,7 @@ cortex-m-rt = { version = "0.6.13", features = ["device"] }
15cortex-m = "0.7.1" 15cortex-m = "0.7.1"
16embedded-hal = { version = "0.2.4" } 16embedded-hal = { version = "0.2.4" }
17futures = { version = "0.3.5", default-features = false, features = ["async-await"] } 17futures = { version = "0.3.5", default-features = false, features = ["async-await"] }
18rand_core = { version = "0.6.2", optional=true}
18 19
19[build-dependencies] 20[build-dependencies]
20regex = "1.4.6" 21regex = "1.4.6"
@@ -321,7 +322,7 @@ _exti = []
321_exti_v1 = [] 322_exti_v1 = []
322_gpio = [] 323_gpio = []
323_gpio_v2 = [] 324_gpio_v2 = []
324_rng = [] 325_rng = [ "rand_core",]
325_rng_v1 = [] 326_rng_v1 = []
326_stm32f4 = [] 327_stm32f4 = []
327_stm32l4 = [] 328_stm32l4 = []
diff --git a/embassy-stm32/gen.py b/embassy-stm32/gen.py
index a1af866f4..d49623389 100644
--- a/embassy-stm32/gen.py
+++ b/embassy-stm32/gen.py
@@ -201,6 +201,9 @@ for chip in chips.values():
201 201
202# ========= Update Cargo features 202# ========= Update Cargo features
203 203
204feature_optional_deps = {}
205feature_optional_deps['_rng'] = ['rand_core']
206
204features = {} 207features = {}
205extra_features = set() 208extra_features = set()
206for name, chip in chips.items(): 209for name, chip in chips.items():
@@ -208,7 +211,10 @@ for name, chip in chips.items():
208 for feature in chip['features']: 211 for feature in chip['features']:
209 extra_features.add(feature) 212 extra_features.add(feature)
210for feature in sorted(list(extra_features)): 213for feature in sorted(list(extra_features)):
211 features[feature] = [] 214 if feature in feature_optional_deps:
215 features[feature] = feature_optional_deps[feature]
216 else:
217 features[feature] = []
212 218
213SEPARATOR_START = '# BEGIN GENERATED FEATURES\n' 219SEPARATOR_START = '# BEGIN GENERATED FEATURES\n'
214SEPARATOR_END = '# END GENERATED FEATURES\n' 220SEPARATOR_END = '# END GENERATED FEATURES\n'
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs
index 557ed61af..c3ab55036 100644
--- a/embassy-stm32/src/lib.rs
+++ b/embassy-stm32/src/lib.rs
@@ -15,6 +15,7 @@ pub mod exti;
15pub mod gpio; 15pub mod gpio;
16#[cfg(feature = "_rng")] 16#[cfg(feature = "_rng")]
17pub mod rng; 17pub mod rng;
18#[cfg(feature = "_usart")]
18pub mod usart; 19pub mod usart;
19 20
20// This must go LAST so that it sees the `impl_foo!` macros 21// This must go LAST so that it sees the `impl_foo!` macros
diff --git a/embassy-stm32/src/pac/regs.rs b/embassy-stm32/src/pac/regs.rs
index e7f853c75..d9d2f8012 100644
--- a/embassy-stm32/src/pac/regs.rs
+++ b/embassy-stm32/src/pac/regs.rs
@@ -1,5 +1,507 @@
1#![no_std] 1#![no_std]
2#![doc = "Peripheral access API (generated using svd2rust v0.17.0 (507115a 2021-04-19))"] 2#![doc = "Peripheral access API (generated using svd2rust v0.17.0 (507115a 2021-04-19))"]
3pub mod syscfg_f4 {
4 use crate::generic::*;
5 #[doc = "System configuration controller"]
6 #[derive(Copy, Clone)]
7 pub struct Syscfg(pub *mut u8);
8 unsafe impl Send for Syscfg {}
9 unsafe impl Sync for Syscfg {}
10 impl Syscfg {
11 #[doc = "memory remap register"]
12 pub fn memrm(self) -> Reg<regs::Memrm, RW> {
13 unsafe { Reg::from_ptr(self.0.add(0usize)) }
14 }
15 #[doc = "peripheral mode configuration register"]
16 pub fn pmc(self) -> Reg<regs::Pmc, RW> {
17 unsafe { Reg::from_ptr(self.0.add(4usize)) }
18 }
19 #[doc = "external interrupt configuration register"]
20 pub fn exticr(self, n: usize) -> Reg<regs::Exticr, RW> {
21 assert!(n < 4usize);
22 unsafe { Reg::from_ptr(self.0.add(8usize + n * 4usize)) }
23 }
24 #[doc = "Compensation cell control register"]
25 pub fn cmpcr(self) -> Reg<regs::Cmpcr, R> {
26 unsafe { Reg::from_ptr(self.0.add(32usize)) }
27 }
28 }
29 pub mod regs {
30 use crate::generic::*;
31 #[doc = "peripheral mode configuration register"]
32 #[repr(transparent)]
33 #[derive(Copy, Clone, Eq, PartialEq)]
34 pub struct Pmc(pub u32);
35 impl Pmc {
36 #[doc = "ADC1DC2"]
37 pub const fn adc1dc2(&self) -> bool {
38 let val = (self.0 >> 16usize) & 0x01;
39 val != 0
40 }
41 #[doc = "ADC1DC2"]
42 pub fn set_adc1dc2(&mut self, val: bool) {
43 self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
44 }
45 #[doc = "ADC2DC2"]
46 pub const fn adc2dc2(&self) -> bool {
47 let val = (self.0 >> 17usize) & 0x01;
48 val != 0
49 }
50 #[doc = "ADC2DC2"]
51 pub fn set_adc2dc2(&mut self, val: bool) {
52 self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
53 }
54 #[doc = "ADC3DC2"]
55 pub const fn adc3dc2(&self) -> bool {
56 let val = (self.0 >> 18usize) & 0x01;
57 val != 0
58 }
59 #[doc = "ADC3DC2"]
60 pub fn set_adc3dc2(&mut self, val: bool) {
61 self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize);
62 }
63 #[doc = "Ethernet PHY interface selection"]
64 pub const fn mii_rmii_sel(&self) -> bool {
65 let val = (self.0 >> 23usize) & 0x01;
66 val != 0
67 }
68 #[doc = "Ethernet PHY interface selection"]
69 pub fn set_mii_rmii_sel(&mut self, val: bool) {
70 self.0 = (self.0 & !(0x01 << 23usize)) | (((val as u32) & 0x01) << 23usize);
71 }
72 }
73 impl Default for Pmc {
74 fn default() -> Pmc {
75 Pmc(0)
76 }
77 }
78 #[doc = "memory remap register"]
79 #[repr(transparent)]
80 #[derive(Copy, Clone, Eq, PartialEq)]
81 pub struct Memrm(pub u32);
82 impl Memrm {
83 #[doc = "Memory mapping selection"]
84 pub const fn mem_mode(&self) -> u8 {
85 let val = (self.0 >> 0usize) & 0x07;
86 val as u8
87 }
88 #[doc = "Memory mapping selection"]
89 pub fn set_mem_mode(&mut self, val: u8) {
90 self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize);
91 }
92 #[doc = "Flash bank mode selection"]
93 pub const fn fb_mode(&self) -> bool {
94 let val = (self.0 >> 8usize) & 0x01;
95 val != 0
96 }
97 #[doc = "Flash bank mode selection"]
98 pub fn set_fb_mode(&mut self, val: bool) {
99 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
100 }
101 #[doc = "FMC memory mapping swap"]
102 pub const fn swp_fmc(&self) -> u8 {
103 let val = (self.0 >> 10usize) & 0x03;
104 val as u8
105 }
106 #[doc = "FMC memory mapping swap"]
107 pub fn set_swp_fmc(&mut self, val: u8) {
108 self.0 = (self.0 & !(0x03 << 10usize)) | (((val as u32) & 0x03) << 10usize);
109 }
110 }
111 impl Default for Memrm {
112 fn default() -> Memrm {
113 Memrm(0)
114 }
115 }
116 #[doc = "external interrupt configuration register"]
117 #[repr(transparent)]
118 #[derive(Copy, Clone, Eq, PartialEq)]
119 pub struct Exticr(pub u32);
120 impl Exticr {
121 #[doc = "EXTI x configuration"]
122 pub fn exti(&self, n: usize) -> u8 {
123 assert!(n < 4usize);
124 let offs = 0usize + n * 4usize;
125 let val = (self.0 >> offs) & 0x0f;
126 val as u8
127 }
128 #[doc = "EXTI x configuration"]
129 pub fn set_exti(&mut self, n: usize, val: u8) {
130 assert!(n < 4usize);
131 let offs = 0usize + n * 4usize;
132 self.0 = (self.0 & !(0x0f << offs)) | (((val as u32) & 0x0f) << offs);
133 }
134 }
135 impl Default for Exticr {
136 fn default() -> Exticr {
137 Exticr(0)
138 }
139 }
140 #[doc = "Compensation cell control register"]
141 #[repr(transparent)]
142 #[derive(Copy, Clone, Eq, PartialEq)]
143 pub struct Cmpcr(pub u32);
144 impl Cmpcr {
145 #[doc = "Compensation cell power-down"]
146 pub const fn cmp_pd(&self) -> bool {
147 let val = (self.0 >> 0usize) & 0x01;
148 val != 0
149 }
150 #[doc = "Compensation cell power-down"]
151 pub fn set_cmp_pd(&mut self, val: bool) {
152 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
153 }
154 #[doc = "READY"]
155 pub const fn ready(&self) -> bool {
156 let val = (self.0 >> 8usize) & 0x01;
157 val != 0
158 }
159 #[doc = "READY"]
160 pub fn set_ready(&mut self, val: bool) {
161 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
162 }
163 }
164 impl Default for Cmpcr {
165 fn default() -> Cmpcr {
166 Cmpcr(0)
167 }
168 }
169 }
170}
171pub mod syscfg_l4 {
172 use crate::generic::*;
173 #[doc = "System configuration controller"]
174 #[derive(Copy, Clone)]
175 pub struct Syscfg(pub *mut u8);
176 unsafe impl Send for Syscfg {}
177 unsafe impl Sync for Syscfg {}
178 impl Syscfg {
179 #[doc = "memory remap register"]
180 pub fn memrmp(self) -> Reg<regs::Memrmp, RW> {
181 unsafe { Reg::from_ptr(self.0.add(0usize)) }
182 }
183 #[doc = "configuration register 1"]
184 pub fn cfgr1(self) -> Reg<regs::Cfgr1, RW> {
185 unsafe { Reg::from_ptr(self.0.add(4usize)) }
186 }
187 #[doc = "external interrupt configuration register 1"]
188 pub fn exticr(self, n: usize) -> Reg<regs::Exticr, RW> {
189 assert!(n < 4usize);
190 unsafe { Reg::from_ptr(self.0.add(8usize + n * 4usize)) }
191 }
192 #[doc = "SCSR"]
193 pub fn scsr(self) -> Reg<regs::Scsr, RW> {
194 unsafe { Reg::from_ptr(self.0.add(24usize)) }
195 }
196 #[doc = "CFGR2"]
197 pub fn cfgr2(self) -> Reg<regs::Cfgr2, RW> {
198 unsafe { Reg::from_ptr(self.0.add(28usize)) }
199 }
200 #[doc = "SWPR"]
201 pub fn swpr(self) -> Reg<regs::Swpr, W> {
202 unsafe { Reg::from_ptr(self.0.add(32usize)) }
203 }
204 #[doc = "SKR"]
205 pub fn skr(self) -> Reg<regs::Skr, W> {
206 unsafe { Reg::from_ptr(self.0.add(36usize)) }
207 }
208 }
209 pub mod regs {
210 use crate::generic::*;
211 #[doc = "SWPR"]
212 #[repr(transparent)]
213 #[derive(Copy, Clone, Eq, PartialEq)]
214 pub struct Swpr(pub u32);
215 impl Swpr {
216 #[doc = "SRAWM2 write protection."]
217 pub fn pwp(&self, n: usize) -> bool {
218 assert!(n < 32usize);
219 let offs = 0usize + n * 1usize;
220 let val = (self.0 >> offs) & 0x01;
221 val != 0
222 }
223 #[doc = "SRAWM2 write protection."]
224 pub fn set_pwp(&mut self, n: usize, val: bool) {
225 assert!(n < 32usize);
226 let offs = 0usize + n * 1usize;
227 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
228 }
229 }
230 impl Default for Swpr {
231 fn default() -> Swpr {
232 Swpr(0)
233 }
234 }
235 #[doc = "SKR"]
236 #[repr(transparent)]
237 #[derive(Copy, Clone, Eq, PartialEq)]
238 pub struct Skr(pub u32);
239 impl Skr {
240 #[doc = "SRAM2 write protection key for software erase"]
241 pub const fn key(&self) -> u8 {
242 let val = (self.0 >> 0usize) & 0xff;
243 val as u8
244 }
245 #[doc = "SRAM2 write protection key for software erase"]
246 pub fn set_key(&mut self, val: u8) {
247 self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
248 }
249 }
250 impl Default for Skr {
251 fn default() -> Skr {
252 Skr(0)
253 }
254 }
255 #[doc = "memory remap register"]
256 #[repr(transparent)]
257 #[derive(Copy, Clone, Eq, PartialEq)]
258 pub struct Memrmp(pub u32);
259 impl Memrmp {
260 #[doc = "Memory mapping selection"]
261 pub const fn mem_mode(&self) -> u8 {
262 let val = (self.0 >> 0usize) & 0x07;
263 val as u8
264 }
265 #[doc = "Memory mapping selection"]
266 pub fn set_mem_mode(&mut self, val: u8) {
267 self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize);
268 }
269 #[doc = "QUADSPI memory mapping swap"]
270 pub const fn qfs(&self) -> bool {
271 let val = (self.0 >> 3usize) & 0x01;
272 val != 0
273 }
274 #[doc = "QUADSPI memory mapping swap"]
275 pub fn set_qfs(&mut self, val: bool) {
276 self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
277 }
278 #[doc = "Flash Bank mode selection"]
279 pub const fn fb_mode(&self) -> bool {
280 let val = (self.0 >> 8usize) & 0x01;
281 val != 0
282 }
283 #[doc = "Flash Bank mode selection"]
284 pub fn set_fb_mode(&mut self, val: bool) {
285 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
286 }
287 }
288 impl Default for Memrmp {
289 fn default() -> Memrmp {
290 Memrmp(0)
291 }
292 }
293 #[doc = "CFGR2"]
294 #[repr(transparent)]
295 #[derive(Copy, Clone, Eq, PartialEq)]
296 pub struct Cfgr2(pub u32);
297 impl Cfgr2 {
298 #[doc = "Cortex LOCKUP (Hardfault) output enable bit"]
299 pub const fn cll(&self) -> bool {
300 let val = (self.0 >> 0usize) & 0x01;
301 val != 0
302 }
303 #[doc = "Cortex LOCKUP (Hardfault) output enable bit"]
304 pub fn set_cll(&mut self, val: bool) {
305 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
306 }
307 #[doc = "SRAM2 parity lock bit"]
308 pub const fn spl(&self) -> bool {
309 let val = (self.0 >> 1usize) & 0x01;
310 val != 0
311 }
312 #[doc = "SRAM2 parity lock bit"]
313 pub fn set_spl(&mut self, val: bool) {
314 self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
315 }
316 #[doc = "PVD lock enable bit"]
317 pub const fn pvdl(&self) -> bool {
318 let val = (self.0 >> 2usize) & 0x01;
319 val != 0
320 }
321 #[doc = "PVD lock enable bit"]
322 pub fn set_pvdl(&mut self, val: bool) {
323 self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
324 }
325 #[doc = "ECC Lock"]
326 pub const fn eccl(&self) -> bool {
327 let val = (self.0 >> 3usize) & 0x01;
328 val != 0
329 }
330 #[doc = "ECC Lock"]
331 pub fn set_eccl(&mut self, val: bool) {
332 self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
333 }
334 #[doc = "SRAM2 parity error flag"]
335 pub const fn spf(&self) -> bool {
336 let val = (self.0 >> 8usize) & 0x01;
337 val != 0
338 }
339 #[doc = "SRAM2 parity error flag"]
340 pub fn set_spf(&mut self, val: bool) {
341 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
342 }
343 }
344 impl Default for Cfgr2 {
345 fn default() -> Cfgr2 {
346 Cfgr2(0)
347 }
348 }
349 #[doc = "SCSR"]
350 #[repr(transparent)]
351 #[derive(Copy, Clone, Eq, PartialEq)]
352 pub struct Scsr(pub u32);
353 impl Scsr {
354 #[doc = "SRAM2 Erase"]
355 pub const fn sram2er(&self) -> bool {
356 let val = (self.0 >> 0usize) & 0x01;
357 val != 0
358 }
359 #[doc = "SRAM2 Erase"]
360 pub fn set_sram2er(&mut self, val: bool) {
361 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
362 }
363 #[doc = "SRAM2 busy by erase operation"]
364 pub const fn sram2bsy(&self) -> bool {
365 let val = (self.0 >> 1usize) & 0x01;
366 val != 0
367 }
368 #[doc = "SRAM2 busy by erase operation"]
369 pub fn set_sram2bsy(&mut self, val: bool) {
370 self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
371 }
372 }
373 impl Default for Scsr {
374 fn default() -> Scsr {
375 Scsr(0)
376 }
377 }
378 #[doc = "external interrupt configuration register 4"]
379 #[repr(transparent)]
380 #[derive(Copy, Clone, Eq, PartialEq)]
381 pub struct Exticr(pub u32);
382 impl Exticr {
383 #[doc = "EXTI12 configuration bits"]
384 pub fn exti(&self, n: usize) -> u8 {
385 assert!(n < 4usize);
386 let offs = 0usize + n * 4usize;
387 let val = (self.0 >> offs) & 0x0f;
388 val as u8
389 }
390 #[doc = "EXTI12 configuration bits"]
391 pub fn set_exti(&mut self, n: usize, val: u8) {
392 assert!(n < 4usize);
393 let offs = 0usize + n * 4usize;
394 self.0 = (self.0 & !(0x0f << offs)) | (((val as u32) & 0x0f) << offs);
395 }
396 }
397 impl Default for Exticr {
398 fn default() -> Exticr {
399 Exticr(0)
400 }
401 }
402 #[doc = "configuration register 1"]
403 #[repr(transparent)]
404 #[derive(Copy, Clone, Eq, PartialEq)]
405 pub struct Cfgr1(pub u32);
406 impl Cfgr1 {
407 #[doc = "Firewall disable"]
408 pub const fn fwdis(&self) -> bool {
409 let val = (self.0 >> 0usize) & 0x01;
410 val != 0
411 }
412 #[doc = "Firewall disable"]
413 pub fn set_fwdis(&mut self, val: bool) {
414 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
415 }
416 #[doc = "I/O analog switch voltage booster enable"]
417 pub const fn boosten(&self) -> bool {
418 let val = (self.0 >> 8usize) & 0x01;
419 val != 0
420 }
421 #[doc = "I/O analog switch voltage booster enable"]
422 pub fn set_boosten(&mut self, val: bool) {
423 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
424 }
425 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB6"]
426 pub const fn i2c_pb6_fmp(&self) -> bool {
427 let val = (self.0 >> 16usize) & 0x01;
428 val != 0
429 }
430 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB6"]
431 pub fn set_i2c_pb6_fmp(&mut self, val: bool) {
432 self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
433 }
434 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB7"]
435 pub const fn i2c_pb7_fmp(&self) -> bool {
436 let val = (self.0 >> 17usize) & 0x01;
437 val != 0
438 }
439 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB7"]
440 pub fn set_i2c_pb7_fmp(&mut self, val: bool) {
441 self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
442 }
443 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB8"]
444 pub const fn i2c_pb8_fmp(&self) -> bool {
445 let val = (self.0 >> 18usize) & 0x01;
446 val != 0
447 }
448 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB8"]
449 pub fn set_i2c_pb8_fmp(&mut self, val: bool) {
450 self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize);
451 }
452 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB9"]
453 pub const fn i2c_pb9_fmp(&self) -> bool {
454 let val = (self.0 >> 19usize) & 0x01;
455 val != 0
456 }
457 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB9"]
458 pub fn set_i2c_pb9_fmp(&mut self, val: bool) {
459 self.0 = (self.0 & !(0x01 << 19usize)) | (((val as u32) & 0x01) << 19usize);
460 }
461 #[doc = "I2C1 Fast-mode Plus driving capability activation"]
462 pub const fn i2c1_fmp(&self) -> bool {
463 let val = (self.0 >> 20usize) & 0x01;
464 val != 0
465 }
466 #[doc = "I2C1 Fast-mode Plus driving capability activation"]
467 pub fn set_i2c1_fmp(&mut self, val: bool) {
468 self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize);
469 }
470 #[doc = "I2C2 Fast-mode Plus driving capability activation"]
471 pub const fn i2c2_fmp(&self) -> bool {
472 let val = (self.0 >> 21usize) & 0x01;
473 val != 0
474 }
475 #[doc = "I2C2 Fast-mode Plus driving capability activation"]
476 pub fn set_i2c2_fmp(&mut self, val: bool) {
477 self.0 = (self.0 & !(0x01 << 21usize)) | (((val as u32) & 0x01) << 21usize);
478 }
479 #[doc = "I2C3 Fast-mode Plus driving capability activation"]
480 pub const fn i2c3_fmp(&self) -> bool {
481 let val = (self.0 >> 22usize) & 0x01;
482 val != 0
483 }
484 #[doc = "I2C3 Fast-mode Plus driving capability activation"]
485 pub fn set_i2c3_fmp(&mut self, val: bool) {
486 self.0 = (self.0 & !(0x01 << 22usize)) | (((val as u32) & 0x01) << 22usize);
487 }
488 #[doc = "Floating Point Unit interrupts enable bits"]
489 pub const fn fpu_ie(&self) -> u8 {
490 let val = (self.0 >> 26usize) & 0x3f;
491 val as u8
492 }
493 #[doc = "Floating Point Unit interrupts enable bits"]
494 pub fn set_fpu_ie(&mut self, val: u8) {
495 self.0 = (self.0 & !(0x3f << 26usize)) | (((val as u32) & 0x3f) << 26usize);
496 }
497 }
498 impl Default for Cfgr1 {
499 fn default() -> Cfgr1 {
500 Cfgr1(0)
501 }
502 }
503 }
504}
3pub mod exti_v1 { 505pub mod exti_v1 {
4 use crate::generic::*; 506 use crate::generic::*;
5 #[doc = "External interrupt/event controller"] 507 #[doc = "External interrupt/event controller"]
@@ -37,6 +539,15 @@ pub mod exti_v1 {
37 use crate::generic::*; 539 use crate::generic::*;
38 #[repr(transparent)] 540 #[repr(transparent)]
39 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 541 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
542 pub struct Mr(pub u8);
543 impl Mr {
544 #[doc = "Interrupt request line is masked"]
545 pub const MASKED: Self = Self(0);
546 #[doc = "Interrupt request line is unmasked"]
547 pub const UNMASKED: Self = Self(0x01);
548 }
549 #[repr(transparent)]
550 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
40 pub struct Prw(pub u8); 551 pub struct Prw(pub u8);
41 impl Prw { 552 impl Prw {
42 #[doc = "Clears pending bit"] 553 #[doc = "Clears pending bit"]
@@ -51,15 +562,6 @@ pub mod exti_v1 {
51 } 562 }
52 #[repr(transparent)] 563 #[repr(transparent)]
53 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 564 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
54 pub struct Mr(pub u8);
55 impl Mr {
56 #[doc = "Interrupt request line is masked"]
57 pub const MASKED: Self = Self(0);
58 #[doc = "Interrupt request line is unmasked"]
59 pub const UNMASKED: Self = Self(0x01);
60 }
61 #[repr(transparent)]
62 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
63 pub struct Tr(pub u8); 565 pub struct Tr(pub u8);
64 impl Tr { 566 impl Tr {
65 #[doc = "Falling edge trigger is disabled"] 567 #[doc = "Falling edge trigger is disabled"]
@@ -103,52 +605,52 @@ pub mod exti_v1 {
103 Rtsr(0) 605 Rtsr(0)
104 } 606 }
105 } 607 }
106 #[doc = "Falling Trigger selection register (EXTI_FTSR)"] 608 #[doc = "Event mask register (EXTI_EMR)"]
107 #[repr(transparent)] 609 #[repr(transparent)]
108 #[derive(Copy, Clone, Eq, PartialEq)] 610 #[derive(Copy, Clone, Eq, PartialEq)]
109 pub struct Ftsr(pub u32); 611 pub struct Emr(pub u32);
110 impl Ftsr { 612 impl Emr {
111 #[doc = "Falling trigger event configuration of line 0"] 613 #[doc = "Event Mask on line 0"]
112 pub fn tr(&self, n: usize) -> super::vals::Tr { 614 pub fn mr(&self, n: usize) -> super::vals::Mr {
113 assert!(n < 23usize); 615 assert!(n < 23usize);
114 let offs = 0usize + n * 1usize; 616 let offs = 0usize + n * 1usize;
115 let val = (self.0 >> offs) & 0x01; 617 let val = (self.0 >> offs) & 0x01;
116 super::vals::Tr(val as u8) 618 super::vals::Mr(val as u8)
117 } 619 }
118 #[doc = "Falling trigger event configuration of line 0"] 620 #[doc = "Event Mask on line 0"]
119 pub fn set_tr(&mut self, n: usize, val: super::vals::Tr) { 621 pub fn set_mr(&mut self, n: usize, val: super::vals::Mr) {
120 assert!(n < 23usize); 622 assert!(n < 23usize);
121 let offs = 0usize + n * 1usize; 623 let offs = 0usize + n * 1usize;
122 self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); 624 self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs);
123 } 625 }
124 } 626 }
125 impl Default for Ftsr { 627 impl Default for Emr {
126 fn default() -> Ftsr { 628 fn default() -> Emr {
127 Ftsr(0) 629 Emr(0)
128 } 630 }
129 } 631 }
130 #[doc = "Pending register (EXTI_PR)"] 632 #[doc = "Falling Trigger selection register (EXTI_FTSR)"]
131 #[repr(transparent)] 633 #[repr(transparent)]
132 #[derive(Copy, Clone, Eq, PartialEq)] 634 #[derive(Copy, Clone, Eq, PartialEq)]
133 pub struct Pr(pub u32); 635 pub struct Ftsr(pub u32);
134 impl Pr { 636 impl Ftsr {
135 #[doc = "Pending bit 0"] 637 #[doc = "Falling trigger event configuration of line 0"]
136 pub fn pr(&self, n: usize) -> bool { 638 pub fn tr(&self, n: usize) -> super::vals::Tr {
137 assert!(n < 23usize); 639 assert!(n < 23usize);
138 let offs = 0usize + n * 1usize; 640 let offs = 0usize + n * 1usize;
139 let val = (self.0 >> offs) & 0x01; 641 let val = (self.0 >> offs) & 0x01;
140 val != 0 642 super::vals::Tr(val as u8)
141 } 643 }
142 #[doc = "Pending bit 0"] 644 #[doc = "Falling trigger event configuration of line 0"]
143 pub fn set_pr(&mut self, n: usize, val: bool) { 645 pub fn set_tr(&mut self, n: usize, val: super::vals::Tr) {
144 assert!(n < 23usize); 646 assert!(n < 23usize);
145 let offs = 0usize + n * 1usize; 647 let offs = 0usize + n * 1usize;
146 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); 648 self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs);
147 } 649 }
148 } 650 }
149 impl Default for Pr { 651 impl Default for Ftsr {
150 fn default() -> Pr { 652 fn default() -> Ftsr {
151 Pr(0) 653 Ftsr(0)
152 } 654 }
153 } 655 }
154 #[doc = "Software interrupt event register (EXTI_SWIER)"] 656 #[doc = "Software interrupt event register (EXTI_SWIER)"]
@@ -175,223 +677,432 @@ pub mod exti_v1 {
175 Swier(0) 677 Swier(0)
176 } 678 }
177 } 679 }
178 #[doc = "Interrupt mask register (EXTI_IMR)"] 680 #[doc = "Pending register (EXTI_PR)"]
179 #[repr(transparent)] 681 #[repr(transparent)]
180 #[derive(Copy, Clone, Eq, PartialEq)] 682 #[derive(Copy, Clone, Eq, PartialEq)]
181 pub struct Imr(pub u32); 683 pub struct Pr(pub u32);
182 impl Imr { 684 impl Pr {
183 #[doc = "Interrupt Mask on line 0"] 685 #[doc = "Pending bit 0"]
184 pub fn mr(&self, n: usize) -> super::vals::Mr { 686 pub fn pr(&self, n: usize) -> bool {
185 assert!(n < 23usize); 687 assert!(n < 23usize);
186 let offs = 0usize + n * 1usize; 688 let offs = 0usize + n * 1usize;
187 let val = (self.0 >> offs) & 0x01; 689 let val = (self.0 >> offs) & 0x01;
188 super::vals::Mr(val as u8) 690 val != 0
189 } 691 }
190 #[doc = "Interrupt Mask on line 0"] 692 #[doc = "Pending bit 0"]
191 pub fn set_mr(&mut self, n: usize, val: super::vals::Mr) { 693 pub fn set_pr(&mut self, n: usize, val: bool) {
192 assert!(n < 23usize); 694 assert!(n < 23usize);
193 let offs = 0usize + n * 1usize; 695 let offs = 0usize + n * 1usize;
194 self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); 696 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
195 } 697 }
196 } 698 }
197 impl Default for Imr { 699 impl Default for Pr {
198 fn default() -> Imr { 700 fn default() -> Pr {
199 Imr(0) 701 Pr(0)
200 } 702 }
201 } 703 }
202 #[doc = "Event mask register (EXTI_EMR)"] 704 #[doc = "Interrupt mask register (EXTI_IMR)"]
203 #[repr(transparent)] 705 #[repr(transparent)]
204 #[derive(Copy, Clone, Eq, PartialEq)] 706 #[derive(Copy, Clone, Eq, PartialEq)]
205 pub struct Emr(pub u32); 707 pub struct Imr(pub u32);
206 impl Emr { 708 impl Imr {
207 #[doc = "Event Mask on line 0"] 709 #[doc = "Interrupt Mask on line 0"]
208 pub fn mr(&self, n: usize) -> super::vals::Mr { 710 pub fn mr(&self, n: usize) -> super::vals::Mr {
209 assert!(n < 23usize); 711 assert!(n < 23usize);
210 let offs = 0usize + n * 1usize; 712 let offs = 0usize + n * 1usize;
211 let val = (self.0 >> offs) & 0x01; 713 let val = (self.0 >> offs) & 0x01;
212 super::vals::Mr(val as u8) 714 super::vals::Mr(val as u8)
213 } 715 }
214 #[doc = "Event Mask on line 0"] 716 #[doc = "Interrupt Mask on line 0"]
215 pub fn set_mr(&mut self, n: usize, val: super::vals::Mr) { 717 pub fn set_mr(&mut self, n: usize, val: super::vals::Mr) {
216 assert!(n < 23usize); 718 assert!(n < 23usize);
217 let offs = 0usize + n * 1usize; 719 let offs = 0usize + n * 1usize;
218 self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); 720 self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs);
219 } 721 }
220 } 722 }
221 impl Default for Emr { 723 impl Default for Imr {
222 fn default() -> Emr { 724 fn default() -> Imr {
223 Emr(0) 725 Imr(0)
224 } 726 }
225 } 727 }
226 } 728 }
227} 729}
228pub mod syscfg_f4 { 730pub mod dma_v1 {
229 use crate::generic::*; 731 use crate::generic::*;
230 #[doc = "System configuration controller"] 732 #[doc = "DMA controller"]
231 #[derive(Copy, Clone)] 733 #[derive(Copy, Clone)]
232 pub struct Syscfg(pub *mut u8); 734 pub struct Dma(pub *mut u8);
233 unsafe impl Send for Syscfg {} 735 unsafe impl Send for Dma {}
234 unsafe impl Sync for Syscfg {} 736 unsafe impl Sync for Dma {}
235 impl Syscfg { 737 impl Dma {
236 #[doc = "memory remap register"] 738 #[doc = "DMA interrupt status register (DMA_ISR)"]
237 pub fn memrm(self) -> Reg<regs::Memrm, RW> { 739 pub fn isr(self) -> Reg<regs::Isr, R> {
238 unsafe { Reg::from_ptr(self.0.add(0usize)) } 740 unsafe { Reg::from_ptr(self.0.add(0usize)) }
239 } 741 }
240 #[doc = "peripheral mode configuration register"] 742 #[doc = "DMA interrupt flag clear register (DMA_IFCR)"]
241 pub fn pmc(self) -> Reg<regs::Pmc, RW> { 743 pub fn ifcr(self) -> Reg<regs::Ifcr, W> {
242 unsafe { Reg::from_ptr(self.0.add(4usize)) } 744 unsafe { Reg::from_ptr(self.0.add(4usize)) }
243 } 745 }
244 #[doc = "external interrupt configuration register"] 746 #[doc = "Channel cluster: CCR?, CNDTR?, CPAR?, and CMAR? registers"]
245 pub fn exticr(self, n: usize) -> Reg<regs::Exticr, RW> { 747 pub fn ch(self, n: usize) -> Ch {
246 assert!(n < 4usize); 748 assert!(n < 7usize);
247 unsafe { Reg::from_ptr(self.0.add(8usize + n * 4usize)) } 749 unsafe { Ch(self.0.add(8usize + n * 20usize)) }
248 } 750 }
249 #[doc = "Compensation cell control register"] 751 }
250 pub fn cmpcr(self) -> Reg<regs::Cmpcr, R> { 752 #[doc = "Channel cluster: CCR?, CNDTR?, CPAR?, and CMAR? registers"]
251 unsafe { Reg::from_ptr(self.0.add(32usize)) } 753 #[derive(Copy, Clone)]
754 pub struct Ch(pub *mut u8);
755 unsafe impl Send for Ch {}
756 unsafe impl Sync for Ch {}
757 impl Ch {
758 #[doc = "DMA channel configuration register (DMA_CCR)"]
759 pub fn cr(self) -> Reg<regs::Cr, RW> {
760 unsafe { Reg::from_ptr(self.0.add(0usize)) }
761 }
762 #[doc = "DMA channel 1 number of data register"]
763 pub fn ndtr(self) -> Reg<regs::Ndtr, RW> {
764 unsafe { Reg::from_ptr(self.0.add(4usize)) }
765 }
766 #[doc = "DMA channel 1 peripheral address register"]
767 pub fn par(self) -> Reg<u32, RW> {
768 unsafe { Reg::from_ptr(self.0.add(8usize)) }
769 }
770 #[doc = "DMA channel 1 memory address register"]
771 pub fn mar(self) -> Reg<u32, RW> {
772 unsafe { Reg::from_ptr(self.0.add(12usize)) }
252 } 773 }
253 } 774 }
254 pub mod regs { 775 pub mod regs {
255 use crate::generic::*; 776 use crate::generic::*;
256 #[doc = "peripheral mode configuration register"] 777 #[doc = "DMA interrupt status register (DMA_ISR)"]
257 #[repr(transparent)] 778 #[repr(transparent)]
258 #[derive(Copy, Clone, Eq, PartialEq)] 779 #[derive(Copy, Clone, Eq, PartialEq)]
259 pub struct Pmc(pub u32); 780 pub struct Isr(pub u32);
260 impl Pmc { 781 impl Isr {
261 #[doc = "ADC1DC2"] 782 #[doc = "Channel 1 Global interrupt flag"]
262 pub const fn adc1dc2(&self) -> bool { 783 pub fn gif(&self, n: usize) -> bool {
263 let val = (self.0 >> 16usize) & 0x01; 784 assert!(n < 7usize);
785 let offs = 0usize + n * 4usize;
786 let val = (self.0 >> offs) & 0x01;
264 val != 0 787 val != 0
265 } 788 }
266 #[doc = "ADC1DC2"] 789 #[doc = "Channel 1 Global interrupt flag"]
267 pub fn set_adc1dc2(&mut self, val: bool) { 790 pub fn set_gif(&mut self, n: usize, val: bool) {
268 self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize); 791 assert!(n < 7usize);
792 let offs = 0usize + n * 4usize;
793 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
269 } 794 }
270 #[doc = "ADC2DC2"] 795 #[doc = "Channel 1 Transfer Complete flag"]
271 pub const fn adc2dc2(&self) -> bool { 796 pub fn tcif(&self, n: usize) -> bool {
272 let val = (self.0 >> 17usize) & 0x01; 797 assert!(n < 7usize);
798 let offs = 1usize + n * 4usize;
799 let val = (self.0 >> offs) & 0x01;
273 val != 0 800 val != 0
274 } 801 }
275 #[doc = "ADC2DC2"] 802 #[doc = "Channel 1 Transfer Complete flag"]
276 pub fn set_adc2dc2(&mut self, val: bool) { 803 pub fn set_tcif(&mut self, n: usize, val: bool) {
277 self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize); 804 assert!(n < 7usize);
805 let offs = 1usize + n * 4usize;
806 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
278 } 807 }
279 #[doc = "ADC3DC2"] 808 #[doc = "Channel 1 Half Transfer Complete flag"]
280 pub const fn adc3dc2(&self) -> bool { 809 pub fn htif(&self, n: usize) -> bool {
281 let val = (self.0 >> 18usize) & 0x01; 810 assert!(n < 7usize);
811 let offs = 2usize + n * 4usize;
812 let val = (self.0 >> offs) & 0x01;
282 val != 0 813 val != 0
283 } 814 }
284 #[doc = "ADC3DC2"] 815 #[doc = "Channel 1 Half Transfer Complete flag"]
285 pub fn set_adc3dc2(&mut self, val: bool) { 816 pub fn set_htif(&mut self, n: usize, val: bool) {
286 self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize); 817 assert!(n < 7usize);
818 let offs = 2usize + n * 4usize;
819 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
287 } 820 }
288 #[doc = "Ethernet PHY interface selection"] 821 #[doc = "Channel 1 Transfer Error flag"]
289 pub const fn mii_rmii_sel(&self) -> bool { 822 pub fn teif(&self, n: usize) -> bool {
290 let val = (self.0 >> 23usize) & 0x01; 823 assert!(n < 7usize);
824 let offs = 3usize + n * 4usize;
825 let val = (self.0 >> offs) & 0x01;
291 val != 0 826 val != 0
292 } 827 }
293 #[doc = "Ethernet PHY interface selection"] 828 #[doc = "Channel 1 Transfer Error flag"]
294 pub fn set_mii_rmii_sel(&mut self, val: bool) { 829 pub fn set_teif(&mut self, n: usize, val: bool) {
295 self.0 = (self.0 & !(0x01 << 23usize)) | (((val as u32) & 0x01) << 23usize); 830 assert!(n < 7usize);
831 let offs = 3usize + n * 4usize;
832 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
296 } 833 }
297 } 834 }
298 impl Default for Pmc { 835 impl Default for Isr {
299 fn default() -> Pmc { 836 fn default() -> Isr {
300 Pmc(0) 837 Isr(0)
301 } 838 }
302 } 839 }
303 #[doc = "Compensation cell control register"] 840 #[doc = "DMA channel configuration register (DMA_CCR)"]
304 #[repr(transparent)] 841 #[repr(transparent)]
305 #[derive(Copy, Clone, Eq, PartialEq)] 842 #[derive(Copy, Clone, Eq, PartialEq)]
306 pub struct Cmpcr(pub u32); 843 pub struct Cr(pub u32);
307 impl Cmpcr { 844 impl Cr {
308 #[doc = "Compensation cell power-down"] 845 #[doc = "Channel enable"]
309 pub const fn cmp_pd(&self) -> bool { 846 pub const fn en(&self) -> bool {
310 let val = (self.0 >> 0usize) & 0x01; 847 let val = (self.0 >> 0usize) & 0x01;
311 val != 0 848 val != 0
312 } 849 }
313 #[doc = "Compensation cell power-down"] 850 #[doc = "Channel enable"]
314 pub fn set_cmp_pd(&mut self, val: bool) { 851 pub fn set_en(&mut self, val: bool) {
315 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); 852 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
316 } 853 }
317 #[doc = "READY"] 854 #[doc = "Transfer complete interrupt enable"]
318 pub const fn ready(&self) -> bool { 855 pub const fn tcie(&self) -> bool {
319 let val = (self.0 >> 8usize) & 0x01; 856 let val = (self.0 >> 1usize) & 0x01;
320 val != 0 857 val != 0
321 } 858 }
322 #[doc = "READY"] 859 #[doc = "Transfer complete interrupt enable"]
323 pub fn set_ready(&mut self, val: bool) { 860 pub fn set_tcie(&mut self, val: bool) {
324 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); 861 self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
862 }
863 #[doc = "Half Transfer interrupt enable"]
864 pub const fn htie(&self) -> bool {
865 let val = (self.0 >> 2usize) & 0x01;
866 val != 0
867 }
868 #[doc = "Half Transfer interrupt enable"]
869 pub fn set_htie(&mut self, val: bool) {
870 self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
871 }
872 #[doc = "Transfer error interrupt enable"]
873 pub const fn teie(&self) -> bool {
874 let val = (self.0 >> 3usize) & 0x01;
875 val != 0
876 }
877 #[doc = "Transfer error interrupt enable"]
878 pub fn set_teie(&mut self, val: bool) {
879 self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
880 }
881 #[doc = "Data transfer direction"]
882 pub const fn dir(&self) -> super::vals::Dir {
883 let val = (self.0 >> 4usize) & 0x01;
884 super::vals::Dir(val as u8)
885 }
886 #[doc = "Data transfer direction"]
887 pub fn set_dir(&mut self, val: super::vals::Dir) {
888 self.0 = (self.0 & !(0x01 << 4usize)) | (((val.0 as u32) & 0x01) << 4usize);
889 }
890 #[doc = "Circular mode"]
891 pub const fn circ(&self) -> super::vals::Circ {
892 let val = (self.0 >> 5usize) & 0x01;
893 super::vals::Circ(val as u8)
894 }
895 #[doc = "Circular mode"]
896 pub fn set_circ(&mut self, val: super::vals::Circ) {
897 self.0 = (self.0 & !(0x01 << 5usize)) | (((val.0 as u32) & 0x01) << 5usize);
898 }
899 #[doc = "Peripheral increment mode"]
900 pub const fn pinc(&self) -> super::vals::Inc {
901 let val = (self.0 >> 6usize) & 0x01;
902 super::vals::Inc(val as u8)
903 }
904 #[doc = "Peripheral increment mode"]
905 pub fn set_pinc(&mut self, val: super::vals::Inc) {
906 self.0 = (self.0 & !(0x01 << 6usize)) | (((val.0 as u32) & 0x01) << 6usize);
907 }
908 #[doc = "Memory increment mode"]
909 pub const fn minc(&self) -> super::vals::Inc {
910 let val = (self.0 >> 7usize) & 0x01;
911 super::vals::Inc(val as u8)
912 }
913 #[doc = "Memory increment mode"]
914 pub fn set_minc(&mut self, val: super::vals::Inc) {
915 self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize);
916 }
917 #[doc = "Peripheral size"]
918 pub const fn psize(&self) -> super::vals::Size {
919 let val = (self.0 >> 8usize) & 0x03;
920 super::vals::Size(val as u8)
921 }
922 #[doc = "Peripheral size"]
923 pub fn set_psize(&mut self, val: super::vals::Size) {
924 self.0 = (self.0 & !(0x03 << 8usize)) | (((val.0 as u32) & 0x03) << 8usize);
925 }
926 #[doc = "Memory size"]
927 pub const fn msize(&self) -> super::vals::Size {
928 let val = (self.0 >> 10usize) & 0x03;
929 super::vals::Size(val as u8)
930 }
931 #[doc = "Memory size"]
932 pub fn set_msize(&mut self, val: super::vals::Size) {
933 self.0 = (self.0 & !(0x03 << 10usize)) | (((val.0 as u32) & 0x03) << 10usize);
934 }
935 #[doc = "Channel Priority level"]
936 pub const fn pl(&self) -> super::vals::Pl {
937 let val = (self.0 >> 12usize) & 0x03;
938 super::vals::Pl(val as u8)
939 }
940 #[doc = "Channel Priority level"]
941 pub fn set_pl(&mut self, val: super::vals::Pl) {
942 self.0 = (self.0 & !(0x03 << 12usize)) | (((val.0 as u32) & 0x03) << 12usize);
943 }
944 #[doc = "Memory to memory mode"]
945 pub const fn mem2mem(&self) -> super::vals::Memmem {
946 let val = (self.0 >> 14usize) & 0x01;
947 super::vals::Memmem(val as u8)
948 }
949 #[doc = "Memory to memory mode"]
950 pub fn set_mem2mem(&mut self, val: super::vals::Memmem) {
951 self.0 = (self.0 & !(0x01 << 14usize)) | (((val.0 as u32) & 0x01) << 14usize);
325 } 952 }
326 } 953 }
327 impl Default for Cmpcr { 954 impl Default for Cr {
328 fn default() -> Cmpcr { 955 fn default() -> Cr {
329 Cmpcr(0) 956 Cr(0)
330 } 957 }
331 } 958 }
332 #[doc = "external interrupt configuration register"] 959 #[doc = "DMA interrupt flag clear register (DMA_IFCR)"]
333 #[repr(transparent)] 960 #[repr(transparent)]
334 #[derive(Copy, Clone, Eq, PartialEq)] 961 #[derive(Copy, Clone, Eq, PartialEq)]
335 pub struct Exticr(pub u32); 962 pub struct Ifcr(pub u32);
336 impl Exticr { 963 impl Ifcr {
337 #[doc = "EXTI x configuration"] 964 #[doc = "Channel 1 Global interrupt clear"]
338 pub fn exti(&self, n: usize) -> u8 { 965 pub fn cgif(&self, n: usize) -> bool {
339 assert!(n < 4usize); 966 assert!(n < 7usize);
340 let offs = 0usize + n * 4usize; 967 let offs = 0usize + n * 4usize;
341 let val = (self.0 >> offs) & 0x0f; 968 let val = (self.0 >> offs) & 0x01;
342 val as u8 969 val != 0
343 } 970 }
344 #[doc = "EXTI x configuration"] 971 #[doc = "Channel 1 Global interrupt clear"]
345 pub fn set_exti(&mut self, n: usize, val: u8) { 972 pub fn set_cgif(&mut self, n: usize, val: bool) {
346 assert!(n < 4usize); 973 assert!(n < 7usize);
347 let offs = 0usize + n * 4usize; 974 let offs = 0usize + n * 4usize;
348 self.0 = (self.0 & !(0x0f << offs)) | (((val as u32) & 0x0f) << offs); 975 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
349 } 976 }
350 } 977 #[doc = "Channel 1 Transfer Complete clear"]
351 impl Default for Exticr { 978 pub fn ctcif(&self, n: usize) -> bool {
352 fn default() -> Exticr { 979 assert!(n < 7usize);
353 Exticr(0) 980 let offs = 1usize + n * 4usize;
981 let val = (self.0 >> offs) & 0x01;
982 val != 0
354 } 983 }
355 } 984 #[doc = "Channel 1 Transfer Complete clear"]
356 #[doc = "memory remap register"] 985 pub fn set_ctcif(&mut self, n: usize, val: bool) {
357 #[repr(transparent)] 986 assert!(n < 7usize);
358 #[derive(Copy, Clone, Eq, PartialEq)] 987 let offs = 1usize + n * 4usize;
359 pub struct Memrm(pub u32); 988 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
360 impl Memrm {
361 #[doc = "Memory mapping selection"]
362 pub const fn mem_mode(&self) -> u8 {
363 let val = (self.0 >> 0usize) & 0x07;
364 val as u8
365 } 989 }
366 #[doc = "Memory mapping selection"] 990 #[doc = "Channel 1 Half Transfer clear"]
367 pub fn set_mem_mode(&mut self, val: u8) { 991 pub fn chtif(&self, n: usize) -> bool {
368 self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize); 992 assert!(n < 7usize);
993 let offs = 2usize + n * 4usize;
994 let val = (self.0 >> offs) & 0x01;
995 val != 0
369 } 996 }
370 #[doc = "Flash bank mode selection"] 997 #[doc = "Channel 1 Half Transfer clear"]
371 pub const fn fb_mode(&self) -> bool { 998 pub fn set_chtif(&mut self, n: usize, val: bool) {
372 let val = (self.0 >> 8usize) & 0x01; 999 assert!(n < 7usize);
1000 let offs = 2usize + n * 4usize;
1001 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
1002 }
1003 #[doc = "Channel 1 Transfer Error clear"]
1004 pub fn cteif(&self, n: usize) -> bool {
1005 assert!(n < 7usize);
1006 let offs = 3usize + n * 4usize;
1007 let val = (self.0 >> offs) & 0x01;
373 val != 0 1008 val != 0
374 } 1009 }
375 #[doc = "Flash bank mode selection"] 1010 #[doc = "Channel 1 Transfer Error clear"]
376 pub fn set_fb_mode(&mut self, val: bool) { 1011 pub fn set_cteif(&mut self, n: usize, val: bool) {
377 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); 1012 assert!(n < 7usize);
1013 let offs = 3usize + n * 4usize;
1014 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
378 } 1015 }
379 #[doc = "FMC memory mapping swap"] 1016 }
380 pub const fn swp_fmc(&self) -> u8 { 1017 impl Default for Ifcr {
381 let val = (self.0 >> 10usize) & 0x03; 1018 fn default() -> Ifcr {
382 val as u8 1019 Ifcr(0)
383 } 1020 }
384 #[doc = "FMC memory mapping swap"] 1021 }
385 pub fn set_swp_fmc(&mut self, val: u8) { 1022 #[doc = "DMA channel 1 number of data register"]
386 self.0 = (self.0 & !(0x03 << 10usize)) | (((val as u32) & 0x03) << 10usize); 1023 #[repr(transparent)]
1024 #[derive(Copy, Clone, Eq, PartialEq)]
1025 pub struct Ndtr(pub u32);
1026 impl Ndtr {
1027 #[doc = "Number of data to transfer"]
1028 pub const fn ndt(&self) -> u16 {
1029 let val = (self.0 >> 0usize) & 0xffff;
1030 val as u16
1031 }
1032 #[doc = "Number of data to transfer"]
1033 pub fn set_ndt(&mut self, val: u16) {
1034 self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
387 } 1035 }
388 } 1036 }
389 impl Default for Memrm { 1037 impl Default for Ndtr {
390 fn default() -> Memrm { 1038 fn default() -> Ndtr {
391 Memrm(0) 1039 Ndtr(0)
392 } 1040 }
393 } 1041 }
394 } 1042 }
1043 pub mod vals {
1044 use crate::generic::*;
1045 #[repr(transparent)]
1046 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1047 pub struct Inc(pub u8);
1048 impl Inc {
1049 #[doc = "Increment mode disabled"]
1050 pub const DISABLED: Self = Self(0);
1051 #[doc = "Increment mode enabled"]
1052 pub const ENABLED: Self = Self(0x01);
1053 }
1054 #[repr(transparent)]
1055 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1056 pub struct Pl(pub u8);
1057 impl Pl {
1058 #[doc = "Low priority"]
1059 pub const LOW: Self = Self(0);
1060 #[doc = "Medium priority"]
1061 pub const MEDIUM: Self = Self(0x01);
1062 #[doc = "High priority"]
1063 pub const HIGH: Self = Self(0x02);
1064 #[doc = "Very high priority"]
1065 pub const VERYHIGH: Self = Self(0x03);
1066 }
1067 #[repr(transparent)]
1068 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1069 pub struct Circ(pub u8);
1070 impl Circ {
1071 #[doc = "Circular buffer disabled"]
1072 pub const DISABLED: Self = Self(0);
1073 #[doc = "Circular buffer enabled"]
1074 pub const ENABLED: Self = Self(0x01);
1075 }
1076 #[repr(transparent)]
1077 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1078 pub struct Dir(pub u8);
1079 impl Dir {
1080 #[doc = "Read from peripheral"]
1081 pub const FROMPERIPHERAL: Self = Self(0);
1082 #[doc = "Read from memory"]
1083 pub const FROMMEMORY: Self = Self(0x01);
1084 }
1085 #[repr(transparent)]
1086 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1087 pub struct Memmem(pub u8);
1088 impl Memmem {
1089 #[doc = "Memory to memory mode disabled"]
1090 pub const DISABLED: Self = Self(0);
1091 #[doc = "Memory to memory mode enabled"]
1092 pub const ENABLED: Self = Self(0x01);
1093 }
1094 #[repr(transparent)]
1095 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1096 pub struct Size(pub u8);
1097 impl Size {
1098 #[doc = "8-bit size"]
1099 pub const BITS8: Self = Self(0);
1100 #[doc = "16-bit size"]
1101 pub const BITS16: Self = Self(0x01);
1102 #[doc = "32-bit size"]
1103 pub const BITS32: Self = Self(0x02);
1104 }
1105 }
395} 1106}
396pub mod generic { 1107pub mod generic {
397 use core::marker::PhantomData; 1108 use core::marker::PhantomData;
@@ -463,6 +1174,116 @@ pub mod generic {
463 } 1174 }
464 } 1175 }
465} 1176}
1177pub mod rng_v1 {
1178 use crate::generic::*;
1179 #[doc = "Random number generator"]
1180 #[derive(Copy, Clone)]
1181 pub struct Rng(pub *mut u8);
1182 unsafe impl Send for Rng {}
1183 unsafe impl Sync for Rng {}
1184 impl Rng {
1185 #[doc = "control register"]
1186 pub fn cr(self) -> Reg<regs::Cr, RW> {
1187 unsafe { Reg::from_ptr(self.0.add(0usize)) }
1188 }
1189 #[doc = "status register"]
1190 pub fn sr(self) -> Reg<regs::Sr, RW> {
1191 unsafe { Reg::from_ptr(self.0.add(4usize)) }
1192 }
1193 #[doc = "data register"]
1194 pub fn dr(self) -> Reg<u32, R> {
1195 unsafe { Reg::from_ptr(self.0.add(8usize)) }
1196 }
1197 }
1198 pub mod regs {
1199 use crate::generic::*;
1200 #[doc = "status register"]
1201 #[repr(transparent)]
1202 #[derive(Copy, Clone, Eq, PartialEq)]
1203 pub struct Sr(pub u32);
1204 impl Sr {
1205 #[doc = "Data ready"]
1206 pub const fn drdy(&self) -> bool {
1207 let val = (self.0 >> 0usize) & 0x01;
1208 val != 0
1209 }
1210 #[doc = "Data ready"]
1211 pub fn set_drdy(&mut self, val: bool) {
1212 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
1213 }
1214 #[doc = "Clock error current status"]
1215 pub const fn cecs(&self) -> bool {
1216 let val = (self.0 >> 1usize) & 0x01;
1217 val != 0
1218 }
1219 #[doc = "Clock error current status"]
1220 pub fn set_cecs(&mut self, val: bool) {
1221 self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
1222 }
1223 #[doc = "Seed error current status"]
1224 pub const fn secs(&self) -> bool {
1225 let val = (self.0 >> 2usize) & 0x01;
1226 val != 0
1227 }
1228 #[doc = "Seed error current status"]
1229 pub fn set_secs(&mut self, val: bool) {
1230 self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
1231 }
1232 #[doc = "Clock error interrupt status"]
1233 pub const fn ceis(&self) -> bool {
1234 let val = (self.0 >> 5usize) & 0x01;
1235 val != 0
1236 }
1237 #[doc = "Clock error interrupt status"]
1238 pub fn set_ceis(&mut self, val: bool) {
1239 self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
1240 }
1241 #[doc = "Seed error interrupt status"]
1242 pub const fn seis(&self) -> bool {
1243 let val = (self.0 >> 6usize) & 0x01;
1244 val != 0
1245 }
1246 #[doc = "Seed error interrupt status"]
1247 pub fn set_seis(&mut self, val: bool) {
1248 self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
1249 }
1250 }
1251 impl Default for Sr {
1252 fn default() -> Sr {
1253 Sr(0)
1254 }
1255 }
1256 #[doc = "control register"]
1257 #[repr(transparent)]
1258 #[derive(Copy, Clone, Eq, PartialEq)]
1259 pub struct Cr(pub u32);
1260 impl Cr {
1261 #[doc = "Random number generator enable"]
1262 pub const fn rngen(&self) -> bool {
1263 let val = (self.0 >> 2usize) & 0x01;
1264 val != 0
1265 }
1266 #[doc = "Random number generator enable"]
1267 pub fn set_rngen(&mut self, val: bool) {
1268 self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
1269 }
1270 #[doc = "Interrupt enable"]
1271 pub const fn ie(&self) -> bool {
1272 let val = (self.0 >> 3usize) & 0x01;
1273 val != 0
1274 }
1275 #[doc = "Interrupt enable"]
1276 pub fn set_ie(&mut self, val: bool) {
1277 self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
1278 }
1279 }
1280 impl Default for Cr {
1281 fn default() -> Cr {
1282 Cr(0)
1283 }
1284 }
1285 }
1286}
466pub mod gpio_v2 { 1287pub mod gpio_v2 {
467 use crate::generic::*; 1288 use crate::generic::*;
468 #[doc = "General-purpose I/Os"] 1289 #[doc = "General-purpose I/Os"]
@@ -509,144 +1330,41 @@ pub mod gpio_v2 {
509 unsafe { Reg::from_ptr(self.0.add(32usize + n * 4usize)) } 1330 unsafe { Reg::from_ptr(self.0.add(32usize + n * 4usize)) }
510 } 1331 }
511 } 1332 }
512 pub mod vals { 1333 pub mod regs {
513 use crate::generic::*; 1334 use crate::generic::*;
1335 #[doc = "GPIO port configuration lock register"]
514 #[repr(transparent)] 1336 #[repr(transparent)]
515 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 1337 #[derive(Copy, Clone, Eq, PartialEq)]
516 pub struct Ot(pub u8); 1338 pub struct Lckr(pub u32);
517 impl Ot { 1339 impl Lckr {
518 #[doc = "Output push-pull (reset state)"] 1340 #[doc = "Port x lock bit y (y= 0..15)"]
519 pub const PUSHPULL: Self = Self(0); 1341 pub fn lck(&self, n: usize) -> super::vals::Lck {
520 #[doc = "Output open-drain"] 1342 assert!(n < 16usize);
521 pub const OPENDRAIN: Self = Self(0x01); 1343 let offs = 0usize + n * 1usize;
522 } 1344 let val = (self.0 >> offs) & 0x01;
523 #[repr(transparent)] 1345 super::vals::Lck(val as u8)
524 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 1346 }
525 pub struct Brw(pub u8); 1347 #[doc = "Port x lock bit y (y= 0..15)"]
526 impl Brw { 1348 pub fn set_lck(&mut self, n: usize, val: super::vals::Lck) {
527 #[doc = "Resets the corresponding ODRx bit"] 1349 assert!(n < 16usize);
528 pub const RESET: Self = Self(0x01); 1350 let offs = 0usize + n * 1usize;
529 } 1351 self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs);
530 #[repr(transparent)] 1352 }
531 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 1353 #[doc = "Port x lock bit y (y= 0..15)"]
532 pub struct Pupdr(pub u8); 1354 pub const fn lckk(&self) -> super::vals::Lckk {
533 impl Pupdr { 1355 let val = (self.0 >> 16usize) & 0x01;
534 #[doc = "No pull-up, pull-down"] 1356 super::vals::Lckk(val as u8)
535 pub const FLOATING: Self = Self(0); 1357 }
536 #[doc = "Pull-up"] 1358 #[doc = "Port x lock bit y (y= 0..15)"]
537 pub const PULLUP: Self = Self(0x01); 1359 pub fn set_lckk(&mut self, val: super::vals::Lckk) {
538 #[doc = "Pull-down"] 1360 self.0 = (self.0 & !(0x01 << 16usize)) | (((val.0 as u32) & 0x01) << 16usize);
539 pub const PULLDOWN: Self = Self(0x02); 1361 }
540 }
541 #[repr(transparent)]
542 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
543 pub struct Moder(pub u8);
544 impl Moder {
545 #[doc = "Input mode (reset state)"]
546 pub const INPUT: Self = Self(0);
547 #[doc = "General purpose output mode"]
548 pub const OUTPUT: Self = Self(0x01);
549 #[doc = "Alternate function mode"]
550 pub const ALTERNATE: Self = Self(0x02);
551 #[doc = "Analog mode"]
552 pub const ANALOG: Self = Self(0x03);
553 }
554 #[repr(transparent)]
555 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
556 pub struct Bsw(pub u8);
557 impl Bsw {
558 #[doc = "Sets the corresponding ODRx bit"]
559 pub const SET: Self = Self(0x01);
560 }
561 #[repr(transparent)]
562 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
563 pub struct Odr(pub u8);
564 impl Odr {
565 #[doc = "Set output to logic low"]
566 pub const LOW: Self = Self(0);
567 #[doc = "Set output to logic high"]
568 pub const HIGH: Self = Self(0x01);
569 }
570 #[repr(transparent)]
571 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
572 pub struct Idr(pub u8);
573 impl Idr {
574 #[doc = "Input is logic low"]
575 pub const LOW: Self = Self(0);
576 #[doc = "Input is logic high"]
577 pub const HIGH: Self = Self(0x01);
578 }
579 #[repr(transparent)]
580 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
581 pub struct Lckk(pub u8);
582 impl Lckk {
583 #[doc = "Port configuration lock key not active"]
584 pub const NOTACTIVE: Self = Self(0);
585 #[doc = "Port configuration lock key active"]
586 pub const ACTIVE: Self = Self(0x01);
587 }
588 #[repr(transparent)]
589 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
590 pub struct Ospeedr(pub u8);
591 impl Ospeedr {
592 #[doc = "Low speed"]
593 pub const LOWSPEED: Self = Self(0);
594 #[doc = "Medium speed"]
595 pub const MEDIUMSPEED: Self = Self(0x01);
596 #[doc = "High speed"]
597 pub const HIGHSPEED: Self = Self(0x02);
598 #[doc = "Very high speed"]
599 pub const VERYHIGHSPEED: Self = Self(0x03);
600 }
601 #[repr(transparent)]
602 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
603 pub struct Afr(pub u8);
604 impl Afr {
605 #[doc = "AF0"]
606 pub const AF0: Self = Self(0);
607 #[doc = "AF1"]
608 pub const AF1: Self = Self(0x01);
609 #[doc = "AF2"]
610 pub const AF2: Self = Self(0x02);
611 #[doc = "AF3"]
612 pub const AF3: Self = Self(0x03);
613 #[doc = "AF4"]
614 pub const AF4: Self = Self(0x04);
615 #[doc = "AF5"]
616 pub const AF5: Self = Self(0x05);
617 #[doc = "AF6"]
618 pub const AF6: Self = Self(0x06);
619 #[doc = "AF7"]
620 pub const AF7: Self = Self(0x07);
621 #[doc = "AF8"]
622 pub const AF8: Self = Self(0x08);
623 #[doc = "AF9"]
624 pub const AF9: Self = Self(0x09);
625 #[doc = "AF10"]
626 pub const AF10: Self = Self(0x0a);
627 #[doc = "AF11"]
628 pub const AF11: Self = Self(0x0b);
629 #[doc = "AF12"]
630 pub const AF12: Self = Self(0x0c);
631 #[doc = "AF13"]
632 pub const AF13: Self = Self(0x0d);
633 #[doc = "AF14"]
634 pub const AF14: Self = Self(0x0e);
635 #[doc = "AF15"]
636 pub const AF15: Self = Self(0x0f);
637 } 1362 }
638 #[repr(transparent)] 1363 impl Default for Lckr {
639 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 1364 fn default() -> Lckr {
640 pub struct Lck(pub u8); 1365 Lckr(0)
641 impl Lck { 1366 }
642 #[doc = "Port configuration not locked"]
643 pub const UNLOCKED: Self = Self(0);
644 #[doc = "Port configuration locked"]
645 pub const LOCKED: Self = Self(0x01);
646 } 1367 }
647 }
648 pub mod regs {
649 use crate::generic::*;
650 #[doc = "GPIO port output data register"] 1368 #[doc = "GPIO port output data register"]
651 #[repr(transparent)] 1369 #[repr(transparent)]
652 #[derive(Copy, Clone, Eq, PartialEq)] 1370 #[derive(Copy, Clone, Eq, PartialEq)]
@@ -671,43 +1389,6 @@ pub mod gpio_v2 {
671 Odr(0) 1389 Odr(0)
672 } 1390 }
673 } 1391 }
674 #[doc = "GPIO port bit set/reset register"]
675 #[repr(transparent)]
676 #[derive(Copy, Clone, Eq, PartialEq)]
677 pub struct Bsrr(pub u32);
678 impl Bsrr {
679 #[doc = "Port x set bit y (y= 0..15)"]
680 pub fn bs(&self, n: usize) -> bool {
681 assert!(n < 16usize);
682 let offs = 0usize + n * 1usize;
683 let val = (self.0 >> offs) & 0x01;
684 val != 0
685 }
686 #[doc = "Port x set bit y (y= 0..15)"]
687 pub fn set_bs(&mut self, n: usize, val: bool) {
688 assert!(n < 16usize);
689 let offs = 0usize + n * 1usize;
690 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
691 }
692 #[doc = "Port x set bit y (y= 0..15)"]
693 pub fn br(&self, n: usize) -> bool {
694 assert!(n < 16usize);
695 let offs = 16usize + n * 1usize;
696 let val = (self.0 >> offs) & 0x01;
697 val != 0
698 }
699 #[doc = "Port x set bit y (y= 0..15)"]
700 pub fn set_br(&mut self, n: usize, val: bool) {
701 assert!(n < 16usize);
702 let offs = 16usize + n * 1usize;
703 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
704 }
705 }
706 impl Default for Bsrr {
707 fn default() -> Bsrr {
708 Bsrr(0)
709 }
710 }
711 #[doc = "GPIO port input data register"] 1392 #[doc = "GPIO port input data register"]
712 #[repr(transparent)] 1393 #[repr(transparent)]
713 #[derive(Copy, Clone, Eq, PartialEq)] 1394 #[derive(Copy, Clone, Eq, PartialEq)]
@@ -756,30 +1437,6 @@ pub mod gpio_v2 {
756 Moder(0) 1437 Moder(0)
757 } 1438 }
758 } 1439 }
759 #[doc = "GPIO port pull-up/pull-down register"]
760 #[repr(transparent)]
761 #[derive(Copy, Clone, Eq, PartialEq)]
762 pub struct Pupdr(pub u32);
763 impl Pupdr {
764 #[doc = "Port x configuration bits (y = 0..15)"]
765 pub fn pupdr(&self, n: usize) -> super::vals::Pupdr {
766 assert!(n < 16usize);
767 let offs = 0usize + n * 2usize;
768 let val = (self.0 >> offs) & 0x03;
769 super::vals::Pupdr(val as u8)
770 }
771 #[doc = "Port x configuration bits (y = 0..15)"]
772 pub fn set_pupdr(&mut self, n: usize, val: super::vals::Pupdr) {
773 assert!(n < 16usize);
774 let offs = 0usize + n * 2usize;
775 self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs);
776 }
777 }
778 impl Default for Pupdr {
779 fn default() -> Pupdr {
780 Pupdr(0)
781 }
782 }
783 #[doc = "GPIO alternate function register"] 1440 #[doc = "GPIO alternate function register"]
784 #[repr(transparent)] 1441 #[repr(transparent)]
785 #[derive(Copy, Clone, Eq, PartialEq)] 1442 #[derive(Copy, Clone, Eq, PartialEq)]
@@ -804,28 +1461,28 @@ pub mod gpio_v2 {
804 Afr(0) 1461 Afr(0)
805 } 1462 }
806 } 1463 }
807 #[doc = "GPIO port output speed register"] 1464 #[doc = "GPIO port pull-up/pull-down register"]
808 #[repr(transparent)] 1465 #[repr(transparent)]
809 #[derive(Copy, Clone, Eq, PartialEq)] 1466 #[derive(Copy, Clone, Eq, PartialEq)]
810 pub struct Ospeedr(pub u32); 1467 pub struct Pupdr(pub u32);
811 impl Ospeedr { 1468 impl Pupdr {
812 #[doc = "Port x configuration bits (y = 0..15)"] 1469 #[doc = "Port x configuration bits (y = 0..15)"]
813 pub fn ospeedr(&self, n: usize) -> super::vals::Ospeedr { 1470 pub fn pupdr(&self, n: usize) -> super::vals::Pupdr {
814 assert!(n < 16usize); 1471 assert!(n < 16usize);
815 let offs = 0usize + n * 2usize; 1472 let offs = 0usize + n * 2usize;
816 let val = (self.0 >> offs) & 0x03; 1473 let val = (self.0 >> offs) & 0x03;
817 super::vals::Ospeedr(val as u8) 1474 super::vals::Pupdr(val as u8)
818 } 1475 }
819 #[doc = "Port x configuration bits (y = 0..15)"] 1476 #[doc = "Port x configuration bits (y = 0..15)"]
820 pub fn set_ospeedr(&mut self, n: usize, val: super::vals::Ospeedr) { 1477 pub fn set_pupdr(&mut self, n: usize, val: super::vals::Pupdr) {
821 assert!(n < 16usize); 1478 assert!(n < 16usize);
822 let offs = 0usize + n * 2usize; 1479 let offs = 0usize + n * 2usize;
823 self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); 1480 self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs);
824 } 1481 }
825 } 1482 }
826 impl Default for Ospeedr { 1483 impl Default for Pupdr {
827 fn default() -> Ospeedr { 1484 fn default() -> Pupdr {
828 Ospeedr(0) 1485 Pupdr(0)
829 } 1486 }
830 } 1487 }
831 #[doc = "GPIO port output type register"] 1488 #[doc = "GPIO port output type register"]
@@ -852,88 +1509,213 @@ pub mod gpio_v2 {
852 Otyper(0) 1509 Otyper(0)
853 } 1510 }
854 } 1511 }
855 #[doc = "GPIO port configuration lock register"] 1512 #[doc = "GPIO port bit set/reset register"]
856 #[repr(transparent)] 1513 #[repr(transparent)]
857 #[derive(Copy, Clone, Eq, PartialEq)] 1514 #[derive(Copy, Clone, Eq, PartialEq)]
858 pub struct Lckr(pub u32); 1515 pub struct Bsrr(pub u32);
859 impl Lckr { 1516 impl Bsrr {
860 #[doc = "Port x lock bit y (y= 0..15)"] 1517 #[doc = "Port x set bit y (y= 0..15)"]
861 pub fn lck(&self, n: usize) -> super::vals::Lck { 1518 pub fn bs(&self, n: usize) -> bool {
862 assert!(n < 16usize); 1519 assert!(n < 16usize);
863 let offs = 0usize + n * 1usize; 1520 let offs = 0usize + n * 1usize;
864 let val = (self.0 >> offs) & 0x01; 1521 let val = (self.0 >> offs) & 0x01;
865 super::vals::Lck(val as u8) 1522 val != 0
866 } 1523 }
867 #[doc = "Port x lock bit y (y= 0..15)"] 1524 #[doc = "Port x set bit y (y= 0..15)"]
868 pub fn set_lck(&mut self, n: usize, val: super::vals::Lck) { 1525 pub fn set_bs(&mut self, n: usize, val: bool) {
869 assert!(n < 16usize); 1526 assert!(n < 16usize);
870 let offs = 0usize + n * 1usize; 1527 let offs = 0usize + n * 1usize;
871 self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); 1528 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
872 } 1529 }
873 #[doc = "Port x lock bit y (y= 0..15)"] 1530 #[doc = "Port x set bit y (y= 0..15)"]
874 pub const fn lckk(&self) -> super::vals::Lckk { 1531 pub fn br(&self, n: usize) -> bool {
875 let val = (self.0 >> 16usize) & 0x01; 1532 assert!(n < 16usize);
876 super::vals::Lckk(val as u8) 1533 let offs = 16usize + n * 1usize;
1534 let val = (self.0 >> offs) & 0x01;
1535 val != 0
877 } 1536 }
878 #[doc = "Port x lock bit y (y= 0..15)"] 1537 #[doc = "Port x set bit y (y= 0..15)"]
879 pub fn set_lckk(&mut self, val: super::vals::Lckk) { 1538 pub fn set_br(&mut self, n: usize, val: bool) {
880 self.0 = (self.0 & !(0x01 << 16usize)) | (((val.0 as u32) & 0x01) << 16usize); 1539 assert!(n < 16usize);
1540 let offs = 16usize + n * 1usize;
1541 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
881 } 1542 }
882 } 1543 }
883 impl Default for Lckr { 1544 impl Default for Bsrr {
884 fn default() -> Lckr { 1545 fn default() -> Bsrr {
885 Lckr(0) 1546 Bsrr(0)
1547 }
1548 }
1549 #[doc = "GPIO port output speed register"]
1550 #[repr(transparent)]
1551 #[derive(Copy, Clone, Eq, PartialEq)]
1552 pub struct Ospeedr(pub u32);
1553 impl Ospeedr {
1554 #[doc = "Port x configuration bits (y = 0..15)"]
1555 pub fn ospeedr(&self, n: usize) -> super::vals::Ospeedr {
1556 assert!(n < 16usize);
1557 let offs = 0usize + n * 2usize;
1558 let val = (self.0 >> offs) & 0x03;
1559 super::vals::Ospeedr(val as u8)
1560 }
1561 #[doc = "Port x configuration bits (y = 0..15)"]
1562 pub fn set_ospeedr(&mut self, n: usize, val: super::vals::Ospeedr) {
1563 assert!(n < 16usize);
1564 let offs = 0usize + n * 2usize;
1565 self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs);
1566 }
1567 }
1568 impl Default for Ospeedr {
1569 fn default() -> Ospeedr {
1570 Ospeedr(0)
886 } 1571 }
887 } 1572 }
888 } 1573 }
889} 1574 pub mod vals {
890pub mod timer_v1 { 1575 use crate::generic::*;
891 use crate::generic::*; 1576 #[repr(transparent)]
892 #[doc = "Basic timer"] 1577 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
893 #[derive(Copy, Clone)] 1578 pub struct Afr(pub u8);
894 pub struct TimBasic(pub *mut u8); 1579 impl Afr {
895 unsafe impl Send for TimBasic {} 1580 #[doc = "AF0"]
896 unsafe impl Sync for TimBasic {} 1581 pub const AF0: Self = Self(0);
897 impl TimBasic { 1582 #[doc = "AF1"]
898 #[doc = "control register 1"] 1583 pub const AF1: Self = Self(0x01);
899 pub fn cr1(self) -> Reg<regs::Cr1Basic, RW> { 1584 #[doc = "AF2"]
900 unsafe { Reg::from_ptr(self.0.add(0usize)) } 1585 pub const AF2: Self = Self(0x02);
1586 #[doc = "AF3"]
1587 pub const AF3: Self = Self(0x03);
1588 #[doc = "AF4"]
1589 pub const AF4: Self = Self(0x04);
1590 #[doc = "AF5"]
1591 pub const AF5: Self = Self(0x05);
1592 #[doc = "AF6"]
1593 pub const AF6: Self = Self(0x06);
1594 #[doc = "AF7"]
1595 pub const AF7: Self = Self(0x07);
1596 #[doc = "AF8"]
1597 pub const AF8: Self = Self(0x08);
1598 #[doc = "AF9"]
1599 pub const AF9: Self = Self(0x09);
1600 #[doc = "AF10"]
1601 pub const AF10: Self = Self(0x0a);
1602 #[doc = "AF11"]
1603 pub const AF11: Self = Self(0x0b);
1604 #[doc = "AF12"]
1605 pub const AF12: Self = Self(0x0c);
1606 #[doc = "AF13"]
1607 pub const AF13: Self = Self(0x0d);
1608 #[doc = "AF14"]
1609 pub const AF14: Self = Self(0x0e);
1610 #[doc = "AF15"]
1611 pub const AF15: Self = Self(0x0f);
901 } 1612 }
902 #[doc = "control register 2"] 1613 #[repr(transparent)]
903 pub fn cr2(self) -> Reg<regs::Cr2Basic, RW> { 1614 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
904 unsafe { Reg::from_ptr(self.0.add(4usize)) } 1615 pub struct Moder(pub u8);
1616 impl Moder {
1617 #[doc = "Input mode (reset state)"]
1618 pub const INPUT: Self = Self(0);
1619 #[doc = "General purpose output mode"]
1620 pub const OUTPUT: Self = Self(0x01);
1621 #[doc = "Alternate function mode"]
1622 pub const ALTERNATE: Self = Self(0x02);
1623 #[doc = "Analog mode"]
1624 pub const ANALOG: Self = Self(0x03);
905 } 1625 }
906 #[doc = "DMA/Interrupt enable register"] 1626 #[repr(transparent)]
907 pub fn dier(self) -> Reg<regs::DierBasic, RW> { 1627 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
908 unsafe { Reg::from_ptr(self.0.add(12usize)) } 1628 pub struct Brw(pub u8);
1629 impl Brw {
1630 #[doc = "Resets the corresponding ODRx bit"]
1631 pub const RESET: Self = Self(0x01);
909 } 1632 }
910 #[doc = "status register"] 1633 #[repr(transparent)]
911 pub fn sr(self) -> Reg<regs::SrBasic, RW> { 1634 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
912 unsafe { Reg::from_ptr(self.0.add(16usize)) } 1635 pub struct Idr(pub u8);
1636 impl Idr {
1637 #[doc = "Input is logic low"]
1638 pub const LOW: Self = Self(0);
1639 #[doc = "Input is logic high"]
1640 pub const HIGH: Self = Self(0x01);
913 } 1641 }
914 #[doc = "event generation register"] 1642 #[repr(transparent)]
915 pub fn egr(self) -> Reg<regs::EgrBasic, W> { 1643 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
916 unsafe { Reg::from_ptr(self.0.add(20usize)) } 1644 pub struct Ospeedr(pub u8);
1645 impl Ospeedr {
1646 #[doc = "Low speed"]
1647 pub const LOWSPEED: Self = Self(0);
1648 #[doc = "Medium speed"]
1649 pub const MEDIUMSPEED: Self = Self(0x01);
1650 #[doc = "High speed"]
1651 pub const HIGHSPEED: Self = Self(0x02);
1652 #[doc = "Very high speed"]
1653 pub const VERYHIGHSPEED: Self = Self(0x03);
917 } 1654 }
918 #[doc = "counter"] 1655 #[repr(transparent)]
919 pub fn cnt(self) -> Reg<regs::Cnt16, RW> { 1656 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
920 unsafe { Reg::from_ptr(self.0.add(36usize)) } 1657 pub struct Lck(pub u8);
1658 impl Lck {
1659 #[doc = "Port configuration not locked"]
1660 pub const UNLOCKED: Self = Self(0);
1661 #[doc = "Port configuration locked"]
1662 pub const LOCKED: Self = Self(0x01);
921 } 1663 }
922 #[doc = "prescaler"] 1664 #[repr(transparent)]
923 pub fn psc(self) -> Reg<regs::Psc, RW> { 1665 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
924 unsafe { Reg::from_ptr(self.0.add(40usize)) } 1666 pub struct Pupdr(pub u8);
1667 impl Pupdr {
1668 #[doc = "No pull-up, pull-down"]
1669 pub const FLOATING: Self = Self(0);
1670 #[doc = "Pull-up"]
1671 pub const PULLUP: Self = Self(0x01);
1672 #[doc = "Pull-down"]
1673 pub const PULLDOWN: Self = Self(0x02);
925 } 1674 }
926 #[doc = "auto-reload register"] 1675 #[repr(transparent)]
927 pub fn arr(self) -> Reg<regs::Arr16, RW> { 1676 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
928 unsafe { Reg::from_ptr(self.0.add(44usize)) } 1677 pub struct Bsw(pub u8);
1678 impl Bsw {
1679 #[doc = "Sets the corresponding ODRx bit"]
1680 pub const SET: Self = Self(0x01);
1681 }
1682 #[repr(transparent)]
1683 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1684 pub struct Ot(pub u8);
1685 impl Ot {
1686 #[doc = "Output push-pull (reset state)"]
1687 pub const PUSHPULL: Self = Self(0);
1688 #[doc = "Output open-drain"]
1689 pub const OPENDRAIN: Self = Self(0x01);
1690 }
1691 #[repr(transparent)]
1692 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1693 pub struct Odr(pub u8);
1694 impl Odr {
1695 #[doc = "Set output to logic low"]
1696 pub const LOW: Self = Self(0);
1697 #[doc = "Set output to logic high"]
1698 pub const HIGH: Self = Self(0x01);
1699 }
1700 #[repr(transparent)]
1701 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1702 pub struct Lckk(pub u8);
1703 impl Lckk {
1704 #[doc = "Port configuration lock key not active"]
1705 pub const NOTACTIVE: Self = Self(0);
1706 #[doc = "Port configuration lock key active"]
1707 pub const ACTIVE: Self = Self(0x01);
929 } 1708 }
930 } 1709 }
931 #[doc = "General purpose 32-bit timer"] 1710}
1711pub mod timer_v1 {
1712 use crate::generic::*;
1713 #[doc = "General purpose 16-bit timer"]
932 #[derive(Copy, Clone)] 1714 #[derive(Copy, Clone)]
933 pub struct TimGp32(pub *mut u8); 1715 pub struct TimGp16(pub *mut u8);
934 unsafe impl Send for TimGp32 {} 1716 unsafe impl Send for TimGp16 {}
935 unsafe impl Sync for TimGp32 {} 1717 unsafe impl Sync for TimGp16 {}
936 impl TimGp32 { 1718 impl TimGp16 {
937 #[doc = "control register 1"] 1719 #[doc = "control register 1"]
938 pub fn cr1(self) -> Reg<regs::Cr1Gp, RW> { 1720 pub fn cr1(self) -> Reg<regs::Cr1Gp, RW> {
939 unsafe { Reg::from_ptr(self.0.add(0usize)) } 1721 unsafe { Reg::from_ptr(self.0.add(0usize)) }
@@ -973,7 +1755,7 @@ pub mod timer_v1 {
973 unsafe { Reg::from_ptr(self.0.add(32usize)) } 1755 unsafe { Reg::from_ptr(self.0.add(32usize)) }
974 } 1756 }
975 #[doc = "counter"] 1757 #[doc = "counter"]
976 pub fn cnt(self) -> Reg<regs::Cnt32, RW> { 1758 pub fn cnt(self) -> Reg<regs::Cnt16, RW> {
977 unsafe { Reg::from_ptr(self.0.add(36usize)) } 1759 unsafe { Reg::from_ptr(self.0.add(36usize)) }
978 } 1760 }
979 #[doc = "prescaler"] 1761 #[doc = "prescaler"]
@@ -981,11 +1763,11 @@ pub mod timer_v1 {
981 unsafe { Reg::from_ptr(self.0.add(40usize)) } 1763 unsafe { Reg::from_ptr(self.0.add(40usize)) }
982 } 1764 }
983 #[doc = "auto-reload register"] 1765 #[doc = "auto-reload register"]
984 pub fn arr(self) -> Reg<regs::Arr32, RW> { 1766 pub fn arr(self) -> Reg<regs::Arr16, RW> {
985 unsafe { Reg::from_ptr(self.0.add(44usize)) } 1767 unsafe { Reg::from_ptr(self.0.add(44usize)) }
986 } 1768 }
987 #[doc = "capture/compare register"] 1769 #[doc = "capture/compare register"]
988 pub fn ccr(self, n: usize) -> Reg<regs::Ccr32, RW> { 1770 pub fn ccr(self, n: usize) -> Reg<regs::Ccr16, RW> {
989 assert!(n < 4usize); 1771 assert!(n < 4usize);
990 unsafe { Reg::from_ptr(self.0.add(52usize + n * 4usize)) } 1772 unsafe { Reg::from_ptr(self.0.add(52usize + n * 4usize)) }
991 } 1773 }
@@ -998,18 +1780,18 @@ pub mod timer_v1 {
998 unsafe { Reg::from_ptr(self.0.add(76usize)) } 1780 unsafe { Reg::from_ptr(self.0.add(76usize)) }
999 } 1781 }
1000 } 1782 }
1001 #[doc = "General purpose 16-bit timer"] 1783 #[doc = "Advanced-timers"]
1002 #[derive(Copy, Clone)] 1784 #[derive(Copy, Clone)]
1003 pub struct TimGp16(pub *mut u8); 1785 pub struct TimAdv(pub *mut u8);
1004 unsafe impl Send for TimGp16 {} 1786 unsafe impl Send for TimAdv {}
1005 unsafe impl Sync for TimGp16 {} 1787 unsafe impl Sync for TimAdv {}
1006 impl TimGp16 { 1788 impl TimAdv {
1007 #[doc = "control register 1"] 1789 #[doc = "control register 1"]
1008 pub fn cr1(self) -> Reg<regs::Cr1Gp, RW> { 1790 pub fn cr1(self) -> Reg<regs::Cr1Gp, RW> {
1009 unsafe { Reg::from_ptr(self.0.add(0usize)) } 1791 unsafe { Reg::from_ptr(self.0.add(0usize)) }
1010 } 1792 }
1011 #[doc = "control register 2"] 1793 #[doc = "control register 2"]
1012 pub fn cr2(self) -> Reg<regs::Cr2Gp, RW> { 1794 pub fn cr2(self) -> Reg<regs::Cr2Adv, RW> {
1013 unsafe { Reg::from_ptr(self.0.add(4usize)) } 1795 unsafe { Reg::from_ptr(self.0.add(4usize)) }
1014 } 1796 }
1015 #[doc = "slave mode control register"] 1797 #[doc = "slave mode control register"]
@@ -1017,15 +1799,15 @@ pub mod timer_v1 {
1017 unsafe { Reg::from_ptr(self.0.add(8usize)) } 1799 unsafe { Reg::from_ptr(self.0.add(8usize)) }
1018 } 1800 }
1019 #[doc = "DMA/Interrupt enable register"] 1801 #[doc = "DMA/Interrupt enable register"]
1020 pub fn dier(self) -> Reg<regs::DierGp, RW> { 1802 pub fn dier(self) -> Reg<regs::DierAdv, RW> {
1021 unsafe { Reg::from_ptr(self.0.add(12usize)) } 1803 unsafe { Reg::from_ptr(self.0.add(12usize)) }
1022 } 1804 }
1023 #[doc = "status register"] 1805 #[doc = "status register"]
1024 pub fn sr(self) -> Reg<regs::SrGp, RW> { 1806 pub fn sr(self) -> Reg<regs::SrAdv, RW> {
1025 unsafe { Reg::from_ptr(self.0.add(16usize)) } 1807 unsafe { Reg::from_ptr(self.0.add(16usize)) }
1026 } 1808 }
1027 #[doc = "event generation register"] 1809 #[doc = "event generation register"]
1028 pub fn egr(self) -> Reg<regs::EgrGp, W> { 1810 pub fn egr(self) -> Reg<regs::EgrAdv, W> {
1029 unsafe { Reg::from_ptr(self.0.add(20usize)) } 1811 unsafe { Reg::from_ptr(self.0.add(20usize)) }
1030 } 1812 }
1031 #[doc = "capture/compare mode register 1 (input mode)"] 1813 #[doc = "capture/compare mode register 1 (input mode)"]
@@ -1039,7 +1821,7 @@ pub mod timer_v1 {
1039 unsafe { Reg::from_ptr(self.0.add(24usize + n * 4usize)) } 1821 unsafe { Reg::from_ptr(self.0.add(24usize + n * 4usize)) }
1040 } 1822 }
1041 #[doc = "capture/compare enable register"] 1823 #[doc = "capture/compare enable register"]
1042 pub fn ccer(self) -> Reg<regs::CcerGp, RW> { 1824 pub fn ccer(self) -> Reg<regs::CcerAdv, RW> {
1043 unsafe { Reg::from_ptr(self.0.add(32usize)) } 1825 unsafe { Reg::from_ptr(self.0.add(32usize)) }
1044 } 1826 }
1045 #[doc = "counter"] 1827 #[doc = "counter"]
@@ -1054,11 +1836,19 @@ pub mod timer_v1 {
1054 pub fn arr(self) -> Reg<regs::Arr16, RW> { 1836 pub fn arr(self) -> Reg<regs::Arr16, RW> {
1055 unsafe { Reg::from_ptr(self.0.add(44usize)) } 1837 unsafe { Reg::from_ptr(self.0.add(44usize)) }
1056 } 1838 }
1839 #[doc = "repetition counter register"]
1840 pub fn rcr(self) -> Reg<regs::Rcr, RW> {
1841 unsafe { Reg::from_ptr(self.0.add(48usize)) }
1842 }
1057 #[doc = "capture/compare register"] 1843 #[doc = "capture/compare register"]
1058 pub fn ccr(self, n: usize) -> Reg<regs::Ccr16, RW> { 1844 pub fn ccr(self, n: usize) -> Reg<regs::Ccr16, RW> {
1059 assert!(n < 4usize); 1845 assert!(n < 4usize);
1060 unsafe { Reg::from_ptr(self.0.add(52usize + n * 4usize)) } 1846 unsafe { Reg::from_ptr(self.0.add(52usize + n * 4usize)) }
1061 } 1847 }
1848 #[doc = "break and dead-time register"]
1849 pub fn bdtr(self) -> Reg<regs::Bdtr, RW> {
1850 unsafe { Reg::from_ptr(self.0.add(68usize)) }
1851 }
1062 #[doc = "DMA control register"] 1852 #[doc = "DMA control register"]
1063 pub fn dcr(self) -> Reg<regs::Dcr, RW> { 1853 pub fn dcr(self) -> Reg<regs::Dcr, RW> {
1064 unsafe { Reg::from_ptr(self.0.add(72usize)) } 1854 unsafe { Reg::from_ptr(self.0.add(72usize)) }
@@ -1068,18 +1858,57 @@ pub mod timer_v1 {
1068 unsafe { Reg::from_ptr(self.0.add(76usize)) } 1858 unsafe { Reg::from_ptr(self.0.add(76usize)) }
1069 } 1859 }
1070 } 1860 }
1071 #[doc = "Advanced-timers"] 1861 #[doc = "Basic timer"]
1072 #[derive(Copy, Clone)] 1862 #[derive(Copy, Clone)]
1073 pub struct TimAdv(pub *mut u8); 1863 pub struct TimBasic(pub *mut u8);
1074 unsafe impl Send for TimAdv {} 1864 unsafe impl Send for TimBasic {}
1075 unsafe impl Sync for TimAdv {} 1865 unsafe impl Sync for TimBasic {}
1076 impl TimAdv { 1866 impl TimBasic {
1867 #[doc = "control register 1"]
1868 pub fn cr1(self) -> Reg<regs::Cr1Basic, RW> {
1869 unsafe { Reg::from_ptr(self.0.add(0usize)) }
1870 }
1871 #[doc = "control register 2"]
1872 pub fn cr2(self) -> Reg<regs::Cr2Basic, RW> {
1873 unsafe { Reg::from_ptr(self.0.add(4usize)) }
1874 }
1875 #[doc = "DMA/Interrupt enable register"]
1876 pub fn dier(self) -> Reg<regs::DierBasic, RW> {
1877 unsafe { Reg::from_ptr(self.0.add(12usize)) }
1878 }
1879 #[doc = "status register"]
1880 pub fn sr(self) -> Reg<regs::SrBasic, RW> {
1881 unsafe { Reg::from_ptr(self.0.add(16usize)) }
1882 }
1883 #[doc = "event generation register"]
1884 pub fn egr(self) -> Reg<regs::EgrBasic, W> {
1885 unsafe { Reg::from_ptr(self.0.add(20usize)) }
1886 }
1887 #[doc = "counter"]
1888 pub fn cnt(self) -> Reg<regs::Cnt16, RW> {
1889 unsafe { Reg::from_ptr(self.0.add(36usize)) }
1890 }
1891 #[doc = "prescaler"]
1892 pub fn psc(self) -> Reg<regs::Psc, RW> {
1893 unsafe { Reg::from_ptr(self.0.add(40usize)) }
1894 }
1895 #[doc = "auto-reload register"]
1896 pub fn arr(self) -> Reg<regs::Arr16, RW> {
1897 unsafe { Reg::from_ptr(self.0.add(44usize)) }
1898 }
1899 }
1900 #[doc = "General purpose 32-bit timer"]
1901 #[derive(Copy, Clone)]
1902 pub struct TimGp32(pub *mut u8);
1903 unsafe impl Send for TimGp32 {}
1904 unsafe impl Sync for TimGp32 {}
1905 impl TimGp32 {
1077 #[doc = "control register 1"] 1906 #[doc = "control register 1"]
1078 pub fn cr1(self) -> Reg<regs::Cr1Gp, RW> { 1907 pub fn cr1(self) -> Reg<regs::Cr1Gp, RW> {
1079 unsafe { Reg::from_ptr(self.0.add(0usize)) } 1908 unsafe { Reg::from_ptr(self.0.add(0usize)) }
1080 } 1909 }
1081 #[doc = "control register 2"] 1910 #[doc = "control register 2"]
1082 pub fn cr2(self) -> Reg<regs::Cr2Adv, RW> { 1911 pub fn cr2(self) -> Reg<regs::Cr2Gp, RW> {
1083 unsafe { Reg::from_ptr(self.0.add(4usize)) } 1912 unsafe { Reg::from_ptr(self.0.add(4usize)) }
1084 } 1913 }
1085 #[doc = "slave mode control register"] 1914 #[doc = "slave mode control register"]
@@ -1087,15 +1916,15 @@ pub mod timer_v1 {
1087 unsafe { Reg::from_ptr(self.0.add(8usize)) } 1916 unsafe { Reg::from_ptr(self.0.add(8usize)) }
1088 } 1917 }
1089 #[doc = "DMA/Interrupt enable register"] 1918 #[doc = "DMA/Interrupt enable register"]
1090 pub fn dier(self) -> Reg<regs::DierAdv, RW> { 1919 pub fn dier(self) -> Reg<regs::DierGp, RW> {
1091 unsafe { Reg::from_ptr(self.0.add(12usize)) } 1920 unsafe { Reg::from_ptr(self.0.add(12usize)) }
1092 } 1921 }
1093 #[doc = "status register"] 1922 #[doc = "status register"]
1094 pub fn sr(self) -> Reg<regs::SrAdv, RW> { 1923 pub fn sr(self) -> Reg<regs::SrGp, RW> {
1095 unsafe { Reg::from_ptr(self.0.add(16usize)) } 1924 unsafe { Reg::from_ptr(self.0.add(16usize)) }
1096 } 1925 }
1097 #[doc = "event generation register"] 1926 #[doc = "event generation register"]
1098 pub fn egr(self) -> Reg<regs::EgrAdv, W> { 1927 pub fn egr(self) -> Reg<regs::EgrGp, W> {
1099 unsafe { Reg::from_ptr(self.0.add(20usize)) } 1928 unsafe { Reg::from_ptr(self.0.add(20usize)) }
1100 } 1929 }
1101 #[doc = "capture/compare mode register 1 (input mode)"] 1930 #[doc = "capture/compare mode register 1 (input mode)"]
@@ -1109,11 +1938,11 @@ pub mod timer_v1 {
1109 unsafe { Reg::from_ptr(self.0.add(24usize + n * 4usize)) } 1938 unsafe { Reg::from_ptr(self.0.add(24usize + n * 4usize)) }
1110 } 1939 }
1111 #[doc = "capture/compare enable register"] 1940 #[doc = "capture/compare enable register"]
1112 pub fn ccer(self) -> Reg<regs::CcerAdv, RW> { 1941 pub fn ccer(self) -> Reg<regs::CcerGp, RW> {
1113 unsafe { Reg::from_ptr(self.0.add(32usize)) } 1942 unsafe { Reg::from_ptr(self.0.add(32usize)) }
1114 } 1943 }
1115 #[doc = "counter"] 1944 #[doc = "counter"]
1116 pub fn cnt(self) -> Reg<regs::Cnt16, RW> { 1945 pub fn cnt(self) -> Reg<regs::Cnt32, RW> {
1117 unsafe { Reg::from_ptr(self.0.add(36usize)) } 1946 unsafe { Reg::from_ptr(self.0.add(36usize)) }
1118 } 1947 }
1119 #[doc = "prescaler"] 1948 #[doc = "prescaler"]
@@ -1121,22 +1950,14 @@ pub mod timer_v1 {
1121 unsafe { Reg::from_ptr(self.0.add(40usize)) } 1950 unsafe { Reg::from_ptr(self.0.add(40usize)) }
1122 } 1951 }
1123 #[doc = "auto-reload register"] 1952 #[doc = "auto-reload register"]
1124 pub fn arr(self) -> Reg<regs::Arr16, RW> { 1953 pub fn arr(self) -> Reg<regs::Arr32, RW> {
1125 unsafe { Reg::from_ptr(self.0.add(44usize)) } 1954 unsafe { Reg::from_ptr(self.0.add(44usize)) }
1126 } 1955 }
1127 #[doc = "repetition counter register"]
1128 pub fn rcr(self) -> Reg<regs::Rcr, RW> {
1129 unsafe { Reg::from_ptr(self.0.add(48usize)) }
1130 }
1131 #[doc = "capture/compare register"] 1956 #[doc = "capture/compare register"]
1132 pub fn ccr(self, n: usize) -> Reg<regs::Ccr16, RW> { 1957 pub fn ccr(self, n: usize) -> Reg<regs::Ccr32, RW> {
1133 assert!(n < 4usize); 1958 assert!(n < 4usize);
1134 unsafe { Reg::from_ptr(self.0.add(52usize + n * 4usize)) } 1959 unsafe { Reg::from_ptr(self.0.add(52usize + n * 4usize)) }
1135 } 1960 }
1136 #[doc = "break and dead-time register"]
1137 pub fn bdtr(self) -> Reg<regs::Bdtr, RW> {
1138 unsafe { Reg::from_ptr(self.0.add(68usize)) }
1139 }
1140 #[doc = "DMA control register"] 1961 #[doc = "DMA control register"]
1141 pub fn dcr(self) -> Reg<regs::Dcr, RW> { 1962 pub fn dcr(self) -> Reg<regs::Dcr, RW> {
1142 unsafe { Reg::from_ptr(self.0.add(72usize)) } 1963 unsafe { Reg::from_ptr(self.0.add(72usize)) }
@@ -1150,108 +1971,64 @@ pub mod timer_v1 {
1150 use crate::generic::*; 1971 use crate::generic::*;
1151 #[repr(transparent)] 1972 #[repr(transparent)]
1152 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 1973 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1153 pub struct Icf(pub u8); 1974 pub struct Ocm(pub u8);
1154 impl Icf { 1975 impl Ocm {
1155 #[doc = "No filter, sampling is done at fDTS"] 1976 #[doc = "The comparison between the output compare register TIMx_CCRy and the counter TIMx_CNT has no effect on the outputs"]
1156 pub const NOFILTER: Self = Self(0); 1977 pub const FROZEN: Self = Self(0);
1157 #[doc = "fSAMPLING=fCK_INT, N=2"] 1978 #[doc = "Set channel to active level on match. OCyREF signal is forced high when the counter matches the capture/compare register"]
1158 pub const FCK_INT_N2: Self = Self(0x01); 1979 pub const ACTIVEONMATCH: Self = Self(0x01);
1159 #[doc = "fSAMPLING=fCK_INT, N=4"] 1980 #[doc = "Set channel to inactive level on match. OCyREF signal is forced low when the counter matches the capture/compare register"]
1160 pub const FCK_INT_N4: Self = Self(0x02); 1981 pub const INACTIVEONMATCH: Self = Self(0x02);
1161 #[doc = "fSAMPLING=fCK_INT, N=8"] 1982 #[doc = "OCyREF toggles when TIMx_CNT=TIMx_CCRy"]
1162 pub const FCK_INT_N8: Self = Self(0x03); 1983 pub const TOGGLE: Self = Self(0x03);
1163 #[doc = "fSAMPLING=fDTS/2, N=6"] 1984 #[doc = "OCyREF is forced low"]
1164 pub const FDTS_DIV2_N6: Self = Self(0x04); 1985 pub const FORCEINACTIVE: Self = Self(0x04);
1165 #[doc = "fSAMPLING=fDTS/2, N=8"] 1986 #[doc = "OCyREF is forced high"]
1166 pub const FDTS_DIV2_N8: Self = Self(0x05); 1987 pub const FORCEACTIVE: Self = Self(0x05);
1167 #[doc = "fSAMPLING=fDTS/4, N=6"] 1988 #[doc = "In upcounting, channel is active as long as TIMx_CNT<TIMx_CCRy else inactive. In downcounting, channel is inactive as long as TIMx_CNT>TIMx_CCRy else active"]
1168 pub const FDTS_DIV4_N6: Self = Self(0x06); 1989 pub const PWMMODE1: Self = Self(0x06);
1169 #[doc = "fSAMPLING=fDTS/4, N=8"] 1990 #[doc = "Inversely to PwmMode1"]
1170 pub const FDTS_DIV4_N8: Self = Self(0x07); 1991 pub const PWMMODE2: Self = Self(0x07);
1171 #[doc = "fSAMPLING=fDTS/8, N=6"]
1172 pub const FDTS_DIV8_N6: Self = Self(0x08);
1173 #[doc = "fSAMPLING=fDTS/8, N=8"]
1174 pub const FDTS_DIV8_N8: Self = Self(0x09);
1175 #[doc = "fSAMPLING=fDTS/16, N=5"]
1176 pub const FDTS_DIV16_N5: Self = Self(0x0a);
1177 #[doc = "fSAMPLING=fDTS/16, N=6"]
1178 pub const FDTS_DIV16_N6: Self = Self(0x0b);
1179 #[doc = "fSAMPLING=fDTS/16, N=8"]
1180 pub const FDTS_DIV16_N8: Self = Self(0x0c);
1181 #[doc = "fSAMPLING=fDTS/32, N=5"]
1182 pub const FDTS_DIV32_N5: Self = Self(0x0d);
1183 #[doc = "fSAMPLING=fDTS/32, N=6"]
1184 pub const FDTS_DIV32_N6: Self = Self(0x0e);
1185 #[doc = "fSAMPLING=fDTS/32, N=8"]
1186 pub const FDTS_DIV32_N8: Self = Self(0x0f);
1187 } 1992 }
1188 #[repr(transparent)] 1993 #[repr(transparent)]
1189 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 1994 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1190 pub struct Ece(pub u8); 1995 pub struct Opm(pub u8);
1191 impl Ece { 1996 impl Opm {
1192 #[doc = "External clock mode 2 disabled"] 1997 #[doc = "Counter is not stopped at update event"]
1193 pub const DISABLED: Self = Self(0); 1998 pub const DISABLED: Self = Self(0);
1194 #[doc = "External clock mode 2 enabled. The counter is clocked by any active edge on the ETRF signal."] 1999 #[doc = "Counter stops counting at the next update event (clearing the CEN bit)"]
1195 pub const ENABLED: Self = Self(0x01); 2000 pub const ENABLED: Self = Self(0x01);
1196 } 2001 }
1197 #[repr(transparent)] 2002 #[repr(transparent)]
1198 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 2003 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1199 pub struct Sms(pub u8); 2004 pub struct Arpe(pub u8);
1200 impl Sms { 2005 impl Arpe {
1201 #[doc = "Slave mode disabled - if CEN = ‘1 then the prescaler is clocked directly by the internal clock."] 2006 #[doc = "TIMx_APRR register is not buffered"]
1202 pub const DISABLED: Self = Self(0);
1203 #[doc = "Encoder mode 1 - Counter counts up/down on TI2FP1 edge depending on TI1FP2 level."]
1204 pub const ENCODER_MODE_1: Self = Self(0x01);
1205 #[doc = "Encoder mode 2 - Counter counts up/down on TI1FP2 edge depending on TI2FP1 level."]
1206 pub const ENCODER_MODE_2: Self = Self(0x02);
1207 #[doc = "Encoder mode 3 - Counter counts up/down on both TI1FP1 and TI2FP2 edges depending on the level of the other input."]
1208 pub const ENCODER_MODE_3: Self = Self(0x03);
1209 #[doc = "Reset Mode - Rising edge of the selected trigger input (TRGI) reinitializes the counter and generates an update of the registers."]
1210 pub const RESET_MODE: Self = Self(0x04);
1211 #[doc = "Gated Mode - The counter clock is enabled when the trigger input (TRGI) is high. The counter stops (but is not reset) as soon as the trigger becomes low. Both start and stop of the counter are controlled."]
1212 pub const GATED_MODE: Self = Self(0x05);
1213 #[doc = "Trigger Mode - The counter starts at a rising edge of the trigger TRGI (but it is not reset). Only the start of the counter is controlled."]
1214 pub const TRIGGER_MODE: Self = Self(0x06);
1215 #[doc = "External Clock Mode 1 - Rising edges of the selected trigger (TRGI) clock the counter."]
1216 pub const EXT_CLOCK_MODE: Self = Self(0x07);
1217 }
1218 #[repr(transparent)]
1219 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1220 pub struct CcmrInputCcs(pub u8);
1221 impl CcmrInputCcs {
1222 #[doc = "CCx channel is configured as input, normal mapping: ICx mapped to TIx"]
1223 pub const TI4: Self = Self(0x01);
1224 #[doc = "CCx channel is configured as input, alternate mapping (switches 1 with 2, 3 with 4)"]
1225 pub const TI3: Self = Self(0x02);
1226 #[doc = "CCx channel is configured as input, ICx is mapped on TRC"]
1227 pub const TRC: Self = Self(0x03);
1228 }
1229 #[repr(transparent)]
1230 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1231 pub struct Ossi(pub u8);
1232 impl Ossi {
1233 #[doc = "When inactive, OC/OCN outputs are disabled"]
1234 pub const DISABLED: Self = Self(0); 2007 pub const DISABLED: Self = Self(0);
1235 #[doc = "When inactive, OC/OCN outputs are forced to idle level"] 2008 #[doc = "TIMx_APRR register is buffered"]
1236 pub const IDLELEVEL: Self = Self(0x01); 2009 pub const ENABLED: Self = Self(0x01);
1237 } 2010 }
1238 #[repr(transparent)] 2011 #[repr(transparent)]
1239 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 2012 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1240 pub struct Urs(pub u8); 2013 pub struct Dir(pub u8);
1241 impl Urs { 2014 impl Dir {
1242 #[doc = "Any of counter overflow/underflow, setting UG, or update through slave mode, generates an update interrupt or DMA request"] 2015 #[doc = "Counter used as upcounter"]
1243 pub const ANYEVENT: Self = Self(0); 2016 pub const UP: Self = Self(0);
1244 #[doc = "Only counter overflow/underflow generates an update interrupt or DMA request"] 2017 #[doc = "Counter used as downcounter"]
1245 pub const COUNTERONLY: Self = Self(0x01); 2018 pub const DOWN: Self = Self(0x01);
1246 } 2019 }
1247 #[repr(transparent)] 2020 #[repr(transparent)]
1248 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 2021 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1249 pub struct Opm(pub u8); 2022 pub struct Cms(pub u8);
1250 impl Opm { 2023 impl Cms {
1251 #[doc = "Counter is not stopped at update event"] 2024 #[doc = "The counter counts up or down depending on the direction bit"]
1252 pub const DISABLED: Self = Self(0); 2025 pub const EDGEALIGNED: Self = Self(0);
1253 #[doc = "Counter stops counting at the next update event (clearing the CEN bit)"] 2026 #[doc = "The counter counts up and down alternatively. Output compare interrupt flags are set only when the counter is counting down."]
1254 pub const ENABLED: Self = Self(0x01); 2027 pub const CENTERALIGNED1: Self = Self(0x01);
2028 #[doc = "The counter counts up and down alternatively. Output compare interrupt flags are set only when the counter is counting up."]
2029 pub const CENTERALIGNED2: Self = Self(0x02);
2030 #[doc = "The counter counts up and down alternatively. Output compare interrupt flags are set both when the counter is counting up or down."]
2031 pub const CENTERALIGNED3: Self = Self(0x03);
1255 } 2032 }
1256 #[repr(transparent)] 2033 #[repr(transparent)]
1257 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 2034 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
@@ -1276,115 +2053,49 @@ pub mod timer_v1 {
1276 } 2053 }
1277 #[repr(transparent)] 2054 #[repr(transparent)]
1278 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 2055 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1279 pub struct Arpe(pub u8); 2056 pub struct Ocpe(pub u8);
1280 impl Arpe { 2057 impl Ocpe {
1281 #[doc = "TIMx_APRR register is not buffered"] 2058 #[doc = "Preload register on CCR2 disabled. New values written to CCR2 are taken into account immediately"]
1282 pub const DISABLED: Self = Self(0); 2059 pub const DISABLED: Self = Self(0);
1283 #[doc = "TIMx_APRR register is buffered"] 2060 #[doc = "Preload register on CCR2 enabled. Preload value is loaded into active register on each update event"]
1284 pub const ENABLED: Self = Self(0x01); 2061 pub const ENABLED: Self = Self(0x01);
1285 } 2062 }
1286 #[repr(transparent)] 2063 #[repr(transparent)]
1287 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 2064 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1288 pub struct Cms(pub u8); 2065 pub struct Icf(pub u8);
1289 impl Cms { 2066 impl Icf {
1290 #[doc = "The counter counts up or down depending on the direction bit"] 2067 #[doc = "No filter, sampling is done at fDTS"]
1291 pub const EDGEALIGNED: Self = Self(0); 2068 pub const NOFILTER: Self = Self(0);
1292 #[doc = "The counter counts up and down alternatively. Output compare interrupt flags are set only when the counter is counting down."] 2069 #[doc = "fSAMPLING=fCK_INT, N=2"]
1293 pub const CENTERALIGNED1: Self = Self(0x01); 2070 pub const FCK_INT_N2: Self = Self(0x01);
1294 #[doc = "The counter counts up and down alternatively. Output compare interrupt flags are set only when the counter is counting up."] 2071 #[doc = "fSAMPLING=fCK_INT, N=4"]
1295 pub const CENTERALIGNED2: Self = Self(0x02); 2072 pub const FCK_INT_N4: Self = Self(0x02);
1296 #[doc = "The counter counts up and down alternatively. Output compare interrupt flags are set both when the counter is counting up or down."] 2073 #[doc = "fSAMPLING=fCK_INT, N=8"]
1297 pub const CENTERALIGNED3: Self = Self(0x03); 2074 pub const FCK_INT_N8: Self = Self(0x03);
1298 } 2075 #[doc = "fSAMPLING=fDTS/2, N=6"]
1299 #[repr(transparent)] 2076 pub const FDTS_DIV2_N6: Self = Self(0x04);
1300 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 2077 #[doc = "fSAMPLING=fDTS/2, N=8"]
1301 pub struct Ocm(pub u8); 2078 pub const FDTS_DIV2_N8: Self = Self(0x05);
1302 impl Ocm { 2079 #[doc = "fSAMPLING=fDTS/4, N=6"]
1303 #[doc = "The comparison between the output compare register TIMx_CCRy and the counter TIMx_CNT has no effect on the outputs"] 2080 pub const FDTS_DIV4_N6: Self = Self(0x06);
1304 pub const FROZEN: Self = Self(0); 2081 #[doc = "fSAMPLING=fDTS/4, N=8"]
1305 #[doc = "Set channel to active level on match. OCyREF signal is forced high when the counter matches the capture/compare register"] 2082 pub const FDTS_DIV4_N8: Self = Self(0x07);
1306 pub const ACTIVEONMATCH: Self = Self(0x01); 2083 #[doc = "fSAMPLING=fDTS/8, N=6"]
1307 #[doc = "Set channel to inactive level on match. OCyREF signal is forced low when the counter matches the capture/compare register"] 2084 pub const FDTS_DIV8_N6: Self = Self(0x08);
1308 pub const INACTIVEONMATCH: Self = Self(0x02); 2085 #[doc = "fSAMPLING=fDTS/8, N=8"]
1309 #[doc = "OCyREF toggles when TIMx_CNT=TIMx_CCRy"] 2086 pub const FDTS_DIV8_N8: Self = Self(0x09);
1310 pub const TOGGLE: Self = Self(0x03); 2087 #[doc = "fSAMPLING=fDTS/16, N=5"]
1311 #[doc = "OCyREF is forced low"] 2088 pub const FDTS_DIV16_N5: Self = Self(0x0a);
1312 pub const FORCEINACTIVE: Self = Self(0x04); 2089 #[doc = "fSAMPLING=fDTS/16, N=6"]
1313 #[doc = "OCyREF is forced high"] 2090 pub const FDTS_DIV16_N6: Self = Self(0x0b);
1314 pub const FORCEACTIVE: Self = Self(0x05); 2091 #[doc = "fSAMPLING=fDTS/16, N=8"]
1315 #[doc = "In upcounting, channel is active as long as TIMx_CNT<TIMx_CCRy else inactive. In downcounting, channel is inactive as long as TIMx_CNT>TIMx_CCRy else active"] 2092 pub const FDTS_DIV16_N8: Self = Self(0x0c);
1316 pub const PWMMODE1: Self = Self(0x06); 2093 #[doc = "fSAMPLING=fDTS/32, N=5"]
1317 #[doc = "Inversely to PwmMode1"] 2094 pub const FDTS_DIV32_N5: Self = Self(0x0d);
1318 pub const PWMMODE2: Self = Self(0x07); 2095 #[doc = "fSAMPLING=fDTS/32, N=6"]
1319 } 2096 pub const FDTS_DIV32_N6: Self = Self(0x0e);
1320 #[repr(transparent)] 2097 #[doc = "fSAMPLING=fDTS/32, N=8"]
1321 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 2098 pub const FDTS_DIV32_N8: Self = Self(0x0f);
1322 pub struct Tis(pub u8);
1323 impl Tis {
1324 #[doc = "The TIMx_CH1 pin is connected to TI1 input"]
1325 pub const NORMAL: Self = Self(0);
1326 #[doc = "The TIMx_CH1, CH2, CH3 pins are connected to TI1 input"]
1327 pub const XOR: Self = Self(0x01);
1328 }
1329 #[repr(transparent)]
1330 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1331 pub struct Ckd(pub u8);
1332 impl Ckd {
1333 #[doc = "t_DTS = t_CK_INT"]
1334 pub const DIV1: Self = Self(0);
1335 #[doc = "t_DTS = 2 × t_CK_INT"]
1336 pub const DIV2: Self = Self(0x01);
1337 #[doc = "t_DTS = 4 × t_CK_INT"]
1338 pub const DIV4: Self = Self(0x02);
1339 }
1340 #[repr(transparent)]
1341 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1342 pub struct Ossr(pub u8);
1343 impl Ossr {
1344 #[doc = "When inactive, OC/OCN outputs are disabled"]
1345 pub const DISABLED: Self = Self(0);
1346 #[doc = "When inactive, OC/OCN outputs are enabled with their inactive level"]
1347 pub const IDLELEVEL: Self = Self(0x01);
1348 }
1349 #[repr(transparent)]
1350 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1351 pub struct Etp(pub u8);
1352 impl Etp {
1353 #[doc = "ETR is noninverted, active at high level or rising edge"]
1354 pub const NOTINVERTED: Self = Self(0);
1355 #[doc = "ETR is inverted, active at low level or falling edge"]
1356 pub const INVERTED: Self = Self(0x01);
1357 }
1358 #[repr(transparent)]
1359 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1360 pub struct Etps(pub u8);
1361 impl Etps {
1362 #[doc = "Prescaler OFF"]
1363 pub const DIV1: Self = Self(0);
1364 #[doc = "ETRP frequency divided by 2"]
1365 pub const DIV2: Self = Self(0x01);
1366 #[doc = "ETRP frequency divided by 4"]
1367 pub const DIV4: Self = Self(0x02);
1368 #[doc = "ETRP frequency divided by 8"]
1369 pub const DIV8: Self = Self(0x03);
1370 }
1371 #[repr(transparent)]
1372 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1373 pub struct Msm(pub u8);
1374 impl Msm {
1375 #[doc = "No action"]
1376 pub const NOSYNC: Self = Self(0);
1377 #[doc = "The effect of an event on the trigger input (TRGI) is delayed to allow a perfect synchronization between the current timer and its slaves (through TRGO). It is useful if we want to synchronize several timers on a single external event."]
1378 pub const SYNC: Self = Self(0x01);
1379 }
1380 #[repr(transparent)]
1381 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1382 pub struct Ccds(pub u8);
1383 impl Ccds {
1384 #[doc = "CCx DMA request sent when CCx event occurs"]
1385 pub const ONCOMPARE: Self = Self(0);
1386 #[doc = "CCx DMA request sent when update event occurs"]
1387 pub const ONUPDATE: Self = Self(0x01);
1388 } 2099 }
1389 #[repr(transparent)] 2100 #[repr(transparent)]
1390 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 2101 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
@@ -1425,21 +2136,75 @@ pub mod timer_v1 {
1425 } 2136 }
1426 #[repr(transparent)] 2137 #[repr(transparent)]
1427 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 2138 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1428 pub struct Ocpe(pub u8); 2139 pub struct Etps(pub u8);
1429 impl Ocpe { 2140 impl Etps {
1430 #[doc = "Preload register on CCR2 disabled. New values written to CCR2 are taken into account immediately"] 2141 #[doc = "Prescaler OFF"]
2142 pub const DIV1: Self = Self(0);
2143 #[doc = "ETRP frequency divided by 2"]
2144 pub const DIV2: Self = Self(0x01);
2145 #[doc = "ETRP frequency divided by 4"]
2146 pub const DIV4: Self = Self(0x02);
2147 #[doc = "ETRP frequency divided by 8"]
2148 pub const DIV8: Self = Self(0x03);
2149 }
2150 #[repr(transparent)]
2151 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
2152 pub struct Msm(pub u8);
2153 impl Msm {
2154 #[doc = "No action"]
2155 pub const NOSYNC: Self = Self(0);
2156 #[doc = "The effect of an event on the trigger input (TRGI) is delayed to allow a perfect synchronization between the current timer and its slaves (through TRGO). It is useful if we want to synchronize several timers on a single external event."]
2157 pub const SYNC: Self = Self(0x01);
2158 }
2159 #[repr(transparent)]
2160 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
2161 pub struct Ece(pub u8);
2162 impl Ece {
2163 #[doc = "External clock mode 2 disabled"]
1431 pub const DISABLED: Self = Self(0); 2164 pub const DISABLED: Self = Self(0);
1432 #[doc = "Preload register on CCR2 enabled. Preload value is loaded into active register on each update event"] 2165 #[doc = "External clock mode 2 enabled. The counter is clocked by any active edge on the ETRF signal."]
1433 pub const ENABLED: Self = Self(0x01); 2166 pub const ENABLED: Self = Self(0x01);
1434 } 2167 }
1435 #[repr(transparent)] 2168 #[repr(transparent)]
1436 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 2169 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1437 pub struct Dir(pub u8); 2170 pub struct CcmrInputCcs(pub u8);
1438 impl Dir { 2171 impl CcmrInputCcs {
1439 #[doc = "Counter used as upcounter"] 2172 #[doc = "CCx channel is configured as input, normal mapping: ICx mapped to TIx"]
1440 pub const UP: Self = Self(0); 2173 pub const TI4: Self = Self(0x01);
1441 #[doc = "Counter used as downcounter"] 2174 #[doc = "CCx channel is configured as input, alternate mapping (switches 1 with 2, 3 with 4)"]
1442 pub const DOWN: Self = Self(0x01); 2175 pub const TI3: Self = Self(0x02);
2176 #[doc = "CCx channel is configured as input, ICx is mapped on TRC"]
2177 pub const TRC: Self = Self(0x03);
2178 }
2179 #[repr(transparent)]
2180 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
2181 pub struct Ossi(pub u8);
2182 impl Ossi {
2183 #[doc = "When inactive, OC/OCN outputs are disabled"]
2184 pub const DISABLED: Self = Self(0);
2185 #[doc = "When inactive, OC/OCN outputs are forced to idle level"]
2186 pub const IDLELEVEL: Self = Self(0x01);
2187 }
2188 #[repr(transparent)]
2189 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
2190 pub struct Sms(pub u8);
2191 impl Sms {
2192 #[doc = "Slave mode disabled - if CEN = ‘1 then the prescaler is clocked directly by the internal clock."]
2193 pub const DISABLED: Self = Self(0);
2194 #[doc = "Encoder mode 1 - Counter counts up/down on TI2FP1 edge depending on TI1FP2 level."]
2195 pub const ENCODER_MODE_1: Self = Self(0x01);
2196 #[doc = "Encoder mode 2 - Counter counts up/down on TI1FP2 edge depending on TI2FP1 level."]
2197 pub const ENCODER_MODE_2: Self = Self(0x02);
2198 #[doc = "Encoder mode 3 - Counter counts up/down on both TI1FP1 and TI2FP2 edges depending on the level of the other input."]
2199 pub const ENCODER_MODE_3: Self = Self(0x03);
2200 #[doc = "Reset Mode - Rising edge of the selected trigger input (TRGI) reinitializes the counter and generates an update of the registers."]
2201 pub const RESET_MODE: Self = Self(0x04);
2202 #[doc = "Gated Mode - The counter clock is enabled when the trigger input (TRGI) is high. The counter stops (but is not reset) as soon as the trigger becomes low. Both start and stop of the counter are controlled."]
2203 pub const GATED_MODE: Self = Self(0x05);
2204 #[doc = "Trigger Mode - The counter starts at a rising edge of the trigger TRGI (but it is not reset). Only the start of the counter is controlled."]
2205 pub const TRIGGER_MODE: Self = Self(0x06);
2206 #[doc = "External Clock Mode 1 - Rising edges of the selected trigger (TRGI) clock the counter."]
2207 pub const EXT_CLOCK_MODE: Self = Self(0x07);
1443 } 2208 }
1444 #[repr(transparent)] 2209 #[repr(transparent)]
1445 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 2210 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
@@ -1450,6 +2215,15 @@ pub mod timer_v1 {
1450 } 2215 }
1451 #[repr(transparent)] 2216 #[repr(transparent)]
1452 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 2217 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
2218 pub struct Urs(pub u8);
2219 impl Urs {
2220 #[doc = "Any of counter overflow/underflow, setting UG, or update through slave mode, generates an update interrupt or DMA request"]
2221 pub const ANYEVENT: Self = Self(0);
2222 #[doc = "Only counter overflow/underflow generates an update interrupt or DMA request"]
2223 pub const COUNTERONLY: Self = Self(0x01);
2224 }
2225 #[repr(transparent)]
2226 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1453 pub struct Ts(pub u8); 2227 pub struct Ts(pub u8);
1454 impl Ts { 2228 impl Ts {
1455 #[doc = "Internal Trigger 0 (ITR0)"] 2229 #[doc = "Internal Trigger 0 (ITR0)"]
@@ -1467,217 +2241,264 @@ pub mod timer_v1 {
1467 #[doc = "External Trigger input (ETRF)"] 2241 #[doc = "External Trigger input (ETRF)"]
1468 pub const ETRF: Self = Self(0x07); 2242 pub const ETRF: Self = Self(0x07);
1469 } 2243 }
1470 }
1471 pub mod regs {
1472 use crate::generic::*;
1473 #[doc = "prescaler"]
1474 #[repr(transparent)] 2244 #[repr(transparent)]
1475 #[derive(Copy, Clone, Eq, PartialEq)] 2245 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1476 pub struct Psc(pub u32); 2246 pub struct Ossr(pub u8);
1477 impl Psc { 2247 impl Ossr {
1478 #[doc = "Prescaler value"] 2248 #[doc = "When inactive, OC/OCN outputs are disabled"]
1479 pub const fn psc(&self) -> u16 { 2249 pub const DISABLED: Self = Self(0);
1480 let val = (self.0 >> 0usize) & 0xffff; 2250 #[doc = "When inactive, OC/OCN outputs are enabled with their inactive level"]
1481 val as u16 2251 pub const IDLELEVEL: Self = Self(0x01);
1482 }
1483 #[doc = "Prescaler value"]
1484 pub fn set_psc(&mut self, val: u16) {
1485 self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
1486 }
1487 } 2252 }
1488 impl Default for Psc { 2253 #[repr(transparent)]
1489 fn default() -> Psc { 2254 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1490 Psc(0) 2255 pub struct Ckd(pub u8);
1491 } 2256 impl Ckd {
2257 #[doc = "t_DTS = t_CK_INT"]
2258 pub const DIV1: Self = Self(0);
2259 #[doc = "t_DTS = 2 × t_CK_INT"]
2260 pub const DIV2: Self = Self(0x01);
2261 #[doc = "t_DTS = 4 × t_CK_INT"]
2262 pub const DIV4: Self = Self(0x02);
1492 } 2263 }
1493 #[doc = "control register 2"] 2264 #[repr(transparent)]
2265 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
2266 pub struct Ccds(pub u8);
2267 impl Ccds {
2268 #[doc = "CCx DMA request sent when CCx event occurs"]
2269 pub const ONCOMPARE: Self = Self(0);
2270 #[doc = "CCx DMA request sent when update event occurs"]
2271 pub const ONUPDATE: Self = Self(0x01);
2272 }
2273 #[repr(transparent)]
2274 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
2275 pub struct Etp(pub u8);
2276 impl Etp {
2277 #[doc = "ETR is noninverted, active at high level or rising edge"]
2278 pub const NOTINVERTED: Self = Self(0);
2279 #[doc = "ETR is inverted, active at low level or falling edge"]
2280 pub const INVERTED: Self = Self(0x01);
2281 }
2282 #[repr(transparent)]
2283 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
2284 pub struct Tis(pub u8);
2285 impl Tis {
2286 #[doc = "The TIMx_CH1 pin is connected to TI1 input"]
2287 pub const NORMAL: Self = Self(0);
2288 #[doc = "The TIMx_CH1, CH2, CH3 pins are connected to TI1 input"]
2289 pub const XOR: Self = Self(0x01);
2290 }
2291 }
2292 pub mod regs {
2293 use crate::generic::*;
2294 #[doc = "status register"]
1494 #[repr(transparent)] 2295 #[repr(transparent)]
1495 #[derive(Copy, Clone, Eq, PartialEq)] 2296 #[derive(Copy, Clone, Eq, PartialEq)]
1496 pub struct Cr2Adv(pub u32); 2297 pub struct SrGp(pub u32);
1497 impl Cr2Adv { 2298 impl SrGp {
1498 #[doc = "Capture/compare preloaded control"] 2299 #[doc = "Update interrupt flag"]
1499 pub const fn ccpc(&self) -> bool { 2300 pub const fn uif(&self) -> bool {
1500 let val = (self.0 >> 0usize) & 0x01; 2301 let val = (self.0 >> 0usize) & 0x01;
1501 val != 0 2302 val != 0
1502 } 2303 }
1503 #[doc = "Capture/compare preloaded control"] 2304 #[doc = "Update interrupt flag"]
1504 pub fn set_ccpc(&mut self, val: bool) { 2305 pub fn set_uif(&mut self, val: bool) {
1505 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); 2306 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
1506 } 2307 }
1507 #[doc = "Capture/compare control update selection"] 2308 #[doc = "Capture/compare 1 interrupt flag"]
1508 pub const fn ccus(&self) -> bool { 2309 pub fn ccif(&self, n: usize) -> bool {
1509 let val = (self.0 >> 2usize) & 0x01; 2310 assert!(n < 4usize);
2311 let offs = 1usize + n * 1usize;
2312 let val = (self.0 >> offs) & 0x01;
1510 val != 0 2313 val != 0
1511 } 2314 }
1512 #[doc = "Capture/compare control update selection"] 2315 #[doc = "Capture/compare 1 interrupt flag"]
1513 pub fn set_ccus(&mut self, val: bool) { 2316 pub fn set_ccif(&mut self, n: usize, val: bool) {
1514 self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); 2317 assert!(n < 4usize);
2318 let offs = 1usize + n * 1usize;
2319 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
1515 } 2320 }
1516 #[doc = "Capture/compare DMA selection"] 2321 #[doc = "COM interrupt flag"]
1517 pub const fn ccds(&self) -> super::vals::Ccds { 2322 pub const fn comif(&self) -> bool {
1518 let val = (self.0 >> 3usize) & 0x01; 2323 let val = (self.0 >> 5usize) & 0x01;
1519 super::vals::Ccds(val as u8) 2324 val != 0
1520 } 2325 }
1521 #[doc = "Capture/compare DMA selection"] 2326 #[doc = "COM interrupt flag"]
1522 pub fn set_ccds(&mut self, val: super::vals::Ccds) { 2327 pub fn set_comif(&mut self, val: bool) {
1523 self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize); 2328 self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
1524 } 2329 }
1525 #[doc = "Master mode selection"] 2330 #[doc = "Trigger interrupt flag"]
1526 pub const fn mms(&self) -> super::vals::Mms { 2331 pub const fn tif(&self) -> bool {
1527 let val = (self.0 >> 4usize) & 0x07; 2332 let val = (self.0 >> 6usize) & 0x01;
1528 super::vals::Mms(val as u8) 2333 val != 0
1529 } 2334 }
1530 #[doc = "Master mode selection"] 2335 #[doc = "Trigger interrupt flag"]
1531 pub fn set_mms(&mut self, val: super::vals::Mms) { 2336 pub fn set_tif(&mut self, val: bool) {
1532 self.0 = (self.0 & !(0x07 << 4usize)) | (((val.0 as u32) & 0x07) << 4usize); 2337 self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
1533 } 2338 }
1534 #[doc = "TI1 selection"] 2339 #[doc = "Break interrupt flag"]
1535 pub const fn ti1s(&self) -> super::vals::Tis { 2340 pub const fn bif(&self) -> bool {
1536 let val = (self.0 >> 7usize) & 0x01; 2341 let val = (self.0 >> 7usize) & 0x01;
1537 super::vals::Tis(val as u8) 2342 val != 0
1538 } 2343 }
1539 #[doc = "TI1 selection"] 2344 #[doc = "Break interrupt flag"]
1540 pub fn set_ti1s(&mut self, val: super::vals::Tis) { 2345 pub fn set_bif(&mut self, val: bool) {
1541 self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize); 2346 self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
1542 } 2347 }
1543 #[doc = "Output Idle state 1"] 2348 #[doc = "Capture/Compare 1 overcapture flag"]
1544 pub fn ois(&self, n: usize) -> bool { 2349 pub fn ccof(&self, n: usize) -> bool {
1545 assert!(n < 4usize); 2350 assert!(n < 4usize);
1546 let offs = 8usize + n * 2usize; 2351 let offs = 9usize + n * 1usize;
1547 let val = (self.0 >> offs) & 0x01; 2352 let val = (self.0 >> offs) & 0x01;
1548 val != 0 2353 val != 0
1549 } 2354 }
1550 #[doc = "Output Idle state 1"] 2355 #[doc = "Capture/Compare 1 overcapture flag"]
1551 pub fn set_ois(&mut self, n: usize, val: bool) { 2356 pub fn set_ccof(&mut self, n: usize, val: bool) {
1552 assert!(n < 4usize); 2357 assert!(n < 4usize);
1553 let offs = 8usize + n * 2usize; 2358 let offs = 9usize + n * 1usize;
1554 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); 2359 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
1555 } 2360 }
1556 #[doc = "Output Idle state 1"] 2361 }
1557 pub const fn ois1n(&self) -> bool { 2362 impl Default for SrGp {
1558 let val = (self.0 >> 9usize) & 0x01; 2363 fn default() -> SrGp {
1559 val != 0 2364 SrGp(0)
1560 } 2365 }
1561 #[doc = "Output Idle state 1"] 2366 }
1562 pub fn set_ois1n(&mut self, val: bool) { 2367 #[doc = "prescaler"]
1563 self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize); 2368 #[repr(transparent)]
2369 #[derive(Copy, Clone, Eq, PartialEq)]
2370 pub struct Psc(pub u32);
2371 impl Psc {
2372 #[doc = "Prescaler value"]
2373 pub const fn psc(&self) -> u16 {
2374 let val = (self.0 >> 0usize) & 0xffff;
2375 val as u16
1564 } 2376 }
1565 #[doc = "Output Idle state 2"] 2377 #[doc = "Prescaler value"]
1566 pub const fn ois2n(&self) -> bool { 2378 pub fn set_psc(&mut self, val: u16) {
1567 let val = (self.0 >> 11usize) & 0x01; 2379 self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
1568 val != 0
1569 } 2380 }
1570 #[doc = "Output Idle state 2"] 2381 }
1571 pub fn set_ois2n(&mut self, val: bool) { 2382 impl Default for Psc {
1572 self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize); 2383 fn default() -> Psc {
2384 Psc(0)
1573 } 2385 }
1574 #[doc = "Output Idle state 3"] 2386 }
1575 pub const fn ois3n(&self) -> bool { 2387 #[doc = "status register"]
1576 let val = (self.0 >> 13usize) & 0x01; 2388 #[repr(transparent)]
2389 #[derive(Copy, Clone, Eq, PartialEq)]
2390 pub struct SrBasic(pub u32);
2391 impl SrBasic {
2392 #[doc = "Update interrupt flag"]
2393 pub const fn uif(&self) -> bool {
2394 let val = (self.0 >> 0usize) & 0x01;
1577 val != 0 2395 val != 0
1578 } 2396 }
1579 #[doc = "Output Idle state 3"] 2397 #[doc = "Update interrupt flag"]
1580 pub fn set_ois3n(&mut self, val: bool) { 2398 pub fn set_uif(&mut self, val: bool) {
1581 self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize); 2399 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
1582 } 2400 }
1583 } 2401 }
1584 impl Default for Cr2Adv { 2402 impl Default for SrBasic {
1585 fn default() -> Cr2Adv { 2403 fn default() -> SrBasic {
1586 Cr2Adv(0) 2404 SrBasic(0)
1587 } 2405 }
1588 } 2406 }
1589 #[doc = "control register 2"] 2407 #[doc = "counter"]
1590 #[repr(transparent)] 2408 #[repr(transparent)]
1591 #[derive(Copy, Clone, Eq, PartialEq)] 2409 #[derive(Copy, Clone, Eq, PartialEq)]
1592 pub struct Cr2Basic(pub u32); 2410 pub struct Cnt16(pub u32);
1593 impl Cr2Basic { 2411 impl Cnt16 {
1594 #[doc = "Master mode selection"] 2412 #[doc = "counter value"]
1595 pub const fn mms(&self) -> super::vals::Mms { 2413 pub const fn cnt(&self) -> u16 {
1596 let val = (self.0 >> 4usize) & 0x07; 2414 let val = (self.0 >> 0usize) & 0xffff;
1597 super::vals::Mms(val as u8) 2415 val as u16
1598 } 2416 }
1599 #[doc = "Master mode selection"] 2417 #[doc = "counter value"]
1600 pub fn set_mms(&mut self, val: super::vals::Mms) { 2418 pub fn set_cnt(&mut self, val: u16) {
1601 self.0 = (self.0 & !(0x07 << 4usize)) | (((val.0 as u32) & 0x07) << 4usize); 2419 self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
1602 } 2420 }
1603 } 2421 }
1604 impl Default for Cr2Basic { 2422 impl Default for Cnt16 {
1605 fn default() -> Cr2Basic { 2423 fn default() -> Cnt16 {
1606 Cr2Basic(0) 2424 Cnt16(0)
1607 } 2425 }
1608 } 2426 }
1609 #[doc = "slave mode control register"] 2427 #[doc = "counter"]
1610 #[repr(transparent)] 2428 #[repr(transparent)]
1611 #[derive(Copy, Clone, Eq, PartialEq)] 2429 #[derive(Copy, Clone, Eq, PartialEq)]
1612 pub struct Smcr(pub u32); 2430 pub struct Cnt32(pub u32);
1613 impl Smcr { 2431 impl Cnt32 {
1614 #[doc = "Slave mode selection"] 2432 #[doc = "counter value"]
1615 pub const fn sms(&self) -> super::vals::Sms { 2433 pub const fn cnt(&self) -> u32 {
1616 let val = (self.0 >> 0usize) & 0x07; 2434 let val = (self.0 >> 0usize) & 0xffff_ffff;
1617 super::vals::Sms(val as u8) 2435 val as u32
1618 }
1619 #[doc = "Slave mode selection"]
1620 pub fn set_sms(&mut self, val: super::vals::Sms) {
1621 self.0 = (self.0 & !(0x07 << 0usize)) | (((val.0 as u32) & 0x07) << 0usize);
1622 } 2436 }
1623 #[doc = "Trigger selection"] 2437 #[doc = "counter value"]
1624 pub const fn ts(&self) -> super::vals::Ts { 2438 pub fn set_cnt(&mut self, val: u32) {
1625 let val = (self.0 >> 4usize) & 0x07; 2439 self.0 =
1626 super::vals::Ts(val as u8) 2440 (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize);
1627 } 2441 }
1628 #[doc = "Trigger selection"] 2442 }
1629 pub fn set_ts(&mut self, val: super::vals::Ts) { 2443 impl Default for Cnt32 {
1630 self.0 = (self.0 & !(0x07 << 4usize)) | (((val.0 as u32) & 0x07) << 4usize); 2444 fn default() -> Cnt32 {
2445 Cnt32(0)
1631 } 2446 }
1632 #[doc = "Master/Slave mode"] 2447 }
1633 pub const fn msm(&self) -> super::vals::Msm { 2448 #[doc = "control register 1"]
1634 let val = (self.0 >> 7usize) & 0x01; 2449 #[repr(transparent)]
1635 super::vals::Msm(val as u8) 2450 #[derive(Copy, Clone, Eq, PartialEq)]
2451 pub struct Cr1Basic(pub u32);
2452 impl Cr1Basic {
2453 #[doc = "Counter enable"]
2454 pub const fn cen(&self) -> bool {
2455 let val = (self.0 >> 0usize) & 0x01;
2456 val != 0
1636 } 2457 }
1637 #[doc = "Master/Slave mode"] 2458 #[doc = "Counter enable"]
1638 pub fn set_msm(&mut self, val: super::vals::Msm) { 2459 pub fn set_cen(&mut self, val: bool) {
1639 self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize); 2460 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
1640 } 2461 }
1641 #[doc = "External trigger filter"] 2462 #[doc = "Update disable"]
1642 pub const fn etf(&self) -> super::vals::Etf { 2463 pub const fn udis(&self) -> bool {
1643 let val = (self.0 >> 8usize) & 0x0f; 2464 let val = (self.0 >> 1usize) & 0x01;
1644 super::vals::Etf(val as u8) 2465 val != 0
1645 } 2466 }
1646 #[doc = "External trigger filter"] 2467 #[doc = "Update disable"]
1647 pub fn set_etf(&mut self, val: super::vals::Etf) { 2468 pub fn set_udis(&mut self, val: bool) {
1648 self.0 = (self.0 & !(0x0f << 8usize)) | (((val.0 as u32) & 0x0f) << 8usize); 2469 self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
1649 } 2470 }
1650 #[doc = "External trigger prescaler"] 2471 #[doc = "Update request source"]
1651 pub const fn etps(&self) -> super::vals::Etps { 2472 pub const fn urs(&self) -> super::vals::Urs {
1652 let val = (self.0 >> 12usize) & 0x03; 2473 let val = (self.0 >> 2usize) & 0x01;
1653 super::vals::Etps(val as u8) 2474 super::vals::Urs(val as u8)
1654 } 2475 }
1655 #[doc = "External trigger prescaler"] 2476 #[doc = "Update request source"]
1656 pub fn set_etps(&mut self, val: super::vals::Etps) { 2477 pub fn set_urs(&mut self, val: super::vals::Urs) {
1657 self.0 = (self.0 & !(0x03 << 12usize)) | (((val.0 as u32) & 0x03) << 12usize); 2478 self.0 = (self.0 & !(0x01 << 2usize)) | (((val.0 as u32) & 0x01) << 2usize);
1658 } 2479 }
1659 #[doc = "External clock enable"] 2480 #[doc = "One-pulse mode"]
1660 pub const fn ece(&self) -> super::vals::Ece { 2481 pub const fn opm(&self) -> super::vals::Opm {
1661 let val = (self.0 >> 14usize) & 0x01; 2482 let val = (self.0 >> 3usize) & 0x01;
1662 super::vals::Ece(val as u8) 2483 super::vals::Opm(val as u8)
1663 } 2484 }
1664 #[doc = "External clock enable"] 2485 #[doc = "One-pulse mode"]
1665 pub fn set_ece(&mut self, val: super::vals::Ece) { 2486 pub fn set_opm(&mut self, val: super::vals::Opm) {
1666 self.0 = (self.0 & !(0x01 << 14usize)) | (((val.0 as u32) & 0x01) << 14usize); 2487 self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize);
1667 } 2488 }
1668 #[doc = "External trigger polarity"] 2489 #[doc = "Auto-reload preload enable"]
1669 pub const fn etp(&self) -> super::vals::Etp { 2490 pub const fn arpe(&self) -> super::vals::Arpe {
1670 let val = (self.0 >> 15usize) & 0x01; 2491 let val = (self.0 >> 7usize) & 0x01;
1671 super::vals::Etp(val as u8) 2492 super::vals::Arpe(val as u8)
1672 } 2493 }
1673 #[doc = "External trigger polarity"] 2494 #[doc = "Auto-reload preload enable"]
1674 pub fn set_etp(&mut self, val: super::vals::Etp) { 2495 pub fn set_arpe(&mut self, val: super::vals::Arpe) {
1675 self.0 = (self.0 & !(0x01 << 15usize)) | (((val.0 as u32) & 0x01) << 15usize); 2496 self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize);
1676 } 2497 }
1677 } 2498 }
1678 impl Default for Smcr { 2499 impl Default for Cr1Basic {
1679 fn default() -> Smcr { 2500 fn default() -> Cr1Basic {
1680 Smcr(0) 2501 Cr1Basic(0)
1681 } 2502 }
1682 } 2503 }
1683 #[doc = "capture/compare mode register 2 (output mode)"] 2504 #[doc = "capture/compare mode register 2 (output mode)"]
@@ -1756,11 +2577,123 @@ pub mod timer_v1 {
1756 CcmrOutput(0) 2577 CcmrOutput(0)
1757 } 2578 }
1758 } 2579 }
2580 #[doc = "DMA control register"]
2581 #[repr(transparent)]
2582 #[derive(Copy, Clone, Eq, PartialEq)]
2583 pub struct Dcr(pub u32);
2584 impl Dcr {
2585 #[doc = "DMA base address"]
2586 pub const fn dba(&self) -> u8 {
2587 let val = (self.0 >> 0usize) & 0x1f;
2588 val as u8
2589 }
2590 #[doc = "DMA base address"]
2591 pub fn set_dba(&mut self, val: u8) {
2592 self.0 = (self.0 & !(0x1f << 0usize)) | (((val as u32) & 0x1f) << 0usize);
2593 }
2594 #[doc = "DMA burst length"]
2595 pub const fn dbl(&self) -> u8 {
2596 let val = (self.0 >> 8usize) & 0x1f;
2597 val as u8
2598 }
2599 #[doc = "DMA burst length"]
2600 pub fn set_dbl(&mut self, val: u8) {
2601 self.0 = (self.0 & !(0x1f << 8usize)) | (((val as u32) & 0x1f) << 8usize);
2602 }
2603 }
2604 impl Default for Dcr {
2605 fn default() -> Dcr {
2606 Dcr(0)
2607 }
2608 }
2609 #[doc = "auto-reload register"]
2610 #[repr(transparent)]
2611 #[derive(Copy, Clone, Eq, PartialEq)]
2612 pub struct Arr16(pub u32);
2613 impl Arr16 {
2614 #[doc = "Auto-reload value"]
2615 pub const fn arr(&self) -> u16 {
2616 let val = (self.0 >> 0usize) & 0xffff;
2617 val as u16
2618 }
2619 #[doc = "Auto-reload value"]
2620 pub fn set_arr(&mut self, val: u16) {
2621 self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
2622 }
2623 }
2624 impl Default for Arr16 {
2625 fn default() -> Arr16 {
2626 Arr16(0)
2627 }
2628 }
2629 #[doc = "capture/compare enable register"]
2630 #[repr(transparent)]
2631 #[derive(Copy, Clone, Eq, PartialEq)]
2632 pub struct CcerAdv(pub u32);
2633 impl CcerAdv {
2634 #[doc = "Capture/Compare 1 output enable"]
2635 pub fn cce(&self, n: usize) -> bool {
2636 assert!(n < 4usize);
2637 let offs = 0usize + n * 4usize;
2638 let val = (self.0 >> offs) & 0x01;
2639 val != 0
2640 }
2641 #[doc = "Capture/Compare 1 output enable"]
2642 pub fn set_cce(&mut self, n: usize, val: bool) {
2643 assert!(n < 4usize);
2644 let offs = 0usize + n * 4usize;
2645 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2646 }
2647 #[doc = "Capture/Compare 1 output Polarity"]
2648 pub fn ccp(&self, n: usize) -> bool {
2649 assert!(n < 4usize);
2650 let offs = 1usize + n * 4usize;
2651 let val = (self.0 >> offs) & 0x01;
2652 val != 0
2653 }
2654 #[doc = "Capture/Compare 1 output Polarity"]
2655 pub fn set_ccp(&mut self, n: usize, val: bool) {
2656 assert!(n < 4usize);
2657 let offs = 1usize + n * 4usize;
2658 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2659 }
2660 #[doc = "Capture/Compare 1 complementary output enable"]
2661 pub fn ccne(&self, n: usize) -> bool {
2662 assert!(n < 4usize);
2663 let offs = 2usize + n * 4usize;
2664 let val = (self.0 >> offs) & 0x01;
2665 val != 0
2666 }
2667 #[doc = "Capture/Compare 1 complementary output enable"]
2668 pub fn set_ccne(&mut self, n: usize, val: bool) {
2669 assert!(n < 4usize);
2670 let offs = 2usize + n * 4usize;
2671 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2672 }
2673 #[doc = "Capture/Compare 1 output Polarity"]
2674 pub fn ccnp(&self, n: usize) -> bool {
2675 assert!(n < 4usize);
2676 let offs = 3usize + n * 4usize;
2677 let val = (self.0 >> offs) & 0x01;
2678 val != 0
2679 }
2680 #[doc = "Capture/Compare 1 output Polarity"]
2681 pub fn set_ccnp(&mut self, n: usize, val: bool) {
2682 assert!(n < 4usize);
2683 let offs = 3usize + n * 4usize;
2684 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2685 }
2686 }
2687 impl Default for CcerAdv {
2688 fn default() -> CcerAdv {
2689 CcerAdv(0)
2690 }
2691 }
1759 #[doc = "status register"] 2692 #[doc = "status register"]
1760 #[repr(transparent)] 2693 #[repr(transparent)]
1761 #[derive(Copy, Clone, Eq, PartialEq)] 2694 #[derive(Copy, Clone, Eq, PartialEq)]
1762 pub struct SrGp(pub u32); 2695 pub struct SrAdv(pub u32);
1763 impl SrGp { 2696 impl SrAdv {
1764 #[doc = "Update interrupt flag"] 2697 #[doc = "Update interrupt flag"]
1765 pub const fn uif(&self) -> bool { 2698 pub const fn uif(&self) -> bool {
1766 let val = (self.0 >> 0usize) & 0x01; 2699 let val = (self.0 >> 0usize) & 0x01;
@@ -1824,161 +2757,108 @@ pub mod timer_v1 {
1824 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); 2757 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
1825 } 2758 }
1826 } 2759 }
1827 impl Default for SrGp { 2760 impl Default for SrAdv {
1828 fn default() -> SrGp { 2761 fn default() -> SrAdv {
1829 SrGp(0) 2762 SrAdv(0)
1830 } 2763 }
1831 } 2764 }
1832 #[doc = "event generation register"] 2765 #[doc = "slave mode control register"]
1833 #[repr(transparent)] 2766 #[repr(transparent)]
1834 #[derive(Copy, Clone, Eq, PartialEq)] 2767 #[derive(Copy, Clone, Eq, PartialEq)]
1835 pub struct EgrGp(pub u32); 2768 pub struct Smcr(pub u32);
1836 impl EgrGp { 2769 impl Smcr {
1837 #[doc = "Update generation"] 2770 #[doc = "Slave mode selection"]
1838 pub const fn ug(&self) -> bool { 2771 pub const fn sms(&self) -> super::vals::Sms {
1839 let val = (self.0 >> 0usize) & 0x01; 2772 let val = (self.0 >> 0usize) & 0x07;
1840 val != 0 2773 super::vals::Sms(val as u8)
1841 }
1842 #[doc = "Update generation"]
1843 pub fn set_ug(&mut self, val: bool) {
1844 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
1845 }
1846 #[doc = "Capture/compare 1 generation"]
1847 pub fn ccg(&self, n: usize) -> bool {
1848 assert!(n < 4usize);
1849 let offs = 1usize + n * 1usize;
1850 let val = (self.0 >> offs) & 0x01;
1851 val != 0
1852 }
1853 #[doc = "Capture/compare 1 generation"]
1854 pub fn set_ccg(&mut self, n: usize, val: bool) {
1855 assert!(n < 4usize);
1856 let offs = 1usize + n * 1usize;
1857 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
1858 }
1859 #[doc = "Capture/Compare control update generation"]
1860 pub const fn comg(&self) -> bool {
1861 let val = (self.0 >> 5usize) & 0x01;
1862 val != 0
1863 } 2774 }
1864 #[doc = "Capture/Compare control update generation"] 2775 #[doc = "Slave mode selection"]
1865 pub fn set_comg(&mut self, val: bool) { 2776 pub fn set_sms(&mut self, val: super::vals::Sms) {
1866 self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); 2777 self.0 = (self.0 & !(0x07 << 0usize)) | (((val.0 as u32) & 0x07) << 0usize);
1867 } 2778 }
1868 #[doc = "Trigger generation"] 2779 #[doc = "Trigger selection"]
1869 pub const fn tg(&self) -> bool { 2780 pub const fn ts(&self) -> super::vals::Ts {
1870 let val = (self.0 >> 6usize) & 0x01; 2781 let val = (self.0 >> 4usize) & 0x07;
1871 val != 0 2782 super::vals::Ts(val as u8)
1872 } 2783 }
1873 #[doc = "Trigger generation"] 2784 #[doc = "Trigger selection"]
1874 pub fn set_tg(&mut self, val: bool) { 2785 pub fn set_ts(&mut self, val: super::vals::Ts) {
1875 self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); 2786 self.0 = (self.0 & !(0x07 << 4usize)) | (((val.0 as u32) & 0x07) << 4usize);
1876 } 2787 }
1877 #[doc = "Break generation"] 2788 #[doc = "Master/Slave mode"]
1878 pub const fn bg(&self) -> bool { 2789 pub const fn msm(&self) -> super::vals::Msm {
1879 let val = (self.0 >> 7usize) & 0x01; 2790 let val = (self.0 >> 7usize) & 0x01;
1880 val != 0 2791 super::vals::Msm(val as u8)
1881 }
1882 #[doc = "Break generation"]
1883 pub fn set_bg(&mut self, val: bool) {
1884 self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
1885 }
1886 }
1887 impl Default for EgrGp {
1888 fn default() -> EgrGp {
1889 EgrGp(0)
1890 }
1891 }
1892 #[doc = "control register 1"]
1893 #[repr(transparent)]
1894 #[derive(Copy, Clone, Eq, PartialEq)]
1895 pub struct Cr1Basic(pub u32);
1896 impl Cr1Basic {
1897 #[doc = "Counter enable"]
1898 pub const fn cen(&self) -> bool {
1899 let val = (self.0 >> 0usize) & 0x01;
1900 val != 0
1901 } 2792 }
1902 #[doc = "Counter enable"] 2793 #[doc = "Master/Slave mode"]
1903 pub fn set_cen(&mut self, val: bool) { 2794 pub fn set_msm(&mut self, val: super::vals::Msm) {
1904 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); 2795 self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize);
1905 } 2796 }
1906 #[doc = "Update disable"] 2797 #[doc = "External trigger filter"]
1907 pub const fn udis(&self) -> bool { 2798 pub const fn etf(&self) -> super::vals::Etf {
1908 let val = (self.0 >> 1usize) & 0x01; 2799 let val = (self.0 >> 8usize) & 0x0f;
1909 val != 0 2800 super::vals::Etf(val as u8)
1910 } 2801 }
1911 #[doc = "Update disable"] 2802 #[doc = "External trigger filter"]
1912 pub fn set_udis(&mut self, val: bool) { 2803 pub fn set_etf(&mut self, val: super::vals::Etf) {
1913 self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); 2804 self.0 = (self.0 & !(0x0f << 8usize)) | (((val.0 as u32) & 0x0f) << 8usize);
1914 } 2805 }
1915 #[doc = "Update request source"] 2806 #[doc = "External trigger prescaler"]
1916 pub const fn urs(&self) -> super::vals::Urs { 2807 pub const fn etps(&self) -> super::vals::Etps {
1917 let val = (self.0 >> 2usize) & 0x01; 2808 let val = (self.0 >> 12usize) & 0x03;
1918 super::vals::Urs(val as u8) 2809 super::vals::Etps(val as u8)
1919 } 2810 }
1920 #[doc = "Update request source"] 2811 #[doc = "External trigger prescaler"]
1921 pub fn set_urs(&mut self, val: super::vals::Urs) { 2812 pub fn set_etps(&mut self, val: super::vals::Etps) {
1922 self.0 = (self.0 & !(0x01 << 2usize)) | (((val.0 as u32) & 0x01) << 2usize); 2813 self.0 = (self.0 & !(0x03 << 12usize)) | (((val.0 as u32) & 0x03) << 12usize);
1923 } 2814 }
1924 #[doc = "One-pulse mode"] 2815 #[doc = "External clock enable"]
1925 pub const fn opm(&self) -> super::vals::Opm { 2816 pub const fn ece(&self) -> super::vals::Ece {
1926 let val = (self.0 >> 3usize) & 0x01; 2817 let val = (self.0 >> 14usize) & 0x01;
1927 super::vals::Opm(val as u8) 2818 super::vals::Ece(val as u8)
1928 } 2819 }
1929 #[doc = "One-pulse mode"] 2820 #[doc = "External clock enable"]
1930 pub fn set_opm(&mut self, val: super::vals::Opm) { 2821 pub fn set_ece(&mut self, val: super::vals::Ece) {
1931 self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize); 2822 self.0 = (self.0 & !(0x01 << 14usize)) | (((val.0 as u32) & 0x01) << 14usize);
1932 } 2823 }
1933 #[doc = "Auto-reload preload enable"] 2824 #[doc = "External trigger polarity"]
1934 pub const fn arpe(&self) -> super::vals::Arpe { 2825 pub const fn etp(&self) -> super::vals::Etp {
1935 let val = (self.0 >> 7usize) & 0x01; 2826 let val = (self.0 >> 15usize) & 0x01;
1936 super::vals::Arpe(val as u8) 2827 super::vals::Etp(val as u8)
1937 } 2828 }
1938 #[doc = "Auto-reload preload enable"] 2829 #[doc = "External trigger polarity"]
1939 pub fn set_arpe(&mut self, val: super::vals::Arpe) { 2830 pub fn set_etp(&mut self, val: super::vals::Etp) {
1940 self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize); 2831 self.0 = (self.0 & !(0x01 << 15usize)) | (((val.0 as u32) & 0x01) << 15usize);
1941 } 2832 }
1942 } 2833 }
1943 impl Default for Cr1Basic { 2834 impl Default for Smcr {
1944 fn default() -> Cr1Basic { 2835 fn default() -> Smcr {
1945 Cr1Basic(0) 2836 Smcr(0)
1946 } 2837 }
1947 } 2838 }
1948 #[doc = "DMA control register"] 2839 #[doc = "control register 2"]
1949 #[repr(transparent)] 2840 #[repr(transparent)]
1950 #[derive(Copy, Clone, Eq, PartialEq)] 2841 #[derive(Copy, Clone, Eq, PartialEq)]
1951 pub struct Dcr(pub u32); 2842 pub struct Cr2Adv(pub u32);
1952 impl Dcr { 2843 impl Cr2Adv {
1953 #[doc = "DMA base address"] 2844 #[doc = "Capture/compare preloaded control"]
1954 pub const fn dba(&self) -> u8 { 2845 pub const fn ccpc(&self) -> bool {
1955 let val = (self.0 >> 0usize) & 0x1f; 2846 let val = (self.0 >> 0usize) & 0x01;
1956 val as u8 2847 val != 0
1957 }
1958 #[doc = "DMA base address"]
1959 pub fn set_dba(&mut self, val: u8) {
1960 self.0 = (self.0 & !(0x1f << 0usize)) | (((val as u32) & 0x1f) << 0usize);
1961 } 2848 }
1962 #[doc = "DMA burst length"] 2849 #[doc = "Capture/compare preloaded control"]
1963 pub const fn dbl(&self) -> u8 { 2850 pub fn set_ccpc(&mut self, val: bool) {
1964 let val = (self.0 >> 8usize) & 0x1f; 2851 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
1965 val as u8
1966 } 2852 }
1967 #[doc = "DMA burst length"] 2853 #[doc = "Capture/compare control update selection"]
1968 pub fn set_dbl(&mut self, val: u8) { 2854 pub const fn ccus(&self) -> bool {
1969 self.0 = (self.0 & !(0x1f << 8usize)) | (((val as u32) & 0x1f) << 8usize); 2855 let val = (self.0 >> 2usize) & 0x01;
2856 val != 0
1970 } 2857 }
1971 } 2858 #[doc = "Capture/compare control update selection"]
1972 impl Default for Dcr { 2859 pub fn set_ccus(&mut self, val: bool) {
1973 fn default() -> Dcr { 2860 self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
1974 Dcr(0)
1975 } 2861 }
1976 }
1977 #[doc = "control register 2"]
1978 #[repr(transparent)]
1979 #[derive(Copy, Clone, Eq, PartialEq)]
1980 pub struct Cr2Gp(pub u32);
1981 impl Cr2Gp {
1982 #[doc = "Capture/compare DMA selection"] 2862 #[doc = "Capture/compare DMA selection"]
1983 pub const fn ccds(&self) -> super::vals::Ccds { 2863 pub const fn ccds(&self) -> super::vals::Ccds {
1984 let val = (self.0 >> 3usize) & 0x01; 2864 let val = (self.0 >> 3usize) & 0x01;
@@ -2006,112 +2886,150 @@ pub mod timer_v1 {
2006 pub fn set_ti1s(&mut self, val: super::vals::Tis) { 2886 pub fn set_ti1s(&mut self, val: super::vals::Tis) {
2007 self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize); 2887 self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize);
2008 } 2888 }
2009 } 2889 #[doc = "Output Idle state 1"]
2010 impl Default for Cr2Gp { 2890 pub fn ois(&self, n: usize) -> bool {
2011 fn default() -> Cr2Gp {
2012 Cr2Gp(0)
2013 }
2014 }
2015 #[doc = "DMA/Interrupt enable register"]
2016 #[repr(transparent)]
2017 #[derive(Copy, Clone, Eq, PartialEq)]
2018 pub struct DierGp(pub u32);
2019 impl DierGp {
2020 #[doc = "Update interrupt enable"]
2021 pub const fn uie(&self) -> bool {
2022 let val = (self.0 >> 0usize) & 0x01;
2023 val != 0
2024 }
2025 #[doc = "Update interrupt enable"]
2026 pub fn set_uie(&mut self, val: bool) {
2027 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
2028 }
2029 #[doc = "Capture/Compare 1 interrupt enable"]
2030 pub fn ccie(&self, n: usize) -> bool {
2031 assert!(n < 4usize); 2891 assert!(n < 4usize);
2032 let offs = 1usize + n * 1usize; 2892 let offs = 8usize + n * 2usize;
2033 let val = (self.0 >> offs) & 0x01; 2893 let val = (self.0 >> offs) & 0x01;
2034 val != 0 2894 val != 0
2035 } 2895 }
2036 #[doc = "Capture/Compare 1 interrupt enable"] 2896 #[doc = "Output Idle state 1"]
2037 pub fn set_ccie(&mut self, n: usize, val: bool) { 2897 pub fn set_ois(&mut self, n: usize, val: bool) {
2038 assert!(n < 4usize); 2898 assert!(n < 4usize);
2039 let offs = 1usize + n * 1usize; 2899 let offs = 8usize + n * 2usize;
2040 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); 2900 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2041 } 2901 }
2042 #[doc = "Trigger interrupt enable"] 2902 #[doc = "Output Idle state 1"]
2043 pub const fn tie(&self) -> bool { 2903 pub const fn ois1n(&self) -> bool {
2044 let val = (self.0 >> 6usize) & 0x01; 2904 let val = (self.0 >> 9usize) & 0x01;
2045 val != 0 2905 val != 0
2046 } 2906 }
2047 #[doc = "Trigger interrupt enable"] 2907 #[doc = "Output Idle state 1"]
2048 pub fn set_tie(&mut self, val: bool) { 2908 pub fn set_ois1n(&mut self, val: bool) {
2049 self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); 2909 self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
2050 } 2910 }
2051 #[doc = "Update DMA request enable"] 2911 #[doc = "Output Idle state 2"]
2052 pub const fn ude(&self) -> bool { 2912 pub const fn ois2n(&self) -> bool {
2053 let val = (self.0 >> 8usize) & 0x01; 2913 let val = (self.0 >> 11usize) & 0x01;
2054 val != 0 2914 val != 0
2055 } 2915 }
2056 #[doc = "Update DMA request enable"] 2916 #[doc = "Output Idle state 2"]
2057 pub fn set_ude(&mut self, val: bool) { 2917 pub fn set_ois2n(&mut self, val: bool) {
2058 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); 2918 self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
2059 } 2919 }
2060 #[doc = "Capture/Compare 1 DMA request enable"] 2920 #[doc = "Output Idle state 3"]
2061 pub fn ccde(&self, n: usize) -> bool { 2921 pub const fn ois3n(&self) -> bool {
2062 assert!(n < 4usize); 2922 let val = (self.0 >> 13usize) & 0x01;
2063 let offs = 9usize + n * 1usize;
2064 let val = (self.0 >> offs) & 0x01;
2065 val != 0 2923 val != 0
2066 } 2924 }
2067 #[doc = "Capture/Compare 1 DMA request enable"] 2925 #[doc = "Output Idle state 3"]
2068 pub fn set_ccde(&mut self, n: usize, val: bool) { 2926 pub fn set_ois3n(&mut self, val: bool) {
2069 assert!(n < 4usize); 2927 self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
2070 let offs = 9usize + n * 1usize;
2071 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2072 } 2928 }
2073 #[doc = "Trigger DMA request enable"] 2929 }
2074 pub const fn tde(&self) -> bool { 2930 impl Default for Cr2Adv {
2075 let val = (self.0 >> 14usize) & 0x01; 2931 fn default() -> Cr2Adv {
2076 val != 0 2932 Cr2Adv(0)
2077 } 2933 }
2078 #[doc = "Trigger DMA request enable"] 2934 }
2079 pub fn set_tde(&mut self, val: bool) { 2935 #[doc = "control register 2"]
2080 self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize); 2936 #[repr(transparent)]
2937 #[derive(Copy, Clone, Eq, PartialEq)]
2938 pub struct Cr2Basic(pub u32);
2939 impl Cr2Basic {
2940 #[doc = "Master mode selection"]
2941 pub const fn mms(&self) -> super::vals::Mms {
2942 let val = (self.0 >> 4usize) & 0x07;
2943 super::vals::Mms(val as u8)
2944 }
2945 #[doc = "Master mode selection"]
2946 pub fn set_mms(&mut self, val: super::vals::Mms) {
2947 self.0 = (self.0 & !(0x07 << 4usize)) | (((val.0 as u32) & 0x07) << 4usize);
2081 } 2948 }
2082 } 2949 }
2083 impl Default for DierGp { 2950 impl Default for Cr2Basic {
2084 fn default() -> DierGp { 2951 fn default() -> Cr2Basic {
2085 DierGp(0) 2952 Cr2Basic(0)
2086 } 2953 }
2087 } 2954 }
2088 #[doc = "DMA/Interrupt enable register"] 2955 #[doc = "repetition counter register"]
2089 #[repr(transparent)] 2956 #[repr(transparent)]
2090 #[derive(Copy, Clone, Eq, PartialEq)] 2957 #[derive(Copy, Clone, Eq, PartialEq)]
2091 pub struct DierBasic(pub u32); 2958 pub struct Rcr(pub u32);
2092 impl DierBasic { 2959 impl Rcr {
2093 #[doc = "Update interrupt enable"] 2960 #[doc = "Repetition counter value"]
2094 pub const fn uie(&self) -> bool { 2961 pub const fn rep(&self) -> u8 {
2962 let val = (self.0 >> 0usize) & 0xff;
2963 val as u8
2964 }
2965 #[doc = "Repetition counter value"]
2966 pub fn set_rep(&mut self, val: u8) {
2967 self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
2968 }
2969 }
2970 impl Default for Rcr {
2971 fn default() -> Rcr {
2972 Rcr(0)
2973 }
2974 }
2975 #[doc = "event generation register"]
2976 #[repr(transparent)]
2977 #[derive(Copy, Clone, Eq, PartialEq)]
2978 pub struct EgrGp(pub u32);
2979 impl EgrGp {
2980 #[doc = "Update generation"]
2981 pub const fn ug(&self) -> bool {
2095 let val = (self.0 >> 0usize) & 0x01; 2982 let val = (self.0 >> 0usize) & 0x01;
2096 val != 0 2983 val != 0
2097 } 2984 }
2098 #[doc = "Update interrupt enable"] 2985 #[doc = "Update generation"]
2099 pub fn set_uie(&mut self, val: bool) { 2986 pub fn set_ug(&mut self, val: bool) {
2100 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); 2987 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
2101 } 2988 }
2102 #[doc = "Update DMA request enable"] 2989 #[doc = "Capture/compare 1 generation"]
2103 pub const fn ude(&self) -> bool { 2990 pub fn ccg(&self, n: usize) -> bool {
2104 let val = (self.0 >> 8usize) & 0x01; 2991 assert!(n < 4usize);
2992 let offs = 1usize + n * 1usize;
2993 let val = (self.0 >> offs) & 0x01;
2105 val != 0 2994 val != 0
2106 } 2995 }
2107 #[doc = "Update DMA request enable"] 2996 #[doc = "Capture/compare 1 generation"]
2108 pub fn set_ude(&mut self, val: bool) { 2997 pub fn set_ccg(&mut self, n: usize, val: bool) {
2109 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); 2998 assert!(n < 4usize);
2999 let offs = 1usize + n * 1usize;
3000 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
3001 }
3002 #[doc = "Capture/Compare control update generation"]
3003 pub const fn comg(&self) -> bool {
3004 let val = (self.0 >> 5usize) & 0x01;
3005 val != 0
3006 }
3007 #[doc = "Capture/Compare control update generation"]
3008 pub fn set_comg(&mut self, val: bool) {
3009 self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
3010 }
3011 #[doc = "Trigger generation"]
3012 pub const fn tg(&self) -> bool {
3013 let val = (self.0 >> 6usize) & 0x01;
3014 val != 0
3015 }
3016 #[doc = "Trigger generation"]
3017 pub fn set_tg(&mut self, val: bool) {
3018 self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
3019 }
3020 #[doc = "Break generation"]
3021 pub const fn bg(&self) -> bool {
3022 let val = (self.0 >> 7usize) & 0x01;
3023 val != 0
3024 }
3025 #[doc = "Break generation"]
3026 pub fn set_bg(&mut self, val: bool) {
3027 self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
2110 } 3028 }
2111 } 3029 }
2112 impl Default for DierBasic { 3030 impl Default for EgrGp {
2113 fn default() -> DierBasic { 3031 fn default() -> EgrGp {
2114 DierBasic(0) 3032 EgrGp(0)
2115 } 3033 }
2116 } 3034 }
2117 #[doc = "control register 1"] 3035 #[doc = "control register 1"]
@@ -2197,137 +3115,95 @@ pub mod timer_v1 {
2197 Cr1Gp(0) 3115 Cr1Gp(0)
2198 } 3116 }
2199 } 3117 }
2200 #[doc = "break and dead-time register"] 3118 #[doc = "capture/compare register 1"]
2201 #[repr(transparent)] 3119 #[repr(transparent)]
2202 #[derive(Copy, Clone, Eq, PartialEq)] 3120 #[derive(Copy, Clone, Eq, PartialEq)]
2203 pub struct Bdtr(pub u32); 3121 pub struct Ccr32(pub u32);
2204 impl Bdtr { 3122 impl Ccr32 {
2205 #[doc = "Dead-time generator setup"] 3123 #[doc = "Capture/Compare 1 value"]
2206 pub const fn dtg(&self) -> u8 { 3124 pub const fn ccr(&self) -> u32 {
2207 let val = (self.0 >> 0usize) & 0xff; 3125 let val = (self.0 >> 0usize) & 0xffff_ffff;
2208 val as u8 3126 val as u32
2209 }
2210 #[doc = "Dead-time generator setup"]
2211 pub fn set_dtg(&mut self, val: u8) {
2212 self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
2213 }
2214 #[doc = "Lock configuration"]
2215 pub const fn lock(&self) -> u8 {
2216 let val = (self.0 >> 8usize) & 0x03;
2217 val as u8
2218 }
2219 #[doc = "Lock configuration"]
2220 pub fn set_lock(&mut self, val: u8) {
2221 self.0 = (self.0 & !(0x03 << 8usize)) | (((val as u32) & 0x03) << 8usize);
2222 }
2223 #[doc = "Off-state selection for Idle mode"]
2224 pub const fn ossi(&self) -> super::vals::Ossi {
2225 let val = (self.0 >> 10usize) & 0x01;
2226 super::vals::Ossi(val as u8)
2227 }
2228 #[doc = "Off-state selection for Idle mode"]
2229 pub fn set_ossi(&mut self, val: super::vals::Ossi) {
2230 self.0 = (self.0 & !(0x01 << 10usize)) | (((val.0 as u32) & 0x01) << 10usize);
2231 }
2232 #[doc = "Off-state selection for Run mode"]
2233 pub const fn ossr(&self) -> super::vals::Ossr {
2234 let val = (self.0 >> 11usize) & 0x01;
2235 super::vals::Ossr(val as u8)
2236 }
2237 #[doc = "Off-state selection for Run mode"]
2238 pub fn set_ossr(&mut self, val: super::vals::Ossr) {
2239 self.0 = (self.0 & !(0x01 << 11usize)) | (((val.0 as u32) & 0x01) << 11usize);
2240 }
2241 #[doc = "Break enable"]
2242 pub const fn bke(&self) -> bool {
2243 let val = (self.0 >> 12usize) & 0x01;
2244 val != 0
2245 }
2246 #[doc = "Break enable"]
2247 pub fn set_bke(&mut self, val: bool) {
2248 self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
2249 }
2250 #[doc = "Break polarity"]
2251 pub const fn bkp(&self) -> bool {
2252 let val = (self.0 >> 13usize) & 0x01;
2253 val != 0
2254 }
2255 #[doc = "Break polarity"]
2256 pub fn set_bkp(&mut self, val: bool) {
2257 self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
2258 } 3127 }
2259 #[doc = "Automatic output enable"] 3128 #[doc = "Capture/Compare 1 value"]
2260 pub const fn aoe(&self) -> bool { 3129 pub fn set_ccr(&mut self, val: u32) {
2261 let val = (self.0 >> 14usize) & 0x01; 3130 self.0 =
2262 val != 0 3131 (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize);
2263 } 3132 }
2264 #[doc = "Automatic output enable"] 3133 }
2265 pub fn set_aoe(&mut self, val: bool) { 3134 impl Default for Ccr32 {
2266 self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize); 3135 fn default() -> Ccr32 {
3136 Ccr32(0)
2267 } 3137 }
2268 #[doc = "Main output enable"] 3138 }
2269 pub const fn moe(&self) -> bool { 3139 #[doc = "capture/compare register 1"]
2270 let val = (self.0 >> 15usize) & 0x01; 3140 #[repr(transparent)]
2271 val != 0 3141 #[derive(Copy, Clone, Eq, PartialEq)]
3142 pub struct Ccr16(pub u32);
3143 impl Ccr16 {
3144 #[doc = "Capture/Compare 1 value"]
3145 pub const fn ccr(&self) -> u16 {
3146 let val = (self.0 >> 0usize) & 0xffff;
3147 val as u16
2272 } 3148 }
2273 #[doc = "Main output enable"] 3149 #[doc = "Capture/Compare 1 value"]
2274 pub fn set_moe(&mut self, val: bool) { 3150 pub fn set_ccr(&mut self, val: u16) {
2275 self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize); 3151 self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
2276 } 3152 }
2277 } 3153 }
2278 impl Default for Bdtr { 3154 impl Default for Ccr16 {
2279 fn default() -> Bdtr { 3155 fn default() -> Ccr16 {
2280 Bdtr(0) 3156 Ccr16(0)
2281 } 3157 }
2282 } 3158 }
2283 #[doc = "capture/compare mode register 1 (input mode)"] 3159 #[doc = "capture/compare enable register"]
2284 #[repr(transparent)] 3160 #[repr(transparent)]
2285 #[derive(Copy, Clone, Eq, PartialEq)] 3161 #[derive(Copy, Clone, Eq, PartialEq)]
2286 pub struct CcmrInput(pub u32); 3162 pub struct CcerGp(pub u32);
2287 impl CcmrInput { 3163 impl CcerGp {
2288 #[doc = "Capture/Compare 1 selection"] 3164 #[doc = "Capture/Compare 1 output enable"]
2289 pub fn ccs(&self, n: usize) -> super::vals::CcmrInputCcs { 3165 pub fn cce(&self, n: usize) -> bool {
2290 assert!(n < 2usize); 3166 assert!(n < 4usize);
2291 let offs = 0usize + n * 8usize; 3167 let offs = 0usize + n * 4usize;
2292 let val = (self.0 >> offs) & 0x03; 3168 let val = (self.0 >> offs) & 0x01;
2293 super::vals::CcmrInputCcs(val as u8) 3169 val != 0
2294 } 3170 }
2295 #[doc = "Capture/Compare 1 selection"] 3171 #[doc = "Capture/Compare 1 output enable"]
2296 pub fn set_ccs(&mut self, n: usize, val: super::vals::CcmrInputCcs) { 3172 pub fn set_cce(&mut self, n: usize, val: bool) {
2297 assert!(n < 2usize); 3173 assert!(n < 4usize);
2298 let offs = 0usize + n * 8usize; 3174 let offs = 0usize + n * 4usize;
2299 self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); 3175 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2300 } 3176 }
2301 #[doc = "Input capture 1 prescaler"] 3177 #[doc = "Capture/Compare 1 output Polarity"]
2302 pub fn icpsc(&self, n: usize) -> u8 { 3178 pub fn ccp(&self, n: usize) -> bool {
2303 assert!(n < 2usize); 3179 assert!(n < 4usize);
2304 let offs = 2usize + n * 8usize; 3180 let offs = 1usize + n * 4usize;
2305 let val = (self.0 >> offs) & 0x03; 3181 let val = (self.0 >> offs) & 0x01;
2306 val as u8 3182 val != 0
2307 } 3183 }
2308 #[doc = "Input capture 1 prescaler"] 3184 #[doc = "Capture/Compare 1 output Polarity"]
2309 pub fn set_icpsc(&mut self, n: usize, val: u8) { 3185 pub fn set_ccp(&mut self, n: usize, val: bool) {
2310 assert!(n < 2usize); 3186 assert!(n < 4usize);
2311 let offs = 2usize + n * 8usize; 3187 let offs = 1usize + n * 4usize;
2312 self.0 = (self.0 & !(0x03 << offs)) | (((val as u32) & 0x03) << offs); 3188 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2313 } 3189 }
2314 #[doc = "Input capture 1 filter"] 3190 #[doc = "Capture/Compare 1 output Polarity"]
2315 pub fn icf(&self, n: usize) -> super::vals::Icf { 3191 pub fn ccnp(&self, n: usize) -> bool {
2316 assert!(n < 2usize); 3192 assert!(n < 4usize);
2317 let offs = 4usize + n * 8usize; 3193 let offs = 3usize + n * 4usize;
2318 let val = (self.0 >> offs) & 0x0f; 3194 let val = (self.0 >> offs) & 0x01;
2319 super::vals::Icf(val as u8) 3195 val != 0
2320 } 3196 }
2321 #[doc = "Input capture 1 filter"] 3197 #[doc = "Capture/Compare 1 output Polarity"]
2322 pub fn set_icf(&mut self, n: usize, val: super::vals::Icf) { 3198 pub fn set_ccnp(&mut self, n: usize, val: bool) {
2323 assert!(n < 2usize); 3199 assert!(n < 4usize);
2324 let offs = 4usize + n * 8usize; 3200 let offs = 3usize + n * 4usize;
2325 self.0 = (self.0 & !(0x0f << offs)) | (((val.0 as u32) & 0x0f) << offs); 3201 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2326 } 3202 }
2327 } 3203 }
2328 impl Default for CcmrInput { 3204 impl Default for CcerGp {
2329 fn default() -> CcmrInput { 3205 fn default() -> CcerGp {
2330 CcmrInput(0) 3206 CcerGp(0)
2331 } 3207 }
2332 } 3208 }
2333 #[doc = "DMA address for full transfer"] 3209 #[doc = "DMA address for full transfer"]
@@ -2350,27 +3226,6 @@ pub mod timer_v1 {
2350 Dmar(0) 3226 Dmar(0)
2351 } 3227 }
2352 } 3228 }
2353 #[doc = "counter"]
2354 #[repr(transparent)]
2355 #[derive(Copy, Clone, Eq, PartialEq)]
2356 pub struct Cnt32(pub u32);
2357 impl Cnt32 {
2358 #[doc = "counter value"]
2359 pub const fn cnt(&self) -> u32 {
2360 let val = (self.0 >> 0usize) & 0xffff_ffff;
2361 val as u32
2362 }
2363 #[doc = "counter value"]
2364 pub fn set_cnt(&mut self, val: u32) {
2365 self.0 =
2366 (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize);
2367 }
2368 }
2369 impl Default for Cnt32 {
2370 fn default() -> Cnt32 {
2371 Cnt32(0)
2372 }
2373 }
2374 #[doc = "DMA/Interrupt enable register"] 3229 #[doc = "DMA/Interrupt enable register"]
2375 #[repr(transparent)] 3230 #[repr(transparent)]
2376 #[derive(Copy, Clone, Eq, PartialEq)] 3231 #[derive(Copy, Clone, Eq, PartialEq)]
@@ -2471,26 +3326,6 @@ pub mod timer_v1 {
2471 DierAdv(0) 3326 DierAdv(0)
2472 } 3327 }
2473 } 3328 }
2474 #[doc = "status register"]
2475 #[repr(transparent)]
2476 #[derive(Copy, Clone, Eq, PartialEq)]
2477 pub struct SrBasic(pub u32);
2478 impl SrBasic {
2479 #[doc = "Update interrupt flag"]
2480 pub const fn uif(&self) -> bool {
2481 let val = (self.0 >> 0usize) & 0x01;
2482 val != 0
2483 }
2484 #[doc = "Update interrupt flag"]
2485 pub fn set_uif(&mut self, val: bool) {
2486 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
2487 }
2488 }
2489 impl Default for SrBasic {
2490 fn default() -> SrBasic {
2491 SrBasic(0)
2492 }
2493 }
2494 #[doc = "event generation register"] 3329 #[doc = "event generation register"]
2495 #[repr(transparent)] 3330 #[repr(transparent)]
2496 #[derive(Copy, Clone, Eq, PartialEq)] 3331 #[derive(Copy, Clone, Eq, PartialEq)]
@@ -2551,47 +3386,6 @@ pub mod timer_v1 {
2551 EgrAdv(0) 3386 EgrAdv(0)
2552 } 3387 }
2553 } 3388 }
2554 #[doc = "repetition counter register"]
2555 #[repr(transparent)]
2556 #[derive(Copy, Clone, Eq, PartialEq)]
2557 pub struct Rcr(pub u32);
2558 impl Rcr {
2559 #[doc = "Repetition counter value"]
2560 pub const fn rep(&self) -> u8 {
2561 let val = (self.0 >> 0usize) & 0xff;
2562 val as u8
2563 }
2564 #[doc = "Repetition counter value"]
2565 pub fn set_rep(&mut self, val: u8) {
2566 self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
2567 }
2568 }
2569 impl Default for Rcr {
2570 fn default() -> Rcr {
2571 Rcr(0)
2572 }
2573 }
2574 #[doc = "auto-reload register"]
2575 #[repr(transparent)]
2576 #[derive(Copy, Clone, Eq, PartialEq)]
2577 pub struct Arr32(pub u32);
2578 impl Arr32 {
2579 #[doc = "Auto-reload value"]
2580 pub const fn arr(&self) -> u32 {
2581 let val = (self.0 >> 0usize) & 0xffff_ffff;
2582 val as u32
2583 }
2584 #[doc = "Auto-reload value"]
2585 pub fn set_arr(&mut self, val: u32) {
2586 self.0 =
2587 (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize);
2588 }
2589 }
2590 impl Default for Arr32 {
2591 fn default() -> Arr32 {
2592 Arr32(0)
2593 }
2594 }
2595 #[doc = "event generation register"] 3389 #[doc = "event generation register"]
2596 #[repr(transparent)] 3390 #[repr(transparent)]
2597 #[derive(Copy, Clone, Eq, PartialEq)] 3391 #[derive(Copy, Clone, Eq, PartialEq)]
@@ -2612,605 +3406,298 @@ pub mod timer_v1 {
2612 EgrBasic(0) 3406 EgrBasic(0)
2613 } 3407 }
2614 } 3408 }
2615 #[doc = "counter"] 3409 #[doc = "DMA/Interrupt enable register"]
2616 #[repr(transparent)]
2617 #[derive(Copy, Clone, Eq, PartialEq)]
2618 pub struct Cnt16(pub u32);
2619 impl Cnt16 {
2620 #[doc = "counter value"]
2621 pub const fn cnt(&self) -> u16 {
2622 let val = (self.0 >> 0usize) & 0xffff;
2623 val as u16
2624 }
2625 #[doc = "counter value"]
2626 pub fn set_cnt(&mut self, val: u16) {
2627 self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
2628 }
2629 }
2630 impl Default for Cnt16 {
2631 fn default() -> Cnt16 {
2632 Cnt16(0)
2633 }
2634 }
2635 #[doc = "auto-reload register"]
2636 #[repr(transparent)]
2637 #[derive(Copy, Clone, Eq, PartialEq)]
2638 pub struct Arr16(pub u32);
2639 impl Arr16 {
2640 #[doc = "Auto-reload value"]
2641 pub const fn arr(&self) -> u16 {
2642 let val = (self.0 >> 0usize) & 0xffff;
2643 val as u16
2644 }
2645 #[doc = "Auto-reload value"]
2646 pub fn set_arr(&mut self, val: u16) {
2647 self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
2648 }
2649 }
2650 impl Default for Arr16 {
2651 fn default() -> Arr16 {
2652 Arr16(0)
2653 }
2654 }
2655 #[doc = "capture/compare enable register"]
2656 #[repr(transparent)]
2657 #[derive(Copy, Clone, Eq, PartialEq)]
2658 pub struct CcerAdv(pub u32);
2659 impl CcerAdv {
2660 #[doc = "Capture/Compare 1 output enable"]
2661 pub fn cce(&self, n: usize) -> bool {
2662 assert!(n < 4usize);
2663 let offs = 0usize + n * 4usize;
2664 let val = (self.0 >> offs) & 0x01;
2665 val != 0
2666 }
2667 #[doc = "Capture/Compare 1 output enable"]
2668 pub fn set_cce(&mut self, n: usize, val: bool) {
2669 assert!(n < 4usize);
2670 let offs = 0usize + n * 4usize;
2671 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2672 }
2673 #[doc = "Capture/Compare 1 output Polarity"]
2674 pub fn ccp(&self, n: usize) -> bool {
2675 assert!(n < 4usize);
2676 let offs = 1usize + n * 4usize;
2677 let val = (self.0 >> offs) & 0x01;
2678 val != 0
2679 }
2680 #[doc = "Capture/Compare 1 output Polarity"]
2681 pub fn set_ccp(&mut self, n: usize, val: bool) {
2682 assert!(n < 4usize);
2683 let offs = 1usize + n * 4usize;
2684 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2685 }
2686 #[doc = "Capture/Compare 1 complementary output enable"]
2687 pub fn ccne(&self, n: usize) -> bool {
2688 assert!(n < 4usize);
2689 let offs = 2usize + n * 4usize;
2690 let val = (self.0 >> offs) & 0x01;
2691 val != 0
2692 }
2693 #[doc = "Capture/Compare 1 complementary output enable"]
2694 pub fn set_ccne(&mut self, n: usize, val: bool) {
2695 assert!(n < 4usize);
2696 let offs = 2usize + n * 4usize;
2697 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2698 }
2699 #[doc = "Capture/Compare 1 output Polarity"]
2700 pub fn ccnp(&self, n: usize) -> bool {
2701 assert!(n < 4usize);
2702 let offs = 3usize + n * 4usize;
2703 let val = (self.0 >> offs) & 0x01;
2704 val != 0
2705 }
2706 #[doc = "Capture/Compare 1 output Polarity"]
2707 pub fn set_ccnp(&mut self, n: usize, val: bool) {
2708 assert!(n < 4usize);
2709 let offs = 3usize + n * 4usize;
2710 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2711 }
2712 }
2713 impl Default for CcerAdv {
2714 fn default() -> CcerAdv {
2715 CcerAdv(0)
2716 }
2717 }
2718 #[doc = "capture/compare register 1"]
2719 #[repr(transparent)]
2720 #[derive(Copy, Clone, Eq, PartialEq)]
2721 pub struct Ccr16(pub u32);
2722 impl Ccr16 {
2723 #[doc = "Capture/Compare 1 value"]
2724 pub const fn ccr(&self) -> u16 {
2725 let val = (self.0 >> 0usize) & 0xffff;
2726 val as u16
2727 }
2728 #[doc = "Capture/Compare 1 value"]
2729 pub fn set_ccr(&mut self, val: u16) {
2730 self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
2731 }
2732 }
2733 impl Default for Ccr16 {
2734 fn default() -> Ccr16 {
2735 Ccr16(0)
2736 }
2737 }
2738 #[doc = "capture/compare register 1"]
2739 #[repr(transparent)]
2740 #[derive(Copy, Clone, Eq, PartialEq)]
2741 pub struct Ccr32(pub u32);
2742 impl Ccr32 {
2743 #[doc = "Capture/Compare 1 value"]
2744 pub const fn ccr(&self) -> u32 {
2745 let val = (self.0 >> 0usize) & 0xffff_ffff;
2746 val as u32
2747 }
2748 #[doc = "Capture/Compare 1 value"]
2749 pub fn set_ccr(&mut self, val: u32) {
2750 self.0 =
2751 (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize);
2752 }
2753 }
2754 impl Default for Ccr32 {
2755 fn default() -> Ccr32 {
2756 Ccr32(0)
2757 }
2758 }
2759 #[doc = "capture/compare enable register"]
2760 #[repr(transparent)] 3410 #[repr(transparent)]
2761 #[derive(Copy, Clone, Eq, PartialEq)] 3411 #[derive(Copy, Clone, Eq, PartialEq)]
2762 pub struct CcerGp(pub u32); 3412 pub struct DierBasic(pub u32);
2763 impl CcerGp { 3413 impl DierBasic {
2764 #[doc = "Capture/Compare 1 output enable"] 3414 #[doc = "Update interrupt enable"]
2765 pub fn cce(&self, n: usize) -> bool { 3415 pub const fn uie(&self) -> bool {
2766 assert!(n < 4usize); 3416 let val = (self.0 >> 0usize) & 0x01;
2767 let offs = 0usize + n * 4usize;
2768 let val = (self.0 >> offs) & 0x01;
2769 val != 0
2770 }
2771 #[doc = "Capture/Compare 1 output enable"]
2772 pub fn set_cce(&mut self, n: usize, val: bool) {
2773 assert!(n < 4usize);
2774 let offs = 0usize + n * 4usize;
2775 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2776 }
2777 #[doc = "Capture/Compare 1 output Polarity"]
2778 pub fn ccp(&self, n: usize) -> bool {
2779 assert!(n < 4usize);
2780 let offs = 1usize + n * 4usize;
2781 let val = (self.0 >> offs) & 0x01;
2782 val != 0 3417 val != 0
2783 } 3418 }
2784 #[doc = "Capture/Compare 1 output Polarity"] 3419 #[doc = "Update interrupt enable"]
2785 pub fn set_ccp(&mut self, n: usize, val: bool) { 3420 pub fn set_uie(&mut self, val: bool) {
2786 assert!(n < 4usize); 3421 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
2787 let offs = 1usize + n * 4usize;
2788 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2789 } 3422 }
2790 #[doc = "Capture/Compare 1 output Polarity"] 3423 #[doc = "Update DMA request enable"]
2791 pub fn ccnp(&self, n: usize) -> bool { 3424 pub const fn ude(&self) -> bool {
2792 assert!(n < 4usize); 3425 let val = (self.0 >> 8usize) & 0x01;
2793 let offs = 3usize + n * 4usize;
2794 let val = (self.0 >> offs) & 0x01;
2795 val != 0 3426 val != 0
2796 } 3427 }
2797 #[doc = "Capture/Compare 1 output Polarity"] 3428 #[doc = "Update DMA request enable"]
2798 pub fn set_ccnp(&mut self, n: usize, val: bool) { 3429 pub fn set_ude(&mut self, val: bool) {
2799 assert!(n < 4usize); 3430 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
2800 let offs = 3usize + n * 4usize;
2801 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2802 } 3431 }
2803 } 3432 }
2804 impl Default for CcerGp { 3433 impl Default for DierBasic {
2805 fn default() -> CcerGp { 3434 fn default() -> DierBasic {
2806 CcerGp(0) 3435 DierBasic(0)
2807 } 3436 }
2808 } 3437 }
2809 #[doc = "status register"] 3438 #[doc = "DMA/Interrupt enable register"]
2810 #[repr(transparent)] 3439 #[repr(transparent)]
2811 #[derive(Copy, Clone, Eq, PartialEq)] 3440 #[derive(Copy, Clone, Eq, PartialEq)]
2812 pub struct SrAdv(pub u32); 3441 pub struct DierGp(pub u32);
2813 impl SrAdv { 3442 impl DierGp {
2814 #[doc = "Update interrupt flag"] 3443 #[doc = "Update interrupt enable"]
2815 pub const fn uif(&self) -> bool { 3444 pub const fn uie(&self) -> bool {
2816 let val = (self.0 >> 0usize) & 0x01; 3445 let val = (self.0 >> 0usize) & 0x01;
2817 val != 0 3446 val != 0
2818 } 3447 }
2819 #[doc = "Update interrupt flag"] 3448 #[doc = "Update interrupt enable"]
2820 pub fn set_uif(&mut self, val: bool) { 3449 pub fn set_uie(&mut self, val: bool) {
2821 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); 3450 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
2822 } 3451 }
2823 #[doc = "Capture/compare 1 interrupt flag"] 3452 #[doc = "Capture/Compare 1 interrupt enable"]
2824 pub fn ccif(&self, n: usize) -> bool { 3453 pub fn ccie(&self, n: usize) -> bool {
2825 assert!(n < 4usize); 3454 assert!(n < 4usize);
2826 let offs = 1usize + n * 1usize; 3455 let offs = 1usize + n * 1usize;
2827 let val = (self.0 >> offs) & 0x01; 3456 let val = (self.0 >> offs) & 0x01;
2828 val != 0 3457 val != 0
2829 } 3458 }
2830 #[doc = "Capture/compare 1 interrupt flag"] 3459 #[doc = "Capture/Compare 1 interrupt enable"]
2831 pub fn set_ccif(&mut self, n: usize, val: bool) { 3460 pub fn set_ccie(&mut self, n: usize, val: bool) {
2832 assert!(n < 4usize); 3461 assert!(n < 4usize);
2833 let offs = 1usize + n * 1usize; 3462 let offs = 1usize + n * 1usize;
2834 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); 3463 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2835 } 3464 }
2836 #[doc = "COM interrupt flag"] 3465 #[doc = "Trigger interrupt enable"]
2837 pub const fn comif(&self) -> bool { 3466 pub const fn tie(&self) -> bool {
2838 let val = (self.0 >> 5usize) & 0x01;
2839 val != 0
2840 }
2841 #[doc = "COM interrupt flag"]
2842 pub fn set_comif(&mut self, val: bool) {
2843 self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
2844 }
2845 #[doc = "Trigger interrupt flag"]
2846 pub const fn tif(&self) -> bool {
2847 let val = (self.0 >> 6usize) & 0x01; 3467 let val = (self.0 >> 6usize) & 0x01;
2848 val != 0 3468 val != 0
2849 } 3469 }
2850 #[doc = "Trigger interrupt flag"] 3470 #[doc = "Trigger interrupt enable"]
2851 pub fn set_tif(&mut self, val: bool) { 3471 pub fn set_tie(&mut self, val: bool) {
2852 self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); 3472 self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
2853 } 3473 }
2854 #[doc = "Break interrupt flag"] 3474 #[doc = "Update DMA request enable"]
2855 pub const fn bif(&self) -> bool { 3475 pub const fn ude(&self) -> bool {
2856 let val = (self.0 >> 7usize) & 0x01; 3476 let val = (self.0 >> 8usize) & 0x01;
2857 val != 0 3477 val != 0
2858 } 3478 }
2859 #[doc = "Break interrupt flag"] 3479 #[doc = "Update DMA request enable"]
2860 pub fn set_bif(&mut self, val: bool) { 3480 pub fn set_ude(&mut self, val: bool) {
2861 self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); 3481 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
2862 } 3482 }
2863 #[doc = "Capture/Compare 1 overcapture flag"] 3483 #[doc = "Capture/Compare 1 DMA request enable"]
2864 pub fn ccof(&self, n: usize) -> bool { 3484 pub fn ccde(&self, n: usize) -> bool {
2865 assert!(n < 4usize); 3485 assert!(n < 4usize);
2866 let offs = 9usize + n * 1usize; 3486 let offs = 9usize + n * 1usize;
2867 let val = (self.0 >> offs) & 0x01; 3487 let val = (self.0 >> offs) & 0x01;
2868 val != 0 3488 val != 0
2869 } 3489 }
2870 #[doc = "Capture/Compare 1 overcapture flag"] 3490 #[doc = "Capture/Compare 1 DMA request enable"]
2871 pub fn set_ccof(&mut self, n: usize, val: bool) { 3491 pub fn set_ccde(&mut self, n: usize, val: bool) {
2872 assert!(n < 4usize); 3492 assert!(n < 4usize);
2873 let offs = 9usize + n * 1usize; 3493 let offs = 9usize + n * 1usize;
2874 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); 3494 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2875 } 3495 }
2876 } 3496 #[doc = "Trigger DMA request enable"]
2877 impl Default for SrAdv { 3497 pub const fn tde(&self) -> bool {
2878 fn default() -> SrAdv { 3498 let val = (self.0 >> 14usize) & 0x01;
2879 SrAdv(0) 3499 val != 0
2880 }
2881 }
2882 }
2883}
2884pub mod syscfg_l4 {
2885 use crate::generic::*;
2886 #[doc = "System configuration controller"]
2887 #[derive(Copy, Clone)]
2888 pub struct Syscfg(pub *mut u8);
2889 unsafe impl Send for Syscfg {}
2890 unsafe impl Sync for Syscfg {}
2891 impl Syscfg {
2892 #[doc = "memory remap register"]
2893 pub fn memrmp(self) -> Reg<regs::Memrmp, RW> {
2894 unsafe { Reg::from_ptr(self.0.add(0usize)) }
2895 }
2896 #[doc = "configuration register 1"]
2897 pub fn cfgr1(self) -> Reg<regs::Cfgr1, RW> {
2898 unsafe { Reg::from_ptr(self.0.add(4usize)) }
2899 }
2900 #[doc = "external interrupt configuration register 1"]
2901 pub fn exticr(self, n: usize) -> Reg<regs::Exticr, RW> {
2902 assert!(n < 4usize);
2903 unsafe { Reg::from_ptr(self.0.add(8usize + n * 4usize)) }
2904 }
2905 #[doc = "SCSR"]
2906 pub fn scsr(self) -> Reg<regs::Scsr, RW> {
2907 unsafe { Reg::from_ptr(self.0.add(24usize)) }
2908 }
2909 #[doc = "CFGR2"]
2910 pub fn cfgr2(self) -> Reg<regs::Cfgr2, RW> {
2911 unsafe { Reg::from_ptr(self.0.add(28usize)) }
2912 }
2913 #[doc = "SWPR"]
2914 pub fn swpr(self) -> Reg<regs::Swpr, W> {
2915 unsafe { Reg::from_ptr(self.0.add(32usize)) }
2916 }
2917 #[doc = "SKR"]
2918 pub fn skr(self) -> Reg<regs::Skr, W> {
2919 unsafe { Reg::from_ptr(self.0.add(36usize)) }
2920 }
2921 }
2922 pub mod regs {
2923 use crate::generic::*;
2924 #[doc = "external interrupt configuration register 4"]
2925 #[repr(transparent)]
2926 #[derive(Copy, Clone, Eq, PartialEq)]
2927 pub struct Exticr(pub u32);
2928 impl Exticr {
2929 #[doc = "EXTI12 configuration bits"]
2930 pub fn exti(&self, n: usize) -> u8 {
2931 assert!(n < 4usize);
2932 let offs = 0usize + n * 4usize;
2933 let val = (self.0 >> offs) & 0x0f;
2934 val as u8
2935 } 3500 }
2936 #[doc = "EXTI12 configuration bits"] 3501 #[doc = "Trigger DMA request enable"]
2937 pub fn set_exti(&mut self, n: usize, val: u8) { 3502 pub fn set_tde(&mut self, val: bool) {
2938 assert!(n < 4usize); 3503 self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
2939 let offs = 0usize + n * 4usize;
2940 self.0 = (self.0 & !(0x0f << offs)) | (((val as u32) & 0x0f) << offs);
2941 } 3504 }
2942 } 3505 }
2943 impl Default for Exticr { 3506 impl Default for DierGp {
2944 fn default() -> Exticr { 3507 fn default() -> DierGp {
2945 Exticr(0) 3508 DierGp(0)
2946 } 3509 }
2947 } 3510 }
2948 #[doc = "SWPR"] 3511 #[doc = "control register 2"]
2949 #[repr(transparent)] 3512 #[repr(transparent)]
2950 #[derive(Copy, Clone, Eq, PartialEq)] 3513 #[derive(Copy, Clone, Eq, PartialEq)]
2951 pub struct Swpr(pub u32); 3514 pub struct Cr2Gp(pub u32);
2952 impl Swpr { 3515 impl Cr2Gp {
2953 #[doc = "SRAWM2 write protection."] 3516 #[doc = "Capture/compare DMA selection"]
2954 pub fn pwp(&self, n: usize) -> bool { 3517 pub const fn ccds(&self) -> super::vals::Ccds {
2955 assert!(n < 32usize); 3518 let val = (self.0 >> 3usize) & 0x01;
2956 let offs = 0usize + n * 1usize; 3519 super::vals::Ccds(val as u8)
2957 let val = (self.0 >> offs) & 0x01;
2958 val != 0
2959 }
2960 #[doc = "SRAWM2 write protection."]
2961 pub fn set_pwp(&mut self, n: usize, val: bool) {
2962 assert!(n < 32usize);
2963 let offs = 0usize + n * 1usize;
2964 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
2965 } 3520 }
2966 } 3521 #[doc = "Capture/compare DMA selection"]
2967 impl Default for Swpr { 3522 pub fn set_ccds(&mut self, val: super::vals::Ccds) {
2968 fn default() -> Swpr { 3523 self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize);
2969 Swpr(0)
2970 } 3524 }
2971 } 3525 #[doc = "Master mode selection"]
2972 #[doc = "SCSR"] 3526 pub const fn mms(&self) -> super::vals::Mms {
2973 #[repr(transparent)] 3527 let val = (self.0 >> 4usize) & 0x07;
2974 #[derive(Copy, Clone, Eq, PartialEq)] 3528 super::vals::Mms(val as u8)
2975 pub struct Scsr(pub u32);
2976 impl Scsr {
2977 #[doc = "SRAM2 Erase"]
2978 pub const fn sram2er(&self) -> bool {
2979 let val = (self.0 >> 0usize) & 0x01;
2980 val != 0
2981 } 3529 }
2982 #[doc = "SRAM2 Erase"] 3530 #[doc = "Master mode selection"]
2983 pub fn set_sram2er(&mut self, val: bool) { 3531 pub fn set_mms(&mut self, val: super::vals::Mms) {
2984 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); 3532 self.0 = (self.0 & !(0x07 << 4usize)) | (((val.0 as u32) & 0x07) << 4usize);
2985 } 3533 }
2986 #[doc = "SRAM2 busy by erase operation"] 3534 #[doc = "TI1 selection"]
2987 pub const fn sram2bsy(&self) -> bool { 3535 pub const fn ti1s(&self) -> super::vals::Tis {
2988 let val = (self.0 >> 1usize) & 0x01; 3536 let val = (self.0 >> 7usize) & 0x01;
2989 val != 0 3537 super::vals::Tis(val as u8)
2990 } 3538 }
2991 #[doc = "SRAM2 busy by erase operation"] 3539 #[doc = "TI1 selection"]
2992 pub fn set_sram2bsy(&mut self, val: bool) { 3540 pub fn set_ti1s(&mut self, val: super::vals::Tis) {
2993 self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); 3541 self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize);
2994 } 3542 }
2995 } 3543 }
2996 impl Default for Scsr { 3544 impl Default for Cr2Gp {
2997 fn default() -> Scsr { 3545 fn default() -> Cr2Gp {
2998 Scsr(0) 3546 Cr2Gp(0)
2999 } 3547 }
3000 } 3548 }
3001 #[doc = "SKR"] 3549 #[doc = "break and dead-time register"]
3002 #[repr(transparent)] 3550 #[repr(transparent)]
3003 #[derive(Copy, Clone, Eq, PartialEq)] 3551 #[derive(Copy, Clone, Eq, PartialEq)]
3004 pub struct Skr(pub u32); 3552 pub struct Bdtr(pub u32);
3005 impl Skr { 3553 impl Bdtr {
3006 #[doc = "SRAM2 write protection key for software erase"] 3554 #[doc = "Dead-time generator setup"]
3007 pub const fn key(&self) -> u8 { 3555 pub const fn dtg(&self) -> u8 {
3008 let val = (self.0 >> 0usize) & 0xff; 3556 let val = (self.0 >> 0usize) & 0xff;
3009 val as u8 3557 val as u8
3010 } 3558 }
3011 #[doc = "SRAM2 write protection key for software erase"] 3559 #[doc = "Dead-time generator setup"]
3012 pub fn set_key(&mut self, val: u8) { 3560 pub fn set_dtg(&mut self, val: u8) {
3013 self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize); 3561 self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
3014 } 3562 }
3015 } 3563 #[doc = "Lock configuration"]
3016 impl Default for Skr { 3564 pub const fn lock(&self) -> u8 {
3017 fn default() -> Skr { 3565 let val = (self.0 >> 8usize) & 0x03;
3018 Skr(0)
3019 }
3020 }
3021 #[doc = "memory remap register"]
3022 #[repr(transparent)]
3023 #[derive(Copy, Clone, Eq, PartialEq)]
3024 pub struct Memrmp(pub u32);
3025 impl Memrmp {
3026 #[doc = "Memory mapping selection"]
3027 pub const fn mem_mode(&self) -> u8 {
3028 let val = (self.0 >> 0usize) & 0x07;
3029 val as u8 3566 val as u8
3030 } 3567 }
3031 #[doc = "Memory mapping selection"] 3568 #[doc = "Lock configuration"]
3032 pub fn set_mem_mode(&mut self, val: u8) { 3569 pub fn set_lock(&mut self, val: u8) {
3033 self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize); 3570 self.0 = (self.0 & !(0x03 << 8usize)) | (((val as u32) & 0x03) << 8usize);
3034 }
3035 #[doc = "QUADSPI memory mapping swap"]
3036 pub const fn qfs(&self) -> bool {
3037 let val = (self.0 >> 3usize) & 0x01;
3038 val != 0
3039 }
3040 #[doc = "QUADSPI memory mapping swap"]
3041 pub fn set_qfs(&mut self, val: bool) {
3042 self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
3043 }
3044 #[doc = "Flash Bank mode selection"]
3045 pub const fn fb_mode(&self) -> bool {
3046 let val = (self.0 >> 8usize) & 0x01;
3047 val != 0
3048 }
3049 #[doc = "Flash Bank mode selection"]
3050 pub fn set_fb_mode(&mut self, val: bool) {
3051 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
3052 }
3053 }
3054 impl Default for Memrmp {
3055 fn default() -> Memrmp {
3056 Memrmp(0)
3057 }
3058 }
3059 #[doc = "configuration register 1"]
3060 #[repr(transparent)]
3061 #[derive(Copy, Clone, Eq, PartialEq)]
3062 pub struct Cfgr1(pub u32);
3063 impl Cfgr1 {
3064 #[doc = "Firewall disable"]
3065 pub const fn fwdis(&self) -> bool {
3066 let val = (self.0 >> 0usize) & 0x01;
3067 val != 0
3068 }
3069 #[doc = "Firewall disable"]
3070 pub fn set_fwdis(&mut self, val: bool) {
3071 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
3072 }
3073 #[doc = "I/O analog switch voltage booster enable"]
3074 pub const fn boosten(&self) -> bool {
3075 let val = (self.0 >> 8usize) & 0x01;
3076 val != 0
3077 }
3078 #[doc = "I/O analog switch voltage booster enable"]
3079 pub fn set_boosten(&mut self, val: bool) {
3080 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
3081 }
3082 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB6"]
3083 pub const fn i2c_pb6_fmp(&self) -> bool {
3084 let val = (self.0 >> 16usize) & 0x01;
3085 val != 0
3086 }
3087 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB6"]
3088 pub fn set_i2c_pb6_fmp(&mut self, val: bool) {
3089 self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
3090 } 3571 }
3091 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB7"] 3572 #[doc = "Off-state selection for Idle mode"]
3092 pub const fn i2c_pb7_fmp(&self) -> bool { 3573 pub const fn ossi(&self) -> super::vals::Ossi {
3093 let val = (self.0 >> 17usize) & 0x01; 3574 let val = (self.0 >> 10usize) & 0x01;
3094 val != 0 3575 super::vals::Ossi(val as u8)
3095 } 3576 }
3096 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB7"] 3577 #[doc = "Off-state selection for Idle mode"]
3097 pub fn set_i2c_pb7_fmp(&mut self, val: bool) { 3578 pub fn set_ossi(&mut self, val: super::vals::Ossi) {
3098 self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize); 3579 self.0 = (self.0 & !(0x01 << 10usize)) | (((val.0 as u32) & 0x01) << 10usize);
3099 } 3580 }
3100 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB8"] 3581 #[doc = "Off-state selection for Run mode"]
3101 pub const fn i2c_pb8_fmp(&self) -> bool { 3582 pub const fn ossr(&self) -> super::vals::Ossr {
3102 let val = (self.0 >> 18usize) & 0x01; 3583 let val = (self.0 >> 11usize) & 0x01;
3103 val != 0 3584 super::vals::Ossr(val as u8)
3104 } 3585 }
3105 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB8"] 3586 #[doc = "Off-state selection for Run mode"]
3106 pub fn set_i2c_pb8_fmp(&mut self, val: bool) { 3587 pub fn set_ossr(&mut self, val: super::vals::Ossr) {
3107 self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize); 3588 self.0 = (self.0 & !(0x01 << 11usize)) | (((val.0 as u32) & 0x01) << 11usize);
3108 } 3589 }
3109 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB9"] 3590 #[doc = "Break enable"]
3110 pub const fn i2c_pb9_fmp(&self) -> bool { 3591 pub const fn bke(&self) -> bool {
3111 let val = (self.0 >> 19usize) & 0x01; 3592 let val = (self.0 >> 12usize) & 0x01;
3112 val != 0 3593 val != 0
3113 } 3594 }
3114 #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB9"] 3595 #[doc = "Break enable"]
3115 pub fn set_i2c_pb9_fmp(&mut self, val: bool) { 3596 pub fn set_bke(&mut self, val: bool) {
3116 self.0 = (self.0 & !(0x01 << 19usize)) | (((val as u32) & 0x01) << 19usize); 3597 self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
3117 } 3598 }
3118 #[doc = "I2C1 Fast-mode Plus driving capability activation"] 3599 #[doc = "Break polarity"]
3119 pub const fn i2c1_fmp(&self) -> bool { 3600 pub const fn bkp(&self) -> bool {
3120 let val = (self.0 >> 20usize) & 0x01; 3601 let val = (self.0 >> 13usize) & 0x01;
3121 val != 0 3602 val != 0
3122 } 3603 }
3123 #[doc = "I2C1 Fast-mode Plus driving capability activation"] 3604 #[doc = "Break polarity"]
3124 pub fn set_i2c1_fmp(&mut self, val: bool) { 3605 pub fn set_bkp(&mut self, val: bool) {
3125 self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize); 3606 self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
3126 } 3607 }
3127 #[doc = "I2C2 Fast-mode Plus driving capability activation"] 3608 #[doc = "Automatic output enable"]
3128 pub const fn i2c2_fmp(&self) -> bool { 3609 pub const fn aoe(&self) -> bool {
3129 let val = (self.0 >> 21usize) & 0x01; 3610 let val = (self.0 >> 14usize) & 0x01;
3130 val != 0 3611 val != 0
3131 } 3612 }
3132 #[doc = "I2C2 Fast-mode Plus driving capability activation"] 3613 #[doc = "Automatic output enable"]
3133 pub fn set_i2c2_fmp(&mut self, val: bool) { 3614 pub fn set_aoe(&mut self, val: bool) {
3134 self.0 = (self.0 & !(0x01 << 21usize)) | (((val as u32) & 0x01) << 21usize); 3615 self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
3135 } 3616 }
3136 #[doc = "I2C3 Fast-mode Plus driving capability activation"] 3617 #[doc = "Main output enable"]
3137 pub const fn i2c3_fmp(&self) -> bool { 3618 pub const fn moe(&self) -> bool {
3138 let val = (self.0 >> 22usize) & 0x01; 3619 let val = (self.0 >> 15usize) & 0x01;
3139 val != 0 3620 val != 0
3140 } 3621 }
3141 #[doc = "I2C3 Fast-mode Plus driving capability activation"] 3622 #[doc = "Main output enable"]
3142 pub fn set_i2c3_fmp(&mut self, val: bool) { 3623 pub fn set_moe(&mut self, val: bool) {
3143 self.0 = (self.0 & !(0x01 << 22usize)) | (((val as u32) & 0x01) << 22usize); 3624 self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
3144 }
3145 #[doc = "Floating Point Unit interrupts enable bits"]
3146 pub const fn fpu_ie(&self) -> u8 {
3147 let val = (self.0 >> 26usize) & 0x3f;
3148 val as u8
3149 }
3150 #[doc = "Floating Point Unit interrupts enable bits"]
3151 pub fn set_fpu_ie(&mut self, val: u8) {
3152 self.0 = (self.0 & !(0x3f << 26usize)) | (((val as u32) & 0x3f) << 26usize);
3153 } 3625 }
3154 } 3626 }
3155 impl Default for Cfgr1 { 3627 impl Default for Bdtr {
3156 fn default() -> Cfgr1 { 3628 fn default() -> Bdtr {
3157 Cfgr1(0) 3629 Bdtr(0)
3158 } 3630 }
3159 } 3631 }
3160 #[doc = "CFGR2"] 3632 #[doc = "capture/compare mode register 1 (input mode)"]
3161 #[repr(transparent)] 3633 #[repr(transparent)]
3162 #[derive(Copy, Clone, Eq, PartialEq)] 3634 #[derive(Copy, Clone, Eq, PartialEq)]
3163 pub struct Cfgr2(pub u32); 3635 pub struct CcmrInput(pub u32);
3164 impl Cfgr2 { 3636 impl CcmrInput {
3165 #[doc = "Cortex LOCKUP (Hardfault) output enable bit"] 3637 #[doc = "Capture/Compare 1 selection"]
3166 pub const fn cll(&self) -> bool { 3638 pub fn ccs(&self, n: usize) -> super::vals::CcmrInputCcs {
3167 let val = (self.0 >> 0usize) & 0x01; 3639 assert!(n < 2usize);
3168 val != 0 3640 let offs = 0usize + n * 8usize;
3169 } 3641 let val = (self.0 >> offs) & 0x03;
3170 #[doc = "Cortex LOCKUP (Hardfault) output enable bit"] 3642 super::vals::CcmrInputCcs(val as u8)
3171 pub fn set_cll(&mut self, val: bool) {
3172 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
3173 } 3643 }
3174 #[doc = "SRAM2 parity lock bit"] 3644 #[doc = "Capture/Compare 1 selection"]
3175 pub const fn spl(&self) -> bool { 3645 pub fn set_ccs(&mut self, n: usize, val: super::vals::CcmrInputCcs) {
3176 let val = (self.0 >> 1usize) & 0x01; 3646 assert!(n < 2usize);
3177 val != 0 3647 let offs = 0usize + n * 8usize;
3648 self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs);
3178 } 3649 }
3179 #[doc = "SRAM2 parity lock bit"] 3650 #[doc = "Input capture 1 prescaler"]
3180 pub fn set_spl(&mut self, val: bool) { 3651 pub fn icpsc(&self, n: usize) -> u8 {
3181 self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); 3652 assert!(n < 2usize);
3653 let offs = 2usize + n * 8usize;
3654 let val = (self.0 >> offs) & 0x03;
3655 val as u8
3182 } 3656 }
3183 #[doc = "PVD lock enable bit"] 3657 #[doc = "Input capture 1 prescaler"]
3184 pub const fn pvdl(&self) -> bool { 3658 pub fn set_icpsc(&mut self, n: usize, val: u8) {
3185 let val = (self.0 >> 2usize) & 0x01; 3659 assert!(n < 2usize);
3186 val != 0 3660 let offs = 2usize + n * 8usize;
3661 self.0 = (self.0 & !(0x03 << offs)) | (((val as u32) & 0x03) << offs);
3187 } 3662 }
3188 #[doc = "PVD lock enable bit"] 3663 #[doc = "Input capture 1 filter"]
3189 pub fn set_pvdl(&mut self, val: bool) { 3664 pub fn icf(&self, n: usize) -> super::vals::Icf {
3190 self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); 3665 assert!(n < 2usize);
3666 let offs = 4usize + n * 8usize;
3667 let val = (self.0 >> offs) & 0x0f;
3668 super::vals::Icf(val as u8)
3191 } 3669 }
3192 #[doc = "ECC Lock"] 3670 #[doc = "Input capture 1 filter"]
3193 pub const fn eccl(&self) -> bool { 3671 pub fn set_icf(&mut self, n: usize, val: super::vals::Icf) {
3194 let val = (self.0 >> 3usize) & 0x01; 3672 assert!(n < 2usize);
3195 val != 0 3673 let offs = 4usize + n * 8usize;
3674 self.0 = (self.0 & !(0x0f << offs)) | (((val.0 as u32) & 0x0f) << offs);
3196 } 3675 }
3197 #[doc = "ECC Lock"] 3676 }
3198 pub fn set_eccl(&mut self, val: bool) { 3677 impl Default for CcmrInput {
3199 self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); 3678 fn default() -> CcmrInput {
3679 CcmrInput(0)
3200 } 3680 }
3201 #[doc = "SRAM2 parity error flag"] 3681 }
3202 pub const fn spf(&self) -> bool { 3682 #[doc = "auto-reload register"]
3203 let val = (self.0 >> 8usize) & 0x01; 3683 #[repr(transparent)]
3204 val != 0 3684 #[derive(Copy, Clone, Eq, PartialEq)]
3685 pub struct Arr32(pub u32);
3686 impl Arr32 {
3687 #[doc = "Auto-reload value"]
3688 pub const fn arr(&self) -> u32 {
3689 let val = (self.0 >> 0usize) & 0xffff_ffff;
3690 val as u32
3205 } 3691 }
3206 #[doc = "SRAM2 parity error flag"] 3692 #[doc = "Auto-reload value"]
3207 pub fn set_spf(&mut self, val: bool) { 3693 pub fn set_arr(&mut self, val: u32) {
3208 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); 3694 self.0 =
3695 (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize);
3209 } 3696 }
3210 } 3697 }
3211 impl Default for Cfgr2 { 3698 impl Default for Arr32 {
3212 fn default() -> Cfgr2 { 3699 fn default() -> Arr32 {
3213 Cfgr2(0) 3700 Arr32(0)
3214 } 3701 }
3215 } 3702 }
3216 } 3703 }
@@ -3249,43 +3736,150 @@ pub mod gpio_v1 {
3249 unsafe { Reg::from_ptr(self.0.add(24usize)) } 3736 unsafe { Reg::from_ptr(self.0.add(24usize)) }
3250 } 3737 }
3251 } 3738 }
3739 pub mod vals {
3740 use crate::generic::*;
3741 #[repr(transparent)]
3742 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
3743 pub struct Idr(pub u8);
3744 impl Idr {
3745 #[doc = "Input is logic low"]
3746 pub const LOW: Self = Self(0);
3747 #[doc = "Input is logic high"]
3748 pub const HIGH: Self = Self(0x01);
3749 }
3750 #[repr(transparent)]
3751 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
3752 pub struct Odr(pub u8);
3753 impl Odr {
3754 #[doc = "Set output to logic low"]
3755 pub const LOW: Self = Self(0);
3756 #[doc = "Set output to logic high"]
3757 pub const HIGH: Self = Self(0x01);
3758 }
3759 #[repr(transparent)]
3760 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
3761 pub struct Brw(pub u8);
3762 impl Brw {
3763 #[doc = "No action on the corresponding ODx bit"]
3764 pub const NOACTION: Self = Self(0);
3765 #[doc = "Reset the ODx bit"]
3766 pub const RESET: Self = Self(0x01);
3767 }
3768 #[repr(transparent)]
3769 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
3770 pub struct Lck(pub u8);
3771 impl Lck {
3772 #[doc = "Port configuration not locked"]
3773 pub const UNLOCKED: Self = Self(0);
3774 #[doc = "Port configuration locked"]
3775 pub const LOCKED: Self = Self(0x01);
3776 }
3777 #[repr(transparent)]
3778 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
3779 pub struct Cnf(pub u8);
3780 impl Cnf {
3781 #[doc = "Analog mode / Push-Pull mode"]
3782 pub const PUSHPULL: Self = Self(0);
3783 #[doc = "Floating input (reset state) / Open Drain-Mode"]
3784 pub const OPENDRAIN: Self = Self(0x01);
3785 #[doc = "Input with pull-up/pull-down / Alternate Function Push-Pull Mode"]
3786 pub const ALTPUSHPULL: Self = Self(0x02);
3787 #[doc = "Alternate Function Open-Drain Mode"]
3788 pub const ALTOPENDRAIN: Self = Self(0x03);
3789 }
3790 #[repr(transparent)]
3791 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
3792 pub struct Bsw(pub u8);
3793 impl Bsw {
3794 #[doc = "No action on the corresponding ODx bit"]
3795 pub const NOACTION: Self = Self(0);
3796 #[doc = "Sets the corresponding ODRx bit"]
3797 pub const SET: Self = Self(0x01);
3798 }
3799 #[repr(transparent)]
3800 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
3801 pub struct Lckk(pub u8);
3802 impl Lckk {
3803 #[doc = "Port configuration lock key not active"]
3804 pub const NOTACTIVE: Self = Self(0);
3805 #[doc = "Port configuration lock key active"]
3806 pub const ACTIVE: Self = Self(0x01);
3807 }
3808 #[repr(transparent)]
3809 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
3810 pub struct Mode(pub u8);
3811 impl Mode {
3812 #[doc = "Input mode (reset state)"]
3813 pub const INPUT: Self = Self(0);
3814 #[doc = "Output mode 10 MHz"]
3815 pub const OUTPUT: Self = Self(0x01);
3816 #[doc = "Output mode 2 MHz"]
3817 pub const OUTPUT2: Self = Self(0x02);
3818 #[doc = "Output mode 50 MHz"]
3819 pub const OUTPUT50: Self = Self(0x03);
3820 }
3821 }
3252 pub mod regs { 3822 pub mod regs {
3253 use crate::generic::*; 3823 use crate::generic::*;
3254 #[doc = "Port bit set/reset register (GPIOn_BSRR)"] 3824 #[doc = "Port configuration register (GPIOn_CRx)"]
3255 #[repr(transparent)] 3825 #[repr(transparent)]
3256 #[derive(Copy, Clone, Eq, PartialEq)] 3826 #[derive(Copy, Clone, Eq, PartialEq)]
3257 pub struct Bsrr(pub u32); 3827 pub struct Cr(pub u32);
3258 impl Bsrr { 3828 impl Cr {
3259 #[doc = "Set bit"] 3829 #[doc = "Port n mode bits"]
3260 pub fn bs(&self, n: usize) -> bool { 3830 pub fn mode(&self, n: usize) -> super::vals::Mode {
3261 assert!(n < 16usize); 3831 assert!(n < 8usize);
3262 let offs = 0usize + n * 1usize; 3832 let offs = 0usize + n * 4usize;
3263 let val = (self.0 >> offs) & 0x01; 3833 let val = (self.0 >> offs) & 0x03;
3264 val != 0 3834 super::vals::Mode(val as u8)
3265 } 3835 }
3266 #[doc = "Set bit"] 3836 #[doc = "Port n mode bits"]
3267 pub fn set_bs(&mut self, n: usize, val: bool) { 3837 pub fn set_mode(&mut self, n: usize, val: super::vals::Mode) {
3268 assert!(n < 16usize); 3838 assert!(n < 8usize);
3269 let offs = 0usize + n * 1usize; 3839 let offs = 0usize + n * 4usize;
3270 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); 3840 self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs);
3271 } 3841 }
3272 #[doc = "Reset bit"] 3842 #[doc = "Port n configuration bits"]
3273 pub fn br(&self, n: usize) -> bool { 3843 pub fn cnf(&self, n: usize) -> super::vals::Cnf {
3844 assert!(n < 8usize);
3845 let offs = 2usize + n * 4usize;
3846 let val = (self.0 >> offs) & 0x03;
3847 super::vals::Cnf(val as u8)
3848 }
3849 #[doc = "Port n configuration bits"]
3850 pub fn set_cnf(&mut self, n: usize, val: super::vals::Cnf) {
3851 assert!(n < 8usize);
3852 let offs = 2usize + n * 4usize;
3853 self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs);
3854 }
3855 }
3856 impl Default for Cr {
3857 fn default() -> Cr {
3858 Cr(0)
3859 }
3860 }
3861 #[doc = "Port output data register (GPIOn_ODR)"]
3862 #[repr(transparent)]
3863 #[derive(Copy, Clone, Eq, PartialEq)]
3864 pub struct Odr(pub u32);
3865 impl Odr {
3866 #[doc = "Port output data"]
3867 pub fn odr(&self, n: usize) -> super::vals::Odr {
3274 assert!(n < 16usize); 3868 assert!(n < 16usize);
3275 let offs = 16usize + n * 1usize; 3869 let offs = 0usize + n * 1usize;
3276 let val = (self.0 >> offs) & 0x01; 3870 let val = (self.0 >> offs) & 0x01;
3277 val != 0 3871 super::vals::Odr(val as u8)
3278 } 3872 }
3279 #[doc = "Reset bit"] 3873 #[doc = "Port output data"]
3280 pub fn set_br(&mut self, n: usize, val: bool) { 3874 pub fn set_odr(&mut self, n: usize, val: super::vals::Odr) {
3281 assert!(n < 16usize); 3875 assert!(n < 16usize);
3282 let offs = 16usize + n * 1usize; 3876 let offs = 0usize + n * 1usize;
3283 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); 3877 self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs);
3284 } 3878 }
3285 } 3879 }
3286 impl Default for Bsrr { 3880 impl Default for Odr {
3287 fn default() -> Bsrr { 3881 fn default() -> Odr {
3288 Bsrr(0) 3882 Odr(0)
3289 } 3883 }
3290 } 3884 }
3291 #[doc = "Port configuration lock register"] 3885 #[doc = "Port configuration lock register"]
@@ -3321,89 +3915,41 @@ pub mod gpio_v1 {
3321 Lckr(0) 3915 Lckr(0)
3322 } 3916 }
3323 } 3917 }
3324 #[doc = "Port output data register (GPIOn_ODR)"] 3918 #[doc = "Port bit set/reset register (GPIOn_BSRR)"]
3325 #[repr(transparent)] 3919 #[repr(transparent)]
3326 #[derive(Copy, Clone, Eq, PartialEq)] 3920 #[derive(Copy, Clone, Eq, PartialEq)]
3327 pub struct Odr(pub u32); 3921 pub struct Bsrr(pub u32);
3328 impl Odr { 3922 impl Bsrr {
3329 #[doc = "Port output data"] 3923 #[doc = "Set bit"]
3330 pub fn odr(&self, n: usize) -> super::vals::Odr { 3924 pub fn bs(&self, n: usize) -> bool {
3331 assert!(n < 16usize); 3925 assert!(n < 16usize);
3332 let offs = 0usize + n * 1usize; 3926 let offs = 0usize + n * 1usize;
3333 let val = (self.0 >> offs) & 0x01; 3927 let val = (self.0 >> offs) & 0x01;
3334 super::vals::Odr(val as u8) 3928 val != 0
3335 } 3929 }
3336 #[doc = "Port output data"] 3930 #[doc = "Set bit"]
3337 pub fn set_odr(&mut self, n: usize, val: super::vals::Odr) { 3931 pub fn set_bs(&mut self, n: usize, val: bool) {
3338 assert!(n < 16usize); 3932 assert!(n < 16usize);
3339 let offs = 0usize + n * 1usize; 3933 let offs = 0usize + n * 1usize;
3340 self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); 3934 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
3341 }
3342 }
3343 impl Default for Odr {
3344 fn default() -> Odr {
3345 Odr(0)
3346 }
3347 }
3348 #[doc = "Port configuration register (GPIOn_CRx)"]
3349 #[repr(transparent)]
3350 #[derive(Copy, Clone, Eq, PartialEq)]
3351 pub struct Cr(pub u32);
3352 impl Cr {
3353 #[doc = "Port n mode bits"]
3354 pub fn mode(&self, n: usize) -> super::vals::Mode {
3355 assert!(n < 8usize);
3356 let offs = 0usize + n * 4usize;
3357 let val = (self.0 >> offs) & 0x03;
3358 super::vals::Mode(val as u8)
3359 }
3360 #[doc = "Port n mode bits"]
3361 pub fn set_mode(&mut self, n: usize, val: super::vals::Mode) {
3362 assert!(n < 8usize);
3363 let offs = 0usize + n * 4usize;
3364 self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs);
3365 }
3366 #[doc = "Port n configuration bits"]
3367 pub fn cnf(&self, n: usize) -> super::vals::Cnf {
3368 assert!(n < 8usize);
3369 let offs = 2usize + n * 4usize;
3370 let val = (self.0 >> offs) & 0x03;
3371 super::vals::Cnf(val as u8)
3372 }
3373 #[doc = "Port n configuration bits"]
3374 pub fn set_cnf(&mut self, n: usize, val: super::vals::Cnf) {
3375 assert!(n < 8usize);
3376 let offs = 2usize + n * 4usize;
3377 self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs);
3378 }
3379 }
3380 impl Default for Cr {
3381 fn default() -> Cr {
3382 Cr(0)
3383 } 3935 }
3384 }
3385 #[doc = "Port bit reset register (GPIOn_BRR)"]
3386 #[repr(transparent)]
3387 #[derive(Copy, Clone, Eq, PartialEq)]
3388 pub struct Brr(pub u32);
3389 impl Brr {
3390 #[doc = "Reset bit"] 3936 #[doc = "Reset bit"]
3391 pub fn br(&self, n: usize) -> bool { 3937 pub fn br(&self, n: usize) -> bool {
3392 assert!(n < 16usize); 3938 assert!(n < 16usize);
3393 let offs = 0usize + n * 1usize; 3939 let offs = 16usize + n * 1usize;
3394 let val = (self.0 >> offs) & 0x01; 3940 let val = (self.0 >> offs) & 0x01;
3395 val != 0 3941 val != 0
3396 } 3942 }
3397 #[doc = "Reset bit"] 3943 #[doc = "Reset bit"]
3398 pub fn set_br(&mut self, n: usize, val: bool) { 3944 pub fn set_br(&mut self, n: usize, val: bool) {
3399 assert!(n < 16usize); 3945 assert!(n < 16usize);
3400 let offs = 0usize + n * 1usize; 3946 let offs = 16usize + n * 1usize;
3401 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); 3947 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
3402 } 3948 }
3403 } 3949 }
3404 impl Default for Brr { 3950 impl Default for Bsrr {
3405 fn default() -> Brr { 3951 fn default() -> Bsrr {
3406 Brr(0) 3952 Bsrr(0)
3407 } 3953 }
3408 } 3954 }
3409 #[doc = "Port input data register (GPIOn_IDR)"] 3955 #[doc = "Port input data register (GPIOn_IDR)"]
@@ -3430,88 +3976,29 @@ pub mod gpio_v1 {
3430 Idr(0) 3976 Idr(0)
3431 } 3977 }
3432 } 3978 }
3433 } 3979 #[doc = "Port bit reset register (GPIOn_BRR)"]
3434 pub mod vals {
3435 use crate::generic::*;
3436 #[repr(transparent)]
3437 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
3438 pub struct Lckk(pub u8);
3439 impl Lckk {
3440 #[doc = "Port configuration lock key not active"]
3441 pub const NOTACTIVE: Self = Self(0);
3442 #[doc = "Port configuration lock key active"]
3443 pub const ACTIVE: Self = Self(0x01);
3444 }
3445 #[repr(transparent)]
3446 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
3447 pub struct Odr(pub u8);
3448 impl Odr {
3449 #[doc = "Set output to logic low"]
3450 pub const LOW: Self = Self(0);
3451 #[doc = "Set output to logic high"]
3452 pub const HIGH: Self = Self(0x01);
3453 }
3454 #[repr(transparent)]
3455 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
3456 pub struct Lck(pub u8);
3457 impl Lck {
3458 #[doc = "Port configuration not locked"]
3459 pub const UNLOCKED: Self = Self(0);
3460 #[doc = "Port configuration locked"]
3461 pub const LOCKED: Self = Self(0x01);
3462 }
3463 #[repr(transparent)]
3464 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
3465 pub struct Bsw(pub u8);
3466 impl Bsw {
3467 #[doc = "No action on the corresponding ODx bit"]
3468 pub const NOACTION: Self = Self(0);
3469 #[doc = "Sets the corresponding ODRx bit"]
3470 pub const SET: Self = Self(0x01);
3471 }
3472 #[repr(transparent)]
3473 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
3474 pub struct Brw(pub u8);
3475 impl Brw {
3476 #[doc = "No action on the corresponding ODx bit"]
3477 pub const NOACTION: Self = Self(0);
3478 #[doc = "Reset the ODx bit"]
3479 pub const RESET: Self = Self(0x01);
3480 }
3481 #[repr(transparent)]
3482 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
3483 pub struct Idr(pub u8);
3484 impl Idr {
3485 #[doc = "Input is logic low"]
3486 pub const LOW: Self = Self(0);
3487 #[doc = "Input is logic high"]
3488 pub const HIGH: Self = Self(0x01);
3489 }
3490 #[repr(transparent)] 3980 #[repr(transparent)]
3491 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 3981 #[derive(Copy, Clone, Eq, PartialEq)]
3492 pub struct Mode(pub u8); 3982 pub struct Brr(pub u32);
3493 impl Mode { 3983 impl Brr {
3494 #[doc = "Input mode (reset state)"] 3984 #[doc = "Reset bit"]
3495 pub const INPUT: Self = Self(0); 3985 pub fn br(&self, n: usize) -> bool {
3496 #[doc = "Output mode 10 MHz"] 3986 assert!(n < 16usize);
3497 pub const OUTPUT: Self = Self(0x01); 3987 let offs = 0usize + n * 1usize;
3498 #[doc = "Output mode 2 MHz"] 3988 let val = (self.0 >> offs) & 0x01;
3499 pub const OUTPUT2: Self = Self(0x02); 3989 val != 0
3500 #[doc = "Output mode 50 MHz"] 3990 }
3501 pub const OUTPUT50: Self = Self(0x03); 3991 #[doc = "Reset bit"]
3992 pub fn set_br(&mut self, n: usize, val: bool) {
3993 assert!(n < 16usize);
3994 let offs = 0usize + n * 1usize;
3995 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
3996 }
3502 } 3997 }
3503 #[repr(transparent)] 3998 impl Default for Brr {
3504 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 3999 fn default() -> Brr {
3505 pub struct Cnf(pub u8); 4000 Brr(0)
3506 impl Cnf { 4001 }
3507 #[doc = "Analog mode / Push-Pull mode"]
3508 pub const PUSHPULL: Self = Self(0);
3509 #[doc = "Floating input (reset state) / Open Drain-Mode"]
3510 pub const OPENDRAIN: Self = Self(0x01);
3511 #[doc = "Input with pull-up/pull-down / Alternate Function Push-Pull Mode"]
3512 pub const ALTPUSHPULL: Self = Self(0x02);
3513 #[doc = "Alternate Function Open-Drain Mode"]
3514 pub const ALTOPENDRAIN: Self = Self(0x03);
3515 } 4002 }
3516 } 4003 }
3517} 4004}
@@ -3585,118 +4072,60 @@ pub mod usart_v1 {
3585 } 4072 }
3586 pub mod regs { 4073 pub mod regs {
3587 use crate::generic::*; 4074 use crate::generic::*;
3588 #[doc = "Baud rate register"] 4075 #[doc = "Control register 2"]
3589 #[repr(transparent)] 4076 #[repr(transparent)]
3590 #[derive(Copy, Clone, Eq, PartialEq)] 4077 #[derive(Copy, Clone, Eq, PartialEq)]
3591 pub struct Brr(pub u32); 4078 pub struct Cr2(pub u32);
3592 impl Brr { 4079 impl Cr2 {
3593 #[doc = "fraction of USARTDIV"] 4080 #[doc = "Address of the USART node"]
3594 pub const fn div_fraction(&self) -> u8 { 4081 pub const fn add(&self) -> u8 {
3595 let val = (self.0 >> 0usize) & 0x0f; 4082 let val = (self.0 >> 0usize) & 0x0f;
3596 val as u8 4083 val as u8
3597 } 4084 }
3598 #[doc = "fraction of USARTDIV"] 4085 #[doc = "Address of the USART node"]
3599 pub fn set_div_fraction(&mut self, val: u8) { 4086 pub fn set_add(&mut self, val: u8) {
3600 self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize); 4087 self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize);
3601 } 4088 }
3602 #[doc = "mantissa of USARTDIV"] 4089 #[doc = "lin break detection length"]
3603 pub const fn div_mantissa(&self) -> u16 { 4090 pub const fn lbdl(&self) -> super::vals::Lbdl {
3604 let val = (self.0 >> 4usize) & 0x0fff; 4091 let val = (self.0 >> 5usize) & 0x01;
3605 val as u16 4092 super::vals::Lbdl(val as u8)
3606 }
3607 #[doc = "mantissa of USARTDIV"]
3608 pub fn set_div_mantissa(&mut self, val: u16) {
3609 self.0 = (self.0 & !(0x0fff << 4usize)) | (((val as u32) & 0x0fff) << 4usize);
3610 }
3611 }
3612 impl Default for Brr {
3613 fn default() -> Brr {
3614 Brr(0)
3615 }
3616 }
3617 #[doc = "Data register"]
3618 #[repr(transparent)]
3619 #[derive(Copy, Clone, Eq, PartialEq)]
3620 pub struct Dr(pub u32);
3621 impl Dr {
3622 #[doc = "Data value"]
3623 pub const fn dr(&self) -> u16 {
3624 let val = (self.0 >> 0usize) & 0x01ff;
3625 val as u16
3626 }
3627 #[doc = "Data value"]
3628 pub fn set_dr(&mut self, val: u16) {
3629 self.0 = (self.0 & !(0x01ff << 0usize)) | (((val as u32) & 0x01ff) << 0usize);
3630 }
3631 }
3632 impl Default for Dr {
3633 fn default() -> Dr {
3634 Dr(0)
3635 }
3636 }
3637 #[doc = "Control register 3"]
3638 #[repr(transparent)]
3639 #[derive(Copy, Clone, Eq, PartialEq)]
3640 pub struct Cr3(pub u32);
3641 impl Cr3 {
3642 #[doc = "Error interrupt enable"]
3643 pub const fn eie(&self) -> bool {
3644 let val = (self.0 >> 0usize) & 0x01;
3645 val != 0
3646 }
3647 #[doc = "Error interrupt enable"]
3648 pub fn set_eie(&mut self, val: bool) {
3649 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
3650 }
3651 #[doc = "IrDA mode enable"]
3652 pub const fn iren(&self) -> bool {
3653 let val = (self.0 >> 1usize) & 0x01;
3654 val != 0
3655 }
3656 #[doc = "IrDA mode enable"]
3657 pub fn set_iren(&mut self, val: bool) {
3658 self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
3659 }
3660 #[doc = "IrDA low-power"]
3661 pub const fn irlp(&self) -> super::vals::Irlp {
3662 let val = (self.0 >> 2usize) & 0x01;
3663 super::vals::Irlp(val as u8)
3664 }
3665 #[doc = "IrDA low-power"]
3666 pub fn set_irlp(&mut self, val: super::vals::Irlp) {
3667 self.0 = (self.0 & !(0x01 << 2usize)) | (((val.0 as u32) & 0x01) << 2usize);
3668 }
3669 #[doc = "Half-duplex selection"]
3670 pub const fn hdsel(&self) -> super::vals::Hdsel {
3671 let val = (self.0 >> 3usize) & 0x01;
3672 super::vals::Hdsel(val as u8)
3673 } 4093 }
3674 #[doc = "Half-duplex selection"] 4094 #[doc = "lin break detection length"]
3675 pub fn set_hdsel(&mut self, val: super::vals::Hdsel) { 4095 pub fn set_lbdl(&mut self, val: super::vals::Lbdl) {
3676 self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize); 4096 self.0 = (self.0 & !(0x01 << 5usize)) | (((val.0 as u32) & 0x01) << 5usize);
3677 } 4097 }
3678 #[doc = "DMA enable receiver"] 4098 #[doc = "LIN break detection interrupt enable"]
3679 pub const fn dmar(&self) -> bool { 4099 pub const fn lbdie(&self) -> bool {
3680 let val = (self.0 >> 6usize) & 0x01; 4100 let val = (self.0 >> 6usize) & 0x01;
3681 val != 0 4101 val != 0
3682 } 4102 }
3683 #[doc = "DMA enable receiver"] 4103 #[doc = "LIN break detection interrupt enable"]
3684 pub fn set_dmar(&mut self, val: bool) { 4104 pub fn set_lbdie(&mut self, val: bool) {
3685 self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); 4105 self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
3686 } 4106 }
3687 #[doc = "DMA enable transmitter"] 4107 #[doc = "STOP bits"]
3688 pub const fn dmat(&self) -> bool { 4108 pub const fn stop(&self) -> super::vals::Stop {
3689 let val = (self.0 >> 7usize) & 0x01; 4109 let val = (self.0 >> 12usize) & 0x03;
4110 super::vals::Stop(val as u8)
4111 }
4112 #[doc = "STOP bits"]
4113 pub fn set_stop(&mut self, val: super::vals::Stop) {
4114 self.0 = (self.0 & !(0x03 << 12usize)) | (((val.0 as u32) & 0x03) << 12usize);
4115 }
4116 #[doc = "LIN mode enable"]
4117 pub const fn linen(&self) -> bool {
4118 let val = (self.0 >> 14usize) & 0x01;
3690 val != 0 4119 val != 0
3691 } 4120 }
3692 #[doc = "DMA enable transmitter"] 4121 #[doc = "LIN mode enable"]
3693 pub fn set_dmat(&mut self, val: bool) { 4122 pub fn set_linen(&mut self, val: bool) {
3694 self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); 4123 self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
3695 } 4124 }
3696 } 4125 }
3697 impl Default for Cr3 { 4126 impl Default for Cr2 {
3698 fn default() -> Cr3 { 4127 fn default() -> Cr2 {
3699 Cr3(0) 4128 Cr2(0)
3700 } 4129 }
3701 } 4130 }
3702 #[doc = "Status register"] 4131 #[doc = "Status register"]
@@ -3829,6 +4258,118 @@ pub mod usart_v1 {
3829 Gtpr(0) 4258 Gtpr(0)
3830 } 4259 }
3831 } 4260 }
4261 #[doc = "Status register"]
4262 #[repr(transparent)]
4263 #[derive(Copy, Clone, Eq, PartialEq)]
4264 pub struct Sr(pub u32);
4265 impl Sr {
4266 #[doc = "Parity error"]
4267 pub const fn pe(&self) -> bool {
4268 let val = (self.0 >> 0usize) & 0x01;
4269 val != 0
4270 }
4271 #[doc = "Parity error"]
4272 pub fn set_pe(&mut self, val: bool) {
4273 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
4274 }
4275 #[doc = "Framing error"]
4276 pub const fn fe(&self) -> bool {
4277 let val = (self.0 >> 1usize) & 0x01;
4278 val != 0
4279 }
4280 #[doc = "Framing error"]
4281 pub fn set_fe(&mut self, val: bool) {
4282 self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
4283 }
4284 #[doc = "Noise error flag"]
4285 pub const fn ne(&self) -> bool {
4286 let val = (self.0 >> 2usize) & 0x01;
4287 val != 0
4288 }
4289 #[doc = "Noise error flag"]
4290 pub fn set_ne(&mut self, val: bool) {
4291 self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
4292 }
4293 #[doc = "Overrun error"]
4294 pub const fn ore(&self) -> bool {
4295 let val = (self.0 >> 3usize) & 0x01;
4296 val != 0
4297 }
4298 #[doc = "Overrun error"]
4299 pub fn set_ore(&mut self, val: bool) {
4300 self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
4301 }
4302 #[doc = "IDLE line detected"]
4303 pub const fn idle(&self) -> bool {
4304 let val = (self.0 >> 4usize) & 0x01;
4305 val != 0
4306 }
4307 #[doc = "IDLE line detected"]
4308 pub fn set_idle(&mut self, val: bool) {
4309 self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
4310 }
4311 #[doc = "Read data register not empty"]
4312 pub const fn rxne(&self) -> bool {
4313 let val = (self.0 >> 5usize) & 0x01;
4314 val != 0
4315 }
4316 #[doc = "Read data register not empty"]
4317 pub fn set_rxne(&mut self, val: bool) {
4318 self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
4319 }
4320 #[doc = "Transmission complete"]
4321 pub const fn tc(&self) -> bool {
4322 let val = (self.0 >> 6usize) & 0x01;
4323 val != 0
4324 }
4325 #[doc = "Transmission complete"]
4326 pub fn set_tc(&mut self, val: bool) {
4327 self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
4328 }
4329 #[doc = "Transmit data register empty"]
4330 pub const fn txe(&self) -> bool {
4331 let val = (self.0 >> 7usize) & 0x01;
4332 val != 0
4333 }
4334 #[doc = "Transmit data register empty"]
4335 pub fn set_txe(&mut self, val: bool) {
4336 self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
4337 }
4338 #[doc = "LIN break detection flag"]
4339 pub const fn lbd(&self) -> bool {
4340 let val = (self.0 >> 8usize) & 0x01;
4341 val != 0
4342 }
4343 #[doc = "LIN break detection flag"]
4344 pub fn set_lbd(&mut self, val: bool) {
4345 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
4346 }
4347 }
4348 impl Default for Sr {
4349 fn default() -> Sr {
4350 Sr(0)
4351 }
4352 }
4353 #[doc = "Data register"]
4354 #[repr(transparent)]
4355 #[derive(Copy, Clone, Eq, PartialEq)]
4356 pub struct Dr(pub u32);
4357 impl Dr {
4358 #[doc = "Data value"]
4359 pub const fn dr(&self) -> u16 {
4360 let val = (self.0 >> 0usize) & 0x01ff;
4361 val as u16
4362 }
4363 #[doc = "Data value"]
4364 pub fn set_dr(&mut self, val: u16) {
4365 self.0 = (self.0 & !(0x01ff << 0usize)) | (((val as u32) & 0x01ff) << 0usize);
4366 }
4367 }
4368 impl Default for Dr {
4369 fn default() -> Dr {
4370 Dr(0)
4371 }
4372 }
3832 #[doc = "Control register 2"] 4373 #[doc = "Control register 2"]
3833 #[repr(transparent)] 4374 #[repr(transparent)]
3834 #[derive(Copy, Clone, Eq, PartialEq)] 4375 #[derive(Copy, Clone, Eq, PartialEq)]
@@ -4168,152 +4709,98 @@ pub mod usart_v1 {
4168 Cr3Usart(0) 4709 Cr3Usart(0)
4169 } 4710 }
4170 } 4711 }
4171 #[doc = "Control register 2"] 4712 #[doc = "Control register 3"]
4172 #[repr(transparent)]
4173 #[derive(Copy, Clone, Eq, PartialEq)]
4174 pub struct Cr2(pub u32);
4175 impl Cr2 {
4176 #[doc = "Address of the USART node"]
4177 pub const fn add(&self) -> u8 {
4178 let val = (self.0 >> 0usize) & 0x0f;
4179 val as u8
4180 }
4181 #[doc = "Address of the USART node"]
4182 pub fn set_add(&mut self, val: u8) {
4183 self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize);
4184 }
4185 #[doc = "lin break detection length"]
4186 pub const fn lbdl(&self) -> super::vals::Lbdl {
4187 let val = (self.0 >> 5usize) & 0x01;
4188 super::vals::Lbdl(val as u8)
4189 }
4190 #[doc = "lin break detection length"]
4191 pub fn set_lbdl(&mut self, val: super::vals::Lbdl) {
4192 self.0 = (self.0 & !(0x01 << 5usize)) | (((val.0 as u32) & 0x01) << 5usize);
4193 }
4194 #[doc = "LIN break detection interrupt enable"]
4195 pub const fn lbdie(&self) -> bool {
4196 let val = (self.0 >> 6usize) & 0x01;
4197 val != 0
4198 }
4199 #[doc = "LIN break detection interrupt enable"]
4200 pub fn set_lbdie(&mut self, val: bool) {
4201 self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
4202 }
4203 #[doc = "STOP bits"]
4204 pub const fn stop(&self) -> super::vals::Stop {
4205 let val = (self.0 >> 12usize) & 0x03;
4206 super::vals::Stop(val as u8)
4207 }
4208 #[doc = "STOP bits"]
4209 pub fn set_stop(&mut self, val: super::vals::Stop) {
4210 self.0 = (self.0 & !(0x03 << 12usize)) | (((val.0 as u32) & 0x03) << 12usize);
4211 }
4212 #[doc = "LIN mode enable"]
4213 pub const fn linen(&self) -> bool {
4214 let val = (self.0 >> 14usize) & 0x01;
4215 val != 0
4216 }
4217 #[doc = "LIN mode enable"]
4218 pub fn set_linen(&mut self, val: bool) {
4219 self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
4220 }
4221 }
4222 impl Default for Cr2 {
4223 fn default() -> Cr2 {
4224 Cr2(0)
4225 }
4226 }
4227 #[doc = "Status register"]
4228 #[repr(transparent)] 4713 #[repr(transparent)]
4229 #[derive(Copy, Clone, Eq, PartialEq)] 4714 #[derive(Copy, Clone, Eq, PartialEq)]
4230 pub struct Sr(pub u32); 4715 pub struct Cr3(pub u32);
4231 impl Sr { 4716 impl Cr3 {
4232 #[doc = "Parity error"] 4717 #[doc = "Error interrupt enable"]
4233 pub const fn pe(&self) -> bool { 4718 pub const fn eie(&self) -> bool {
4234 let val = (self.0 >> 0usize) & 0x01; 4719 let val = (self.0 >> 0usize) & 0x01;
4235 val != 0 4720 val != 0
4236 } 4721 }
4237 #[doc = "Parity error"] 4722 #[doc = "Error interrupt enable"]
4238 pub fn set_pe(&mut self, val: bool) { 4723 pub fn set_eie(&mut self, val: bool) {
4239 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); 4724 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
4240 } 4725 }
4241 #[doc = "Framing error"] 4726 #[doc = "IrDA mode enable"]
4242 pub const fn fe(&self) -> bool { 4727 pub const fn iren(&self) -> bool {
4243 let val = (self.0 >> 1usize) & 0x01; 4728 let val = (self.0 >> 1usize) & 0x01;
4244 val != 0 4729 val != 0
4245 } 4730 }
4246 #[doc = "Framing error"] 4731 #[doc = "IrDA mode enable"]
4247 pub fn set_fe(&mut self, val: bool) { 4732 pub fn set_iren(&mut self, val: bool) {
4248 self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); 4733 self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
4249 } 4734 }
4250 #[doc = "Noise error flag"] 4735 #[doc = "IrDA low-power"]
4251 pub const fn ne(&self) -> bool { 4736 pub const fn irlp(&self) -> super::vals::Irlp {
4252 let val = (self.0 >> 2usize) & 0x01; 4737 let val = (self.0 >> 2usize) & 0x01;
4253 val != 0 4738 super::vals::Irlp(val as u8)
4254 } 4739 }
4255 #[doc = "Noise error flag"] 4740 #[doc = "IrDA low-power"]
4256 pub fn set_ne(&mut self, val: bool) { 4741 pub fn set_irlp(&mut self, val: super::vals::Irlp) {
4257 self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); 4742 self.0 = (self.0 & !(0x01 << 2usize)) | (((val.0 as u32) & 0x01) << 2usize);
4258 } 4743 }
4259 #[doc = "Overrun error"] 4744 #[doc = "Half-duplex selection"]
4260 pub const fn ore(&self) -> bool { 4745 pub const fn hdsel(&self) -> super::vals::Hdsel {
4261 let val = (self.0 >> 3usize) & 0x01; 4746 let val = (self.0 >> 3usize) & 0x01;
4262 val != 0 4747 super::vals::Hdsel(val as u8)
4263 }
4264 #[doc = "Overrun error"]
4265 pub fn set_ore(&mut self, val: bool) {
4266 self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
4267 }
4268 #[doc = "IDLE line detected"]
4269 pub const fn idle(&self) -> bool {
4270 let val = (self.0 >> 4usize) & 0x01;
4271 val != 0
4272 }
4273 #[doc = "IDLE line detected"]
4274 pub fn set_idle(&mut self, val: bool) {
4275 self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
4276 }
4277 #[doc = "Read data register not empty"]
4278 pub const fn rxne(&self) -> bool {
4279 let val = (self.0 >> 5usize) & 0x01;
4280 val != 0
4281 } 4748 }
4282 #[doc = "Read data register not empty"] 4749 #[doc = "Half-duplex selection"]
4283 pub fn set_rxne(&mut self, val: bool) { 4750 pub fn set_hdsel(&mut self, val: super::vals::Hdsel) {
4284 self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); 4751 self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize);
4285 } 4752 }
4286 #[doc = "Transmission complete"] 4753 #[doc = "DMA enable receiver"]
4287 pub const fn tc(&self) -> bool { 4754 pub const fn dmar(&self) -> bool {
4288 let val = (self.0 >> 6usize) & 0x01; 4755 let val = (self.0 >> 6usize) & 0x01;
4289 val != 0 4756 val != 0
4290 } 4757 }
4291 #[doc = "Transmission complete"] 4758 #[doc = "DMA enable receiver"]
4292 pub fn set_tc(&mut self, val: bool) { 4759 pub fn set_dmar(&mut self, val: bool) {
4293 self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); 4760 self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
4294 } 4761 }
4295 #[doc = "Transmit data register empty"] 4762 #[doc = "DMA enable transmitter"]
4296 pub const fn txe(&self) -> bool { 4763 pub const fn dmat(&self) -> bool {
4297 let val = (self.0 >> 7usize) & 0x01; 4764 let val = (self.0 >> 7usize) & 0x01;
4298 val != 0 4765 val != 0
4299 } 4766 }
4300 #[doc = "Transmit data register empty"] 4767 #[doc = "DMA enable transmitter"]
4301 pub fn set_txe(&mut self, val: bool) { 4768 pub fn set_dmat(&mut self, val: bool) {
4302 self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); 4769 self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
4303 } 4770 }
4304 #[doc = "LIN break detection flag"] 4771 }
4305 pub const fn lbd(&self) -> bool { 4772 impl Default for Cr3 {
4306 let val = (self.0 >> 8usize) & 0x01; 4773 fn default() -> Cr3 {
4307 val != 0 4774 Cr3(0)
4308 } 4775 }
4309 #[doc = "LIN break detection flag"] 4776 }
4310 pub fn set_lbd(&mut self, val: bool) { 4777 #[doc = "Baud rate register"]
4311 self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); 4778 #[repr(transparent)]
4779 #[derive(Copy, Clone, Eq, PartialEq)]
4780 pub struct Brr(pub u32);
4781 impl Brr {
4782 #[doc = "fraction of USARTDIV"]
4783 pub const fn div_fraction(&self) -> u8 {
4784 let val = (self.0 >> 0usize) & 0x0f;
4785 val as u8
4786 }
4787 #[doc = "fraction of USARTDIV"]
4788 pub fn set_div_fraction(&mut self, val: u8) {
4789 self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize);
4790 }
4791 #[doc = "mantissa of USARTDIV"]
4792 pub const fn div_mantissa(&self) -> u16 {
4793 let val = (self.0 >> 4usize) & 0x0fff;
4794 val as u16
4795 }
4796 #[doc = "mantissa of USARTDIV"]
4797 pub fn set_div_mantissa(&mut self, val: u16) {
4798 self.0 = (self.0 & !(0x0fff << 4usize)) | (((val as u32) & 0x0fff) << 4usize);
4312 } 4799 }
4313 } 4800 }
4314 impl Default for Sr { 4801 impl Default for Brr {
4315 fn default() -> Sr { 4802 fn default() -> Brr {
4316 Sr(0) 4803 Brr(0)
4317 } 4804 }
4318 } 4805 }
4319 } 4806 }
@@ -4321,46 +4808,6 @@ pub mod usart_v1 {
4321 use crate::generic::*; 4808 use crate::generic::*;
4322 #[repr(transparent)] 4809 #[repr(transparent)]
4323 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 4810 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4324 pub struct Stop(pub u8);
4325 impl Stop {
4326 #[doc = "1 stop bit"]
4327 pub const STOP1: Self = Self(0);
4328 #[doc = "0.5 stop bits"]
4329 pub const STOP0P5: Self = Self(0x01);
4330 #[doc = "2 stop bits"]
4331 pub const STOP2: Self = Self(0x02);
4332 #[doc = "1.5 stop bits"]
4333 pub const STOP1P5: Self = Self(0x03);
4334 }
4335 #[repr(transparent)]
4336 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4337 pub struct Irlp(pub u8);
4338 impl Irlp {
4339 #[doc = "Normal mode"]
4340 pub const NORMAL: Self = Self(0);
4341 #[doc = "Low-power mode"]
4342 pub const LOWPOWER: Self = Self(0x01);
4343 }
4344 #[repr(transparent)]
4345 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4346 pub struct Hdsel(pub u8);
4347 impl Hdsel {
4348 #[doc = "Half duplex mode is not selected"]
4349 pub const FULLDUPLEX: Self = Self(0);
4350 #[doc = "Half duplex mode is selected"]
4351 pub const HALFDUPLEX: Self = Self(0x01);
4352 }
4353 #[repr(transparent)]
4354 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4355 pub struct Lbdl(pub u8);
4356 impl Lbdl {
4357 #[doc = "10-bit break detection"]
4358 pub const LBDL10: Self = Self(0);
4359 #[doc = "11-bit break detection"]
4360 pub const LBDL11: Self = Self(0x01);
4361 }
4362 #[repr(transparent)]
4363 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4364 pub struct M(pub u8); 4811 pub struct M(pub u8);
4365 impl M { 4812 impl M {
4366 #[doc = "8 data bits"] 4813 #[doc = "8 data bits"]
@@ -4388,15 +4835,6 @@ pub mod usart_v1 {
4388 } 4835 }
4389 #[repr(transparent)] 4836 #[repr(transparent)]
4390 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 4837 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4391 pub struct Cpol(pub u8);
4392 impl Cpol {
4393 #[doc = "Steady low value on CK pin outside transmission window"]
4394 pub const LOW: Self = Self(0);
4395 #[doc = "Steady high value on CK pin outside transmission window"]
4396 pub const HIGH: Self = Self(0x01);
4397 }
4398 #[repr(transparent)]
4399 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4400 pub struct Wake(pub u8); 4838 pub struct Wake(pub u8);
4401 impl Wake { 4839 impl Wake {
4402 #[doc = "USART wakeup on idle line"] 4840 #[doc = "USART wakeup on idle line"]
@@ -4406,6 +4844,24 @@ pub mod usart_v1 {
4406 } 4844 }
4407 #[repr(transparent)] 4845 #[repr(transparent)]
4408 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 4846 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4847 pub struct Hdsel(pub u8);
4848 impl Hdsel {
4849 #[doc = "Half duplex mode is not selected"]
4850 pub const FULLDUPLEX: Self = Self(0);
4851 #[doc = "Half duplex mode is selected"]
4852 pub const HALFDUPLEX: Self = Self(0x01);
4853 }
4854 #[repr(transparent)]
4855 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4856 pub struct Lbdl(pub u8);
4857 impl Lbdl {
4858 #[doc = "10-bit break detection"]
4859 pub const LBDL10: Self = Self(0);
4860 #[doc = "11-bit break detection"]
4861 pub const LBDL11: Self = Self(0x01);
4862 }
4863 #[repr(transparent)]
4864 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4409 pub struct Sbk(pub u8); 4865 pub struct Sbk(pub u8);
4410 impl Sbk { 4866 impl Sbk {
4411 #[doc = "No break character is transmitted"] 4867 #[doc = "No break character is transmitted"]
@@ -4415,6 +4871,28 @@ pub mod usart_v1 {
4415 } 4871 }
4416 #[repr(transparent)] 4872 #[repr(transparent)]
4417 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 4873 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4874 pub struct Stop(pub u8);
4875 impl Stop {
4876 #[doc = "1 stop bit"]
4877 pub const STOP1: Self = Self(0);
4878 #[doc = "0.5 stop bits"]
4879 pub const STOP0P5: Self = Self(0x01);
4880 #[doc = "2 stop bits"]
4881 pub const STOP2: Self = Self(0x02);
4882 #[doc = "1.5 stop bits"]
4883 pub const STOP1P5: Self = Self(0x03);
4884 }
4885 #[repr(transparent)]
4886 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4887 pub struct Irlp(pub u8);
4888 impl Irlp {
4889 #[doc = "Normal mode"]
4890 pub const NORMAL: Self = Self(0);
4891 #[doc = "Low-power mode"]
4892 pub const LOWPOWER: Self = Self(0x01);
4893 }
4894 #[repr(transparent)]
4895 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4418 pub struct Ps(pub u8); 4896 pub struct Ps(pub u8);
4419 impl Ps { 4897 impl Ps {
4420 #[doc = "Even parity"] 4898 #[doc = "Even parity"]
@@ -4422,497 +4900,41 @@ pub mod usart_v1 {
4422 #[doc = "Odd parity"] 4900 #[doc = "Odd parity"]
4423 pub const ODD: Self = Self(0x01); 4901 pub const ODD: Self = Self(0x01);
4424 } 4902 }
4903 #[repr(transparent)]
4904 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4905 pub struct Cpol(pub u8);
4906 impl Cpol {
4907 #[doc = "Steady low value on CK pin outside transmission window"]
4908 pub const LOW: Self = Self(0);
4909 #[doc = "Steady high value on CK pin outside transmission window"]
4910 pub const HIGH: Self = Self(0x01);
4911 }
4425 } 4912 }
4426} 4913}
4427pub mod dma_v1 { 4914pub mod dma_v2 {
4428 use crate::generic::*; 4915 use crate::generic::*;
4429 #[doc = "Channel cluster: CCR?, CNDTR?, CPAR?, and CMAR? registers"]
4430 #[derive(Copy, Clone)]
4431 pub struct Ch(pub *mut u8);
4432 unsafe impl Send for Ch {}
4433 unsafe impl Sync for Ch {}
4434 impl Ch {
4435 #[doc = "DMA channel configuration register (DMA_CCR)"]
4436 pub fn cr(self) -> Reg<regs::Cr, RW> {
4437 unsafe { Reg::from_ptr(self.0.add(0usize)) }
4438 }
4439 #[doc = "DMA channel 1 number of data register"]
4440 pub fn ndtr(self) -> Reg<regs::Ndtr, RW> {
4441 unsafe { Reg::from_ptr(self.0.add(4usize)) }
4442 }
4443 #[doc = "DMA channel 1 peripheral address register"]
4444 pub fn par(self) -> Reg<u32, RW> {
4445 unsafe { Reg::from_ptr(self.0.add(8usize)) }
4446 }
4447 #[doc = "DMA channel 1 memory address register"]
4448 pub fn mar(self) -> Reg<u32, RW> {
4449 unsafe { Reg::from_ptr(self.0.add(12usize)) }
4450 }
4451 }
4452 #[doc = "DMA controller"] 4916 #[doc = "DMA controller"]
4453 #[derive(Copy, Clone)] 4917 #[derive(Copy, Clone)]
4454 pub struct Dma(pub *mut u8); 4918 pub struct Dma(pub *mut u8);
4455 unsafe impl Send for Dma {} 4919 unsafe impl Send for Dma {}
4456 unsafe impl Sync for Dma {} 4920 unsafe impl Sync for Dma {}
4457 impl Dma { 4921 impl Dma {
4458 #[doc = "DMA interrupt status register (DMA_ISR)"] 4922 #[doc = "low interrupt status register"]
4459 pub fn isr(self) -> Reg<regs::Isr, R> { 4923 pub fn isr(self, n: usize) -> Reg<regs::Isr, R> {
4460 unsafe { Reg::from_ptr(self.0.add(0usize)) } 4924 assert!(n < 2usize);
4461 } 4925 unsafe { Reg::from_ptr(self.0.add(0usize + n * 4usize)) }
4462 #[doc = "DMA interrupt flag clear register (DMA_IFCR)"]
4463 pub fn ifcr(self) -> Reg<regs::Ifcr, W> {
4464 unsafe { Reg::from_ptr(self.0.add(4usize)) }
4465 }
4466 #[doc = "Channel cluster: CCR?, CNDTR?, CPAR?, and CMAR? registers"]
4467 pub fn ch(self, n: usize) -> Ch {
4468 assert!(n < 7usize);
4469 unsafe { Ch(self.0.add(8usize + n * 20usize)) }
4470 }
4471 }
4472 pub mod vals {
4473 use crate::generic::*;
4474 #[repr(transparent)]
4475 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4476 pub struct Memmem(pub u8);
4477 impl Memmem {
4478 #[doc = "Memory to memory mode disabled"]
4479 pub const DISABLED: Self = Self(0);
4480 #[doc = "Memory to memory mode enabled"]
4481 pub const ENABLED: Self = Self(0x01);
4482 }
4483 #[repr(transparent)]
4484 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4485 pub struct Inc(pub u8);
4486 impl Inc {
4487 #[doc = "Increment mode disabled"]
4488 pub const DISABLED: Self = Self(0);
4489 #[doc = "Increment mode enabled"]
4490 pub const ENABLED: Self = Self(0x01);
4491 }
4492 #[repr(transparent)]
4493 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4494 pub struct Dir(pub u8);
4495 impl Dir {
4496 #[doc = "Read from peripheral"]
4497 pub const FROMPERIPHERAL: Self = Self(0);
4498 #[doc = "Read from memory"]
4499 pub const FROMMEMORY: Self = Self(0x01);
4500 }
4501 #[repr(transparent)]
4502 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4503 pub struct Circ(pub u8);
4504 impl Circ {
4505 #[doc = "Circular buffer disabled"]
4506 pub const DISABLED: Self = Self(0);
4507 #[doc = "Circular buffer enabled"]
4508 pub const ENABLED: Self = Self(0x01);
4509 }
4510 #[repr(transparent)]
4511 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4512 pub struct Size(pub u8);
4513 impl Size {
4514 #[doc = "8-bit size"]
4515 pub const BITS8: Self = Self(0);
4516 #[doc = "16-bit size"]
4517 pub const BITS16: Self = Self(0x01);
4518 #[doc = "32-bit size"]
4519 pub const BITS32: Self = Self(0x02);
4520 }
4521 #[repr(transparent)]
4522 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4523 pub struct Pl(pub u8);
4524 impl Pl {
4525 #[doc = "Low priority"]
4526 pub const LOW: Self = Self(0);
4527 #[doc = "Medium priority"]
4528 pub const MEDIUM: Self = Self(0x01);
4529 #[doc = "High priority"]
4530 pub const HIGH: Self = Self(0x02);
4531 #[doc = "Very high priority"]
4532 pub const VERYHIGH: Self = Self(0x03);
4533 }
4534 }
4535 pub mod regs {
4536 use crate::generic::*;
4537 #[doc = "DMA channel configuration register (DMA_CCR)"]
4538 #[repr(transparent)]
4539 #[derive(Copy, Clone, Eq, PartialEq)]
4540 pub struct Cr(pub u32);
4541 impl Cr {
4542 #[doc = "Channel enable"]
4543 pub const fn en(&self) -> bool {
4544 let val = (self.0 >> 0usize) & 0x01;
4545 val != 0
4546 }
4547 #[doc = "Channel enable"]
4548 pub fn set_en(&mut self, val: bool) {
4549 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
4550 }
4551 #[doc = "Transfer complete interrupt enable"]
4552 pub const fn tcie(&self) -> bool {
4553 let val = (self.0 >> 1usize) & 0x01;
4554 val != 0
4555 }
4556 #[doc = "Transfer complete interrupt enable"]
4557 pub fn set_tcie(&mut self, val: bool) {
4558 self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
4559 }
4560 #[doc = "Half Transfer interrupt enable"]
4561 pub const fn htie(&self) -> bool {
4562 let val = (self.0 >> 2usize) & 0x01;
4563 val != 0
4564 }
4565 #[doc = "Half Transfer interrupt enable"]
4566 pub fn set_htie(&mut self, val: bool) {
4567 self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
4568 }
4569 #[doc = "Transfer error interrupt enable"]
4570 pub const fn teie(&self) -> bool {
4571 let val = (self.0 >> 3usize) & 0x01;
4572 val != 0
4573 }
4574 #[doc = "Transfer error interrupt enable"]
4575 pub fn set_teie(&mut self, val: bool) {
4576 self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
4577 }
4578 #[doc = "Data transfer direction"]
4579 pub const fn dir(&self) -> super::vals::Dir {
4580 let val = (self.0 >> 4usize) & 0x01;
4581 super::vals::Dir(val as u8)
4582 }
4583 #[doc = "Data transfer direction"]
4584 pub fn set_dir(&mut self, val: super::vals::Dir) {
4585 self.0 = (self.0 & !(0x01 << 4usize)) | (((val.0 as u32) & 0x01) << 4usize);
4586 }
4587 #[doc = "Circular mode"]
4588 pub const fn circ(&self) -> super::vals::Circ {
4589 let val = (self.0 >> 5usize) & 0x01;
4590 super::vals::Circ(val as u8)
4591 }
4592 #[doc = "Circular mode"]
4593 pub fn set_circ(&mut self, val: super::vals::Circ) {
4594 self.0 = (self.0 & !(0x01 << 5usize)) | (((val.0 as u32) & 0x01) << 5usize);
4595 }
4596 #[doc = "Peripheral increment mode"]
4597 pub const fn pinc(&self) -> super::vals::Inc {
4598 let val = (self.0 >> 6usize) & 0x01;
4599 super::vals::Inc(val as u8)
4600 }
4601 #[doc = "Peripheral increment mode"]
4602 pub fn set_pinc(&mut self, val: super::vals::Inc) {
4603 self.0 = (self.0 & !(0x01 << 6usize)) | (((val.0 as u32) & 0x01) << 6usize);
4604 }
4605 #[doc = "Memory increment mode"]
4606 pub const fn minc(&self) -> super::vals::Inc {
4607 let val = (self.0 >> 7usize) & 0x01;
4608 super::vals::Inc(val as u8)
4609 }
4610 #[doc = "Memory increment mode"]
4611 pub fn set_minc(&mut self, val: super::vals::Inc) {
4612 self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize);
4613 }
4614 #[doc = "Peripheral size"]
4615 pub const fn psize(&self) -> super::vals::Size {
4616 let val = (self.0 >> 8usize) & 0x03;
4617 super::vals::Size(val as u8)
4618 }
4619 #[doc = "Peripheral size"]
4620 pub fn set_psize(&mut self, val: super::vals::Size) {
4621 self.0 = (self.0 & !(0x03 << 8usize)) | (((val.0 as u32) & 0x03) << 8usize);
4622 }
4623 #[doc = "Memory size"]
4624 pub const fn msize(&self) -> super::vals::Size {
4625 let val = (self.0 >> 10usize) & 0x03;
4626 super::vals::Size(val as u8)
4627 }
4628 #[doc = "Memory size"]
4629 pub fn set_msize(&mut self, val: super::vals::Size) {
4630 self.0 = (self.0 & !(0x03 << 10usize)) | (((val.0 as u32) & 0x03) << 10usize);
4631 }
4632 #[doc = "Channel Priority level"]
4633 pub const fn pl(&self) -> super::vals::Pl {
4634 let val = (self.0 >> 12usize) & 0x03;
4635 super::vals::Pl(val as u8)
4636 }
4637 #[doc = "Channel Priority level"]
4638 pub fn set_pl(&mut self, val: super::vals::Pl) {
4639 self.0 = (self.0 & !(0x03 << 12usize)) | (((val.0 as u32) & 0x03) << 12usize);
4640 }
4641 #[doc = "Memory to memory mode"]
4642 pub const fn mem2mem(&self) -> super::vals::Memmem {
4643 let val = (self.0 >> 14usize) & 0x01;
4644 super::vals::Memmem(val as u8)
4645 }
4646 #[doc = "Memory to memory mode"]
4647 pub fn set_mem2mem(&mut self, val: super::vals::Memmem) {
4648 self.0 = (self.0 & !(0x01 << 14usize)) | (((val.0 as u32) & 0x01) << 14usize);
4649 }
4650 }
4651 impl Default for Cr {
4652 fn default() -> Cr {
4653 Cr(0)
4654 }
4655 }
4656 #[doc = "DMA interrupt flag clear register (DMA_IFCR)"]
4657 #[repr(transparent)]
4658 #[derive(Copy, Clone, Eq, PartialEq)]
4659 pub struct Ifcr(pub u32);
4660 impl Ifcr {
4661 #[doc = "Channel 1 Global interrupt clear"]
4662 pub fn cgif(&self, n: usize) -> bool {
4663 assert!(n < 7usize);
4664 let offs = 0usize + n * 4usize;
4665 let val = (self.0 >> offs) & 0x01;
4666 val != 0
4667 }
4668 #[doc = "Channel 1 Global interrupt clear"]
4669 pub fn set_cgif(&mut self, n: usize, val: bool) {
4670 assert!(n < 7usize);
4671 let offs = 0usize + n * 4usize;
4672 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
4673 }
4674 #[doc = "Channel 1 Transfer Complete clear"]
4675 pub fn ctcif(&self, n: usize) -> bool {
4676 assert!(n < 7usize);
4677 let offs = 1usize + n * 4usize;
4678 let val = (self.0 >> offs) & 0x01;
4679 val != 0
4680 }
4681 #[doc = "Channel 1 Transfer Complete clear"]
4682 pub fn set_ctcif(&mut self, n: usize, val: bool) {
4683 assert!(n < 7usize);
4684 let offs = 1usize + n * 4usize;
4685 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
4686 }
4687 #[doc = "Channel 1 Half Transfer clear"]
4688 pub fn chtif(&self, n: usize) -> bool {
4689 assert!(n < 7usize);
4690 let offs = 2usize + n * 4usize;
4691 let val = (self.0 >> offs) & 0x01;
4692 val != 0
4693 }
4694 #[doc = "Channel 1 Half Transfer clear"]
4695 pub fn set_chtif(&mut self, n: usize, val: bool) {
4696 assert!(n < 7usize);
4697 let offs = 2usize + n * 4usize;
4698 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
4699 }
4700 #[doc = "Channel 1 Transfer Error clear"]
4701 pub fn cteif(&self, n: usize) -> bool {
4702 assert!(n < 7usize);
4703 let offs = 3usize + n * 4usize;
4704 let val = (self.0 >> offs) & 0x01;
4705 val != 0
4706 }
4707 #[doc = "Channel 1 Transfer Error clear"]
4708 pub fn set_cteif(&mut self, n: usize, val: bool) {
4709 assert!(n < 7usize);
4710 let offs = 3usize + n * 4usize;
4711 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
4712 }
4713 }
4714 impl Default for Ifcr {
4715 fn default() -> Ifcr {
4716 Ifcr(0)
4717 }
4718 }
4719 #[doc = "DMA channel 1 number of data register"]
4720 #[repr(transparent)]
4721 #[derive(Copy, Clone, Eq, PartialEq)]
4722 pub struct Ndtr(pub u32);
4723 impl Ndtr {
4724 #[doc = "Number of data to transfer"]
4725 pub const fn ndt(&self) -> u16 {
4726 let val = (self.0 >> 0usize) & 0xffff;
4727 val as u16
4728 }
4729 #[doc = "Number of data to transfer"]
4730 pub fn set_ndt(&mut self, val: u16) {
4731 self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
4732 }
4733 }
4734 impl Default for Ndtr {
4735 fn default() -> Ndtr {
4736 Ndtr(0)
4737 }
4738 }
4739 #[doc = "DMA interrupt status register (DMA_ISR)"]
4740 #[repr(transparent)]
4741 #[derive(Copy, Clone, Eq, PartialEq)]
4742 pub struct Isr(pub u32);
4743 impl Isr {
4744 #[doc = "Channel 1 Global interrupt flag"]
4745 pub fn gif(&self, n: usize) -> bool {
4746 assert!(n < 7usize);
4747 let offs = 0usize + n * 4usize;
4748 let val = (self.0 >> offs) & 0x01;
4749 val != 0
4750 }
4751 #[doc = "Channel 1 Global interrupt flag"]
4752 pub fn set_gif(&mut self, n: usize, val: bool) {
4753 assert!(n < 7usize);
4754 let offs = 0usize + n * 4usize;
4755 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
4756 }
4757 #[doc = "Channel 1 Transfer Complete flag"]
4758 pub fn tcif(&self, n: usize) -> bool {
4759 assert!(n < 7usize);
4760 let offs = 1usize + n * 4usize;
4761 let val = (self.0 >> offs) & 0x01;
4762 val != 0
4763 }
4764 #[doc = "Channel 1 Transfer Complete flag"]
4765 pub fn set_tcif(&mut self, n: usize, val: bool) {
4766 assert!(n < 7usize);
4767 let offs = 1usize + n * 4usize;
4768 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
4769 }
4770 #[doc = "Channel 1 Half Transfer Complete flag"]
4771 pub fn htif(&self, n: usize) -> bool {
4772 assert!(n < 7usize);
4773 let offs = 2usize + n * 4usize;
4774 let val = (self.0 >> offs) & 0x01;
4775 val != 0
4776 }
4777 #[doc = "Channel 1 Half Transfer Complete flag"]
4778 pub fn set_htif(&mut self, n: usize, val: bool) {
4779 assert!(n < 7usize);
4780 let offs = 2usize + n * 4usize;
4781 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
4782 }
4783 #[doc = "Channel 1 Transfer Error flag"]
4784 pub fn teif(&self, n: usize) -> bool {
4785 assert!(n < 7usize);
4786 let offs = 3usize + n * 4usize;
4787 let val = (self.0 >> offs) & 0x01;
4788 val != 0
4789 }
4790 #[doc = "Channel 1 Transfer Error flag"]
4791 pub fn set_teif(&mut self, n: usize, val: bool) {
4792 assert!(n < 7usize);
4793 let offs = 3usize + n * 4usize;
4794 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
4795 }
4796 }
4797 impl Default for Isr {
4798 fn default() -> Isr {
4799 Isr(0)
4800 }
4801 }
4802 }
4803}
4804pub mod rng_v1 {
4805 use crate::generic::*;
4806 #[doc = "Random number generator"]
4807 #[derive(Copy, Clone)]
4808 pub struct Rng(pub *mut u8);
4809 unsafe impl Send for Rng {}
4810 unsafe impl Sync for Rng {}
4811 impl Rng {
4812 #[doc = "control register"]
4813 pub fn cr(self) -> Reg<regs::Cr, RW> {
4814 unsafe { Reg::from_ptr(self.0.add(0usize)) }
4815 }
4816 #[doc = "status register"]
4817 pub fn sr(self) -> Reg<regs::Sr, RW> {
4818 unsafe { Reg::from_ptr(self.0.add(4usize)) }
4819 }
4820 #[doc = "data register"]
4821 pub fn dr(self) -> Reg<u32, R> {
4822 unsafe { Reg::from_ptr(self.0.add(8usize)) }
4823 }
4824 }
4825 pub mod regs {
4826 use crate::generic::*;
4827 #[doc = "status register"]
4828 #[repr(transparent)]
4829 #[derive(Copy, Clone, Eq, PartialEq)]
4830 pub struct Sr(pub u32);
4831 impl Sr {
4832 #[doc = "Data ready"]
4833 pub const fn drdy(&self) -> bool {
4834 let val = (self.0 >> 0usize) & 0x01;
4835 val != 0
4836 }
4837 #[doc = "Data ready"]
4838 pub fn set_drdy(&mut self, val: bool) {
4839 self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
4840 }
4841 #[doc = "Clock error current status"]
4842 pub const fn cecs(&self) -> bool {
4843 let val = (self.0 >> 1usize) & 0x01;
4844 val != 0
4845 }
4846 #[doc = "Clock error current status"]
4847 pub fn set_cecs(&mut self, val: bool) {
4848 self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
4849 }
4850 #[doc = "Seed error current status"]
4851 pub const fn secs(&self) -> bool {
4852 let val = (self.0 >> 2usize) & 0x01;
4853 val != 0
4854 }
4855 #[doc = "Seed error current status"]
4856 pub fn set_secs(&mut self, val: bool) {
4857 self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
4858 }
4859 #[doc = "Clock error interrupt status"]
4860 pub const fn ceis(&self) -> bool {
4861 let val = (self.0 >> 5usize) & 0x01;
4862 val != 0
4863 }
4864 #[doc = "Clock error interrupt status"]
4865 pub fn set_ceis(&mut self, val: bool) {
4866 self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
4867 }
4868 #[doc = "Seed error interrupt status"]
4869 pub const fn seis(&self) -> bool {
4870 let val = (self.0 >> 6usize) & 0x01;
4871 val != 0
4872 }
4873 #[doc = "Seed error interrupt status"]
4874 pub fn set_seis(&mut self, val: bool) {
4875 self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
4876 }
4877 }
4878 impl Default for Sr {
4879 fn default() -> Sr {
4880 Sr(0)
4881 }
4882 } 4926 }
4883 #[doc = "control register"] 4927 #[doc = "low interrupt flag clear register"]
4884 #[repr(transparent)] 4928 pub fn ifcr(self, n: usize) -> Reg<regs::Ifcr, W> {
4885 #[derive(Copy, Clone, Eq, PartialEq)] 4929 assert!(n < 2usize);
4886 pub struct Cr(pub u32); 4930 unsafe { Reg::from_ptr(self.0.add(8usize + n * 4usize)) }
4887 impl Cr {
4888 #[doc = "Random number generator enable"]
4889 pub const fn rngen(&self) -> bool {
4890 let val = (self.0 >> 2usize) & 0x01;
4891 val != 0
4892 }
4893 #[doc = "Random number generator enable"]
4894 pub fn set_rngen(&mut self, val: bool) {
4895 self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
4896 }
4897 #[doc = "Interrupt enable"]
4898 pub const fn ie(&self) -> bool {
4899 let val = (self.0 >> 3usize) & 0x01;
4900 val != 0
4901 }
4902 #[doc = "Interrupt enable"]
4903 pub fn set_ie(&mut self, val: bool) {
4904 self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
4905 }
4906 } 4931 }
4907 impl Default for Cr { 4932 #[doc = "Stream cluster: S?CR, S?NDTR, S?M0AR, S?M1AR and S?FCR registers"]
4908 fn default() -> Cr { 4933 pub fn st(self, n: usize) -> St {
4909 Cr(0) 4934 assert!(n < 8usize);
4910 } 4935 unsafe { St(self.0.add(16usize + n * 24usize)) }
4911 } 4936 }
4912 } 4937 }
4913}
4914pub mod dma_v2 {
4915 use crate::generic::*;
4916 #[doc = "Stream cluster: S?CR, S?NDTR, S?M0AR, S?M1AR and S?FCR registers"] 4938 #[doc = "Stream cluster: S?CR, S?NDTR, S?M0AR, S?M1AR and S?FCR registers"]
4917 #[derive(Copy, Clone)] 4939 #[derive(Copy, Clone)]
4918 pub struct St(pub *mut u8); 4940 pub struct St(pub *mut u8);
@@ -4944,77 +4966,8 @@ pub mod dma_v2 {
4944 unsafe { Reg::from_ptr(self.0.add(20usize)) } 4966 unsafe { Reg::from_ptr(self.0.add(20usize)) }
4945 } 4967 }
4946 } 4968 }
4947 #[doc = "DMA controller"]
4948 #[derive(Copy, Clone)]
4949 pub struct Dma(pub *mut u8);
4950 unsafe impl Send for Dma {}
4951 unsafe impl Sync for Dma {}
4952 impl Dma {
4953 #[doc = "low interrupt status register"]
4954 pub fn isr(self, n: usize) -> Reg<regs::Isr, R> {
4955 assert!(n < 2usize);
4956 unsafe { Reg::from_ptr(self.0.add(0usize + n * 4usize)) }
4957 }
4958 #[doc = "low interrupt flag clear register"]
4959 pub fn ifcr(self, n: usize) -> Reg<regs::Ifcr, W> {
4960 assert!(n < 2usize);
4961 unsafe { Reg::from_ptr(self.0.add(8usize + n * 4usize)) }
4962 }
4963 #[doc = "Stream cluster: S?CR, S?NDTR, S?M0AR, S?M1AR and S?FCR registers"]
4964 pub fn st(self, n: usize) -> St {
4965 assert!(n < 8usize);
4966 unsafe { St(self.0.add(16usize + n * 24usize)) }
4967 }
4968 }
4969 pub mod regs { 4969 pub mod regs {
4970 use crate::generic::*; 4970 use crate::generic::*;
4971 #[doc = "stream x FIFO control register"]
4972 #[repr(transparent)]
4973 #[derive(Copy, Clone, Eq, PartialEq)]
4974 pub struct Fcr(pub u32);
4975 impl Fcr {
4976 #[doc = "FIFO threshold selection"]
4977 pub const fn fth(&self) -> super::vals::Fth {
4978 let val = (self.0 >> 0usize) & 0x03;
4979 super::vals::Fth(val as u8)
4980 }
4981 #[doc = "FIFO threshold selection"]
4982 pub fn set_fth(&mut self, val: super::vals::Fth) {
4983 self.0 = (self.0 & !(0x03 << 0usize)) | (((val.0 as u32) & 0x03) << 0usize);
4984 }
4985 #[doc = "Direct mode disable"]
4986 pub const fn dmdis(&self) -> super::vals::Dmdis {
4987 let val = (self.0 >> 2usize) & 0x01;
4988 super::vals::Dmdis(val as u8)
4989 }
4990 #[doc = "Direct mode disable"]
4991 pub fn set_dmdis(&mut self, val: super::vals::Dmdis) {
4992 self.0 = (self.0 & !(0x01 << 2usize)) | (((val.0 as u32) & 0x01) << 2usize);
4993 }
4994 #[doc = "FIFO status"]
4995 pub const fn fs(&self) -> super::vals::Fs {
4996 let val = (self.0 >> 3usize) & 0x07;
4997 super::vals::Fs(val as u8)
4998 }
4999 #[doc = "FIFO status"]
5000 pub fn set_fs(&mut self, val: super::vals::Fs) {
5001 self.0 = (self.0 & !(0x07 << 3usize)) | (((val.0 as u32) & 0x07) << 3usize);
5002 }
5003 #[doc = "FIFO error interrupt enable"]
5004 pub const fn feie(&self) -> bool {
5005 let val = (self.0 >> 7usize) & 0x01;
5006 val != 0
5007 }
5008 #[doc = "FIFO error interrupt enable"]
5009 pub fn set_feie(&mut self, val: bool) {
5010 self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
5011 }
5012 }
5013 impl Default for Fcr {
5014 fn default() -> Fcr {
5015 Fcr(0)
5016 }
5017 }
5018 #[doc = "low interrupt status register"] 4971 #[doc = "low interrupt status register"]
5019 #[repr(transparent)] 4972 #[repr(transparent)]
5020 #[derive(Copy, Clone, Eq, PartialEq)] 4973 #[derive(Copy, Clone, Eq, PartialEq)]
@@ -5091,24 +5044,80 @@ pub mod dma_v2 {
5091 Isr(0) 5044 Isr(0)
5092 } 5045 }
5093 } 5046 }
5094 #[doc = "stream x number of data register"] 5047 #[doc = "low interrupt flag clear register"]
5095 #[repr(transparent)] 5048 #[repr(transparent)]
5096 #[derive(Copy, Clone, Eq, PartialEq)] 5049 #[derive(Copy, Clone, Eq, PartialEq)]
5097 pub struct Ndtr(pub u32); 5050 pub struct Ifcr(pub u32);
5098 impl Ndtr { 5051 impl Ifcr {
5099 #[doc = "Number of data items to transfer"] 5052 #[doc = "Stream x clear FIFO error interrupt flag (x = 3..0)"]
5100 pub const fn ndt(&self) -> u16 { 5053 pub fn cfeif(&self, n: usize) -> bool {
5101 let val = (self.0 >> 0usize) & 0xffff; 5054 assert!(n < 4usize);
5102 val as u16 5055 let offs = 0usize + ([0usize, 6usize, 16usize, 22usize][n] as usize);
5056 let val = (self.0 >> offs) & 0x01;
5057 val != 0
5103 } 5058 }
5104 #[doc = "Number of data items to transfer"] 5059 #[doc = "Stream x clear FIFO error interrupt flag (x = 3..0)"]
5105 pub fn set_ndt(&mut self, val: u16) { 5060 pub fn set_cfeif(&mut self, n: usize, val: bool) {
5106 self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); 5061 assert!(n < 4usize);
5062 let offs = 0usize + ([0usize, 6usize, 16usize, 22usize][n] as usize);
5063 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
5064 }
5065 #[doc = "Stream x clear direct mode error interrupt flag (x = 3..0)"]
5066 pub fn cdmeif(&self, n: usize) -> bool {
5067 assert!(n < 4usize);
5068 let offs = 2usize + ([0usize, 6usize, 16usize, 22usize][n] as usize);
5069 let val = (self.0 >> offs) & 0x01;
5070 val != 0
5071 }
5072 #[doc = "Stream x clear direct mode error interrupt flag (x = 3..0)"]
5073 pub fn set_cdmeif(&mut self, n: usize, val: bool) {
5074 assert!(n < 4usize);
5075 let offs = 2usize + ([0usize, 6usize, 16usize, 22usize][n] as usize);
5076 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
5077 }
5078 #[doc = "Stream x clear transfer error interrupt flag (x = 3..0)"]
5079 pub fn cteif(&self, n: usize) -> bool {
5080 assert!(n < 4usize);
5081 let offs = 3usize + ([0usize, 6usize, 16usize, 22usize][n] as usize);
5082 let val = (self.0 >> offs) & 0x01;
5083 val != 0
5084 }
5085 #[doc = "Stream x clear transfer error interrupt flag (x = 3..0)"]
5086 pub fn set_cteif(&mut self, n: usize, val: bool) {
5087 assert!(n < 4usize);
5088 let offs = 3usize + ([0usize, 6usize, 16usize, 22usize][n] as usize);
5089 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
5090 }
5091 #[doc = "Stream x clear half transfer interrupt flag (x = 3..0)"]
5092 pub fn chtif(&self, n: usize) -> bool {
5093 assert!(n < 4usize);
5094 let offs = 4usize + ([0usize, 6usize, 16usize, 22usize][n] as usize);
5095 let val = (self.0 >> offs) & 0x01;
5096 val != 0
5097 }
5098 #[doc = "Stream x clear half transfer interrupt flag (x = 3..0)"]
5099 pub fn set_chtif(&mut self, n: usize, val: bool) {
5100 assert!(n < 4usize);
5101 let offs = 4usize + ([0usize, 6usize, 16usize, 22usize][n] as usize);
5102 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
5103 }
5104 #[doc = "Stream x clear transfer complete interrupt flag (x = 3..0)"]
5105 pub fn ctcif(&self, n: usize) -> bool {
5106 assert!(n < 4usize);
5107 let offs = 5usize + ([0usize, 6usize, 16usize, 22usize][n] as usize);
5108 let val = (self.0 >> offs) & 0x01;
5109 val != 0
5110 }
5111 #[doc = "Stream x clear transfer complete interrupt flag (x = 3..0)"]
5112 pub fn set_ctcif(&mut self, n: usize, val: bool) {
5113 assert!(n < 4usize);
5114 let offs = 5usize + ([0usize, 6usize, 16usize, 22usize][n] as usize);
5115 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
5107 } 5116 }
5108 } 5117 }
5109 impl Default for Ndtr { 5118 impl Default for Ifcr {
5110 fn default() -> Ndtr { 5119 fn default() -> Ifcr {
5111 Ndtr(0) 5120 Ifcr(0)
5112 } 5121 }
5113 } 5122 }
5114 #[doc = "stream x configuration register"] 5123 #[doc = "stream x configuration register"]
@@ -5293,80 +5302,71 @@ pub mod dma_v2 {
5293 Cr(0) 5302 Cr(0)
5294 } 5303 }
5295 } 5304 }
5296 #[doc = "low interrupt flag clear register"] 5305 #[doc = "stream x number of data register"]
5297 #[repr(transparent)] 5306 #[repr(transparent)]
5298 #[derive(Copy, Clone, Eq, PartialEq)] 5307 #[derive(Copy, Clone, Eq, PartialEq)]
5299 pub struct Ifcr(pub u32); 5308 pub struct Ndtr(pub u32);
5300 impl Ifcr { 5309 impl Ndtr {
5301 #[doc = "Stream x clear FIFO error interrupt flag (x = 3..0)"] 5310 #[doc = "Number of data items to transfer"]
5302 pub fn cfeif(&self, n: usize) -> bool { 5311 pub const fn ndt(&self) -> u16 {
5303 assert!(n < 4usize); 5312 let val = (self.0 >> 0usize) & 0xffff;
5304 let offs = 0usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); 5313 val as u16
5305 let val = (self.0 >> offs) & 0x01;
5306 val != 0
5307 } 5314 }
5308 #[doc = "Stream x clear FIFO error interrupt flag (x = 3..0)"] 5315 #[doc = "Number of data items to transfer"]
5309 pub fn set_cfeif(&mut self, n: usize, val: bool) { 5316 pub fn set_ndt(&mut self, val: u16) {
5310 assert!(n < 4usize); 5317 self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
5311 let offs = 0usize + ([0usize, 6usize, 16usize, 22usize][n] as usize);
5312 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
5313 } 5318 }
5314 #[doc = "Stream x clear direct mode error interrupt flag (x = 3..0)"] 5319 }
5315 pub fn cdmeif(&self, n: usize) -> bool { 5320 impl Default for Ndtr {
5316 assert!(n < 4usize); 5321 fn default() -> Ndtr {
5317 let offs = 2usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); 5322 Ndtr(0)
5318 let val = (self.0 >> offs) & 0x01;
5319 val != 0
5320 } 5323 }
5321 #[doc = "Stream x clear direct mode error interrupt flag (x = 3..0)"] 5324 }
5322 pub fn set_cdmeif(&mut self, n: usize, val: bool) { 5325 #[doc = "stream x FIFO control register"]
5323 assert!(n < 4usize); 5326 #[repr(transparent)]
5324 let offs = 2usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); 5327 #[derive(Copy, Clone, Eq, PartialEq)]
5325 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); 5328 pub struct Fcr(pub u32);
5329 impl Fcr {
5330 #[doc = "FIFO threshold selection"]
5331 pub const fn fth(&self) -> super::vals::Fth {
5332 let val = (self.0 >> 0usize) & 0x03;
5333 super::vals::Fth(val as u8)
5326 } 5334 }
5327 #[doc = "Stream x clear transfer error interrupt flag (x = 3..0)"] 5335 #[doc = "FIFO threshold selection"]
5328 pub fn cteif(&self, n: usize) -> bool { 5336 pub fn set_fth(&mut self, val: super::vals::Fth) {
5329 assert!(n < 4usize); 5337 self.0 = (self.0 & !(0x03 << 0usize)) | (((val.0 as u32) & 0x03) << 0usize);
5330 let offs = 3usize + ([0usize, 6usize, 16usize, 22usize][n] as usize);
5331 let val = (self.0 >> offs) & 0x01;
5332 val != 0
5333 } 5338 }
5334 #[doc = "Stream x clear transfer error interrupt flag (x = 3..0)"] 5339 #[doc = "Direct mode disable"]
5335 pub fn set_cteif(&mut self, n: usize, val: bool) { 5340 pub const fn dmdis(&self) -> super::vals::Dmdis {
5336 assert!(n < 4usize); 5341 let val = (self.0 >> 2usize) & 0x01;
5337 let offs = 3usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); 5342 super::vals::Dmdis(val as u8)
5338 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
5339 } 5343 }
5340 #[doc = "Stream x clear half transfer interrupt flag (x = 3..0)"] 5344 #[doc = "Direct mode disable"]
5341 pub fn chtif(&self, n: usize) -> bool { 5345 pub fn set_dmdis(&mut self, val: super::vals::Dmdis) {
5342 assert!(n < 4usize); 5346 self.0 = (self.0 & !(0x01 << 2usize)) | (((val.0 as u32) & 0x01) << 2usize);
5343 let offs = 4usize + ([0usize, 6usize, 16usize, 22usize][n] as usize);
5344 let val = (self.0 >> offs) & 0x01;
5345 val != 0
5346 } 5347 }
5347 #[doc = "Stream x clear half transfer interrupt flag (x = 3..0)"] 5348 #[doc = "FIFO status"]
5348 pub fn set_chtif(&mut self, n: usize, val: bool) { 5349 pub const fn fs(&self) -> super::vals::Fs {
5349 assert!(n < 4usize); 5350 let val = (self.0 >> 3usize) & 0x07;
5350 let offs = 4usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); 5351 super::vals::Fs(val as u8)
5351 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
5352 } 5352 }
5353 #[doc = "Stream x clear transfer complete interrupt flag (x = 3..0)"] 5353 #[doc = "FIFO status"]
5354 pub fn ctcif(&self, n: usize) -> bool { 5354 pub fn set_fs(&mut self, val: super::vals::Fs) {
5355 assert!(n < 4usize); 5355 self.0 = (self.0 & !(0x07 << 3usize)) | (((val.0 as u32) & 0x07) << 3usize);
5356 let offs = 5usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); 5356 }
5357 let val = (self.0 >> offs) & 0x01; 5357 #[doc = "FIFO error interrupt enable"]
5358 pub const fn feie(&self) -> bool {
5359 let val = (self.0 >> 7usize) & 0x01;
5358 val != 0 5360 val != 0
5359 } 5361 }
5360 #[doc = "Stream x clear transfer complete interrupt flag (x = 3..0)"] 5362 #[doc = "FIFO error interrupt enable"]
5361 pub fn set_ctcif(&mut self, n: usize, val: bool) { 5363 pub fn set_feie(&mut self, val: bool) {
5362 assert!(n < 4usize); 5364 self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
5363 let offs = 5usize + ([0usize, 6usize, 16usize, 22usize][n] as usize);
5364 self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
5365 } 5365 }
5366 } 5366 }
5367 impl Default for Ifcr { 5367 impl Default for Fcr {
5368 fn default() -> Ifcr { 5368 fn default() -> Fcr {
5369 Ifcr(0) 5369 Fcr(0)
5370 } 5370 }
5371 } 5371 }
5372 } 5372 }
@@ -5374,6 +5374,15 @@ pub mod dma_v2 {
5374 use crate::generic::*; 5374 use crate::generic::*;
5375 #[repr(transparent)] 5375 #[repr(transparent)]
5376 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 5376 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5377 pub struct Inc(pub u8);
5378 impl Inc {
5379 #[doc = "Address pointer is fixed"]
5380 pub const FIXED: Self = Self(0);
5381 #[doc = "Address pointer is incremented after each data transfer"]
5382 pub const INCREMENTED: Self = Self(0x01);
5383 }
5384 #[repr(transparent)]
5385 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5377 pub struct Pfctrl(pub u8); 5386 pub struct Pfctrl(pub u8);
5378 impl Pfctrl { 5387 impl Pfctrl {
5379 #[doc = "The DMA is the flow controller"] 5388 #[doc = "The DMA is the flow controller"]
@@ -5383,23 +5392,29 @@ pub mod dma_v2 {
5383 } 5392 }
5384 #[repr(transparent)] 5393 #[repr(transparent)]
5385 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 5394 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5386 pub struct Size(pub u8); 5395 pub struct Pl(pub u8);
5387 impl Size { 5396 impl Pl {
5388 #[doc = "Byte (8-bit)"] 5397 #[doc = "Low"]
5389 pub const BITS8: Self = Self(0); 5398 pub const LOW: Self = Self(0);
5390 #[doc = "Half-word (16-bit)"] 5399 #[doc = "Medium"]
5391 pub const BITS16: Self = Self(0x01); 5400 pub const MEDIUM: Self = Self(0x01);
5392 #[doc = "Word (32-bit)"] 5401 #[doc = "High"]
5393 pub const BITS32: Self = Self(0x02); 5402 pub const HIGH: Self = Self(0x02);
5403 #[doc = "Very high"]
5404 pub const VERYHIGH: Self = Self(0x03);
5394 } 5405 }
5395 #[repr(transparent)] 5406 #[repr(transparent)]
5396 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 5407 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5397 pub struct Dbm(pub u8); 5408 pub struct Fth(pub u8);
5398 impl Dbm { 5409 impl Fth {
5399 #[doc = "No buffer switching at the end of transfer"] 5410 #[doc = "1/4 full FIFO"]
5400 pub const DISABLED: Self = Self(0); 5411 pub const QUARTER: Self = Self(0);
5401 #[doc = "Memory target switched at the end of the DMA transfer"] 5412 #[doc = "1/2 full FIFO"]
5402 pub const ENABLED: Self = Self(0x01); 5413 pub const HALF: Self = Self(0x01);
5414 #[doc = "3/4 full FIFO"]
5415 pub const THREEQUARTERS: Self = Self(0x02);
5416 #[doc = "Full FIFO"]
5417 pub const FULL: Self = Self(0x03);
5403 } 5418 }
5404 #[repr(transparent)] 5419 #[repr(transparent)]
5405 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 5420 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
@@ -5414,37 +5429,6 @@ pub mod dma_v2 {
5414 } 5429 }
5415 #[repr(transparent)] 5430 #[repr(transparent)]
5416 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 5431 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5417 pub struct Pincos(pub u8);
5418 impl Pincos {
5419 #[doc = "The offset size for the peripheral address calculation is linked to the PSIZE"]
5420 pub const PSIZE: Self = Self(0);
5421 #[doc = "The offset size for the peripheral address calculation is fixed to 4 (32-bit alignment)"]
5422 pub const FIXED4: Self = Self(0x01);
5423 }
5424 #[repr(transparent)]
5425 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5426 pub struct Burst(pub u8);
5427 impl Burst {
5428 #[doc = "Single transfer"]
5429 pub const SINGLE: Self = Self(0);
5430 #[doc = "Incremental burst of 4 beats"]
5431 pub const INCR4: Self = Self(0x01);
5432 #[doc = "Incremental burst of 8 beats"]
5433 pub const INCR8: Self = Self(0x02);
5434 #[doc = "Incremental burst of 16 beats"]
5435 pub const INCR16: Self = Self(0x03);
5436 }
5437 #[repr(transparent)]
5438 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5439 pub struct Ct(pub u8);
5440 impl Ct {
5441 #[doc = "The current target memory is Memory 0"]
5442 pub const MEMORY0: Self = Self(0);
5443 #[doc = "The current target memory is Memory 1"]
5444 pub const MEMORY1: Self = Self(0x01);
5445 }
5446 #[repr(transparent)]
5447 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5448 pub struct Fs(pub u8); 5432 pub struct Fs(pub u8);
5449 impl Fs { 5433 impl Fs {
5450 #[doc = "0 < fifo_level < 1/4"] 5434 #[doc = "0 < fifo_level < 1/4"]
@@ -5462,38 +5446,23 @@ pub mod dma_v2 {
5462 } 5446 }
5463 #[repr(transparent)] 5447 #[repr(transparent)]
5464 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 5448 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5465 pub struct Fth(pub u8); 5449 pub struct Size(pub u8);
5466 impl Fth { 5450 impl Size {
5467 #[doc = "1/4 full FIFO"] 5451 #[doc = "Byte (8-bit)"]
5468 pub const QUARTER: Self = Self(0); 5452 pub const BITS8: Self = Self(0);
5469 #[doc = "1/2 full FIFO"] 5453 #[doc = "Half-word (16-bit)"]
5470 pub const HALF: Self = Self(0x01); 5454 pub const BITS16: Self = Self(0x01);
5471 #[doc = "3/4 full FIFO"] 5455 #[doc = "Word (32-bit)"]
5472 pub const THREEQUARTERS: Self = Self(0x02); 5456 pub const BITS32: Self = Self(0x02);
5473 #[doc = "Full FIFO"]
5474 pub const FULL: Self = Self(0x03);
5475 }
5476 #[repr(transparent)]
5477 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5478 pub struct Inc(pub u8);
5479 impl Inc {
5480 #[doc = "Address pointer is fixed"]
5481 pub const FIXED: Self = Self(0);
5482 #[doc = "Address pointer is incremented after each data transfer"]
5483 pub const INCREMENTED: Self = Self(0x01);
5484 } 5457 }
5485 #[repr(transparent)] 5458 #[repr(transparent)]
5486 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 5459 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5487 pub struct Pl(pub u8); 5460 pub struct Pincos(pub u8);
5488 impl Pl { 5461 impl Pincos {
5489 #[doc = "Low"] 5462 #[doc = "The offset size for the peripheral address calculation is linked to the PSIZE"]
5490 pub const LOW: Self = Self(0); 5463 pub const PSIZE: Self = Self(0);
5491 #[doc = "Medium"] 5464 #[doc = "The offset size for the peripheral address calculation is fixed to 4 (32-bit alignment)"]
5492 pub const MEDIUM: Self = Self(0x01); 5465 pub const FIXED4: Self = Self(0x01);
5493 #[doc = "High"]
5494 pub const HIGH: Self = Self(0x02);
5495 #[doc = "Very high"]
5496 pub const VERYHIGH: Self = Self(0x03);
5497 } 5466 }
5498 #[repr(transparent)] 5467 #[repr(transparent)]
5499 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 5468 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
@@ -5506,6 +5475,15 @@ pub mod dma_v2 {
5506 } 5475 }
5507 #[repr(transparent)] 5476 #[repr(transparent)]
5508 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 5477 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5478 pub struct Dbm(pub u8);
5479 impl Dbm {
5480 #[doc = "No buffer switching at the end of transfer"]
5481 pub const DISABLED: Self = Self(0);
5482 #[doc = "Memory target switched at the end of the DMA transfer"]
5483 pub const ENABLED: Self = Self(0x01);
5484 }
5485 #[repr(transparent)]
5486 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5509 pub struct Dmdis(pub u8); 5487 pub struct Dmdis(pub u8);
5510 impl Dmdis { 5488 impl Dmdis {
5511 #[doc = "Direct mode is enabled"] 5489 #[doc = "Direct mode is enabled"]
@@ -5513,5 +5491,27 @@ pub mod dma_v2 {
5513 #[doc = "Direct mode is disabled"] 5491 #[doc = "Direct mode is disabled"]
5514 pub const DISABLED: Self = Self(0x01); 5492 pub const DISABLED: Self = Self(0x01);
5515 } 5493 }
5494 #[repr(transparent)]
5495 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5496 pub struct Burst(pub u8);
5497 impl Burst {
5498 #[doc = "Single transfer"]
5499 pub const SINGLE: Self = Self(0);
5500 #[doc = "Incremental burst of 4 beats"]
5501 pub const INCR4: Self = Self(0x01);
5502 #[doc = "Incremental burst of 8 beats"]
5503 pub const INCR8: Self = Self(0x02);
5504 #[doc = "Incremental burst of 16 beats"]
5505 pub const INCR16: Self = Self(0x03);
5506 }
5507 #[repr(transparent)]
5508 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
5509 pub struct Ct(pub u8);
5510 impl Ct {
5511 #[doc = "The current target memory is Memory 0"]
5512 pub const MEMORY0: Self = Self(0);
5513 #[doc = "The current target memory is Memory 1"]
5514 pub const MEMORY1: Self = Self(0x01);
5515 }
5516 } 5516 }
5517} 5517}
diff --git a/embassy-stm32/src/rng.rs b/embassy-stm32/src/rng.rs
index d1419dfd7..79a0a1eb5 100644
--- a/embassy-stm32/src/rng.rs
+++ b/embassy-stm32/src/rng.rs
@@ -1,31 +1,149 @@
1#![macro_use] 1#![macro_use]
2use crate::pac::rng::{regs, Rng}; 2
3//use crate::pac::rng::{regs, Rng};
4use crate::pac;
3use crate::peripherals; 5use crate::peripherals;
4use embassy::util::Unborrow; 6use crate::interrupt;
7use embassy::util::{Unborrow, AtomicWaker};
5use embassy_extras::unborrow; 8use embassy_extras::unborrow;
9use rand_core::{RngCore, CryptoRng};
10
11use defmt::*;
12
13static RNG_WAKER: AtomicWaker = AtomicWaker::new();
14
15#[interrupt]
16unsafe fn RNG() {
17 let bits = crate::pac::RNG.sr().read();
18 if bits.drdy() || bits.seis() || bits.ceis() {
19 crate::pac::RNG.cr().write(|reg| reg.set_ie(false));
20 RNG_WAKER.wake();
21 }
22}
6 23
7pub struct Random<T: Instance> { 24pub struct Random<T: Instance> {
8 inner: T, 25 inner: T,
9} 26}
10 27
11impl<T: Instance> Random<T> { 28impl<T: Instance> Random<T> {
12 pub fn new(inner: impl Unborrow<Target = T>) -> Self { 29 pub fn new(inner: impl Unborrow<Target=T>) -> Self {
13 unborrow!(inner); 30 unborrow!(inner);
14 Self { inner } 31 Self { inner }
15 } 32 }
16} 33}
17 34
35impl<T: Instance> RngCore for Random<T> {
36 fn next_u32(&mut self) -> u32 {
37 loop {
38 let bits = unsafe { T::regs().sr().read() };
39 if bits.drdy() {
40 return unsafe{ T::regs().dr().read() }
41 }
42 }
43 }
44
45 fn next_u64(&mut self) -> u64 {
46 let mut rand = self.next_u32() as u64;
47 rand |= (self.next_u32() as u64) << 32;
48 rand
49 }
50
51 fn fill_bytes(&mut self, dest: &mut [u8]) {
52 for chunk in dest.chunks_mut(4) {
53 let rand = self.next_u32();
54 for (slot, num) in chunk.iter_mut().zip(rand.to_be_bytes().iter()) {
55 *slot = *num
56 }
57 }
58 }
59
60 fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
61 self.fill_bytes( dest );
62 Ok(())
63 }
64}
65
66impl<T: Instance> CryptoRng for Random<T> { }
67
18use core::future::Future; 68use core::future::Future;
19use core::marker::PhantomData; 69use core::marker::PhantomData;
20use embassy::traits::rng::Rng as RngTrait; 70use embassy::traits;
71use core::task::{Poll, Context};
72use core::pin::Pin;
73
74struct RngInterruptFuture<T: Instance> {
75 _marker: PhantomData<T>,
76}
21 77
22impl<T: Instance> RngTrait for Random<T> { 78impl<T: Instance> Future for RngInterruptFuture<T> {
23 type Error = (); 79 type Output = Result<(), Error>;
24 #[rustfmt::skip]
25 type RngFuture<'a> where Self: 'a = impl Future<Output = Result<(), Self::Error>>;
26 80
27 fn fill<'a>(&'a mut self, dest: &'a mut [u8]) -> Self::RngFuture<'a> { 81 fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
28 async move { Ok(()) } 82 RNG_WAKER.register(cx.waker());
83
84 let bits = unsafe { T::regs().sr().read() };
85
86 if bits.drdy() {
87 return Poll::Ready(Ok(()));
88 } else if bits.seis() {
89 unsafe {
90 T::regs().sr().modify(|reg| {
91 reg.set_seis(false);
92 });
93 }
94 } else if bits.ceis() {
95 unsafe {
96 T::regs().sr().modify(|reg| {
97 reg.set_ceis(false);
98 });
99 }
100 }
101
102 Poll::Pending
103 }
104}
105
106impl<T: Instance> RngInterruptFuture<T> {
107 async fn new() -> Result<(), Error> {
108 unsafe {
109 T::regs().cr().modify(|reg| {
110 reg.set_ie(true);
111 //reg.set_rngen(true);
112 });
113 }
114
115 Self {
116 _marker: PhantomData
117 }.await
118 }
119}
120
121pub enum Error {
122 SeedError,
123 ClockError,
124}
125
126impl<T: Instance> traits::rng::Rng for Random<T> {
127 type Error = Error;
128 type RngFuture<'a> where Self: 'a = impl Future<Output=Result<(), Self::Error>>;
129
130 fn fill_bytes<'a>(&'a mut self, dest: &'a mut [u8]) -> Self::RngFuture<'a> {
131 unsafe {
132 T::regs().cr().modify(|reg| {
133 reg.set_rngen(true);
134 });
135 }
136
137 async move {
138 for chunk in dest.chunks_mut(4) {
139 RngInterruptFuture::<T>::new().await?;
140 let random_bytes = unsafe { T::regs().dr().read() }.to_be_bytes();
141 for (dest, src) in chunk.iter_mut().zip(random_bytes.iter()) {
142 *dest = *src
143 }
144 }
145 Ok(())
146 }
29 } 147 }
30} 148}
31 149
@@ -33,20 +151,20 @@ pub(crate) mod sealed {
33 use super::*; 151 use super::*;
34 152
35 pub trait Instance { 153 pub trait Instance {
36 fn regs(&self) -> Rng; 154 fn regs() -> pac::rng::Rng;
37 } 155 }
38} 156}
39 157
40pub trait Instance: sealed::Instance {} 158pub trait Instance: sealed::Instance {}
41 159
42macro_rules! impl_rng { 160macro_rules! impl_rng {
43 ($inst:ident) => { 161 ($addr:ident) => {
44 impl crate::rng::sealed::Instance for peripherals::$inst { 162 impl crate::rng::sealed::Instance for peripherals::RNG {
45 fn regs(&self) -> crate::pac::rng::Rng { 163 fn regs() -> crate::pac::chip::rng::Rng {
46 crate::pac::$inst 164 crate::pac::RNG
47 } 165 }
48 } 166 }
49 167
50 impl crate::rng::Instance for peripherals::$inst {} 168 impl crate::rng::Instance for peripherals::RNG {}
51 }; 169 };
52} 170}
diff --git a/embassy-traits/src/rng.rs b/embassy-traits/src/rng.rs
index af786bd4a..ddc4c20e0 100644
--- a/embassy-traits/src/rng.rs
+++ b/embassy-traits/src/rng.rs
@@ -13,5 +13,5 @@ pub trait Rng {
13 /// May result in delays if entropy is exhausted prior to completely 13 /// May result in delays if entropy is exhausted prior to completely
14 /// filling the buffer. Upon completion, the buffer will be completely 14 /// filling the buffer. Upon completion, the buffer will be completely
15 /// filled or an error will have been reported. 15 /// filled or an error will have been reported.
16 fn fill<'a>(&'a mut self, dest: &'a mut [u8]) -> Self::RngFuture<'a>; 16 fn fill_bytes<'a>(&'a mut self, dest: &'a mut [u8]) -> Self::RngFuture<'a>;
17} 17}