aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-08-19 23:51:53 +0200
committerDario Nieuwenhuis <[email protected]>2021-08-19 23:59:50 +0200
commit174c51f09707b8a475382071f99e0d9c44f93ab7 (patch)
treea6d41534e2df77a251b9188383c299be8879b7c5
parent2c992f701049a9c0e72048b134c26fdb26f2692a (diff)
stm32/metapac: check GPIO RCC regs are always found.
-rw-r--r--embassy-stm32/src/rcc/f0/mod.rs12
-rw-r--r--embassy-stm32/src/rcc/l0/mod.rs10
m---------stm32-data0
-rw-r--r--stm32-metapac-gen/src/lib.rs18
4 files changed, 9 insertions, 31 deletions
diff --git a/embassy-stm32/src/rcc/f0/mod.rs b/embassy-stm32/src/rcc/f0/mod.rs
index ec6474e86..916ed39fc 100644
--- a/embassy-stm32/src/rcc/f0/mod.rs
+++ b/embassy-stm32/src/rcc/f0/mod.rs
@@ -202,18 +202,6 @@ impl<'d> Rcc<'d> {
202} 202}
203 203
204pub unsafe fn init(config: Config) { 204pub unsafe fn init(config: Config) {
205 RCC.ahbenr().modify(|w| {
206 w.set_iopaen(true);
207 w.set_iopben(true);
208 w.set_iopcen(true);
209 w.set_iopden(true);
210
211 #[cfg(rcc_f0)]
212 w.set_iopeen(true);
213
214 w.set_iopfen(true);
215 });
216
217 let rcc = Rcc::new(<peripherals::RCC as embassy::util::Steal>::steal(), config); 205 let rcc = Rcc::new(<peripherals::RCC as embassy::util::Steal>::steal(), config);
218 let clocks = rcc.freeze(); 206 let clocks = rcc.freeze();
219 set_freqs(clocks); 207 set_freqs(clocks);
diff --git a/embassy-stm32/src/rcc/l0/mod.rs b/embassy-stm32/src/rcc/l0/mod.rs
index 1c3b314b6..e65faaa2c 100644
--- a/embassy-stm32/src/rcc/l0/mod.rs
+++ b/embassy-stm32/src/rcc/l0/mod.rs
@@ -377,16 +377,6 @@ impl RccExt for RCC {
377pub struct HSI48(()); 377pub struct HSI48(());
378 378
379pub unsafe fn init(config: Config) { 379pub unsafe fn init(config: Config) {
380 let rcc = pac::RCC;
381 rcc.iopenr().write(|w| {
382 w.set_iopaen(true);
383 w.set_iopben(true);
384 w.set_iopcen(true);
385 w.set_iopden(true);
386 w.set_iopeen(true);
387 w.set_iophen(true);
388 });
389
390 let r = <peripherals::RCC as embassy::util::Steal>::steal(); 380 let r = <peripherals::RCC as embassy::util::Steal>::steal();
391 let clocks = r.freeze(config); 381 let clocks = r.freeze(config);
392 set_freqs(clocks); 382 set_freqs(clocks);
diff --git a/stm32-data b/stm32-data
Subproject d3c03a41de925d07e26a5f6157eb85307692a65 Subproject 12be5f3da4ba38850d94ab865d2b920bd936300
diff --git a/stm32-metapac-gen/src/lib.rs b/stm32-metapac-gen/src/lib.rs
index 2f940544b..8646accfa 100644
--- a/stm32-metapac-gen/src/lib.rs
+++ b/stm32-metapac-gen/src/lib.rs
@@ -117,11 +117,7 @@ impl BlockInfo {
117 } 117 }
118} 118}
119 119
120fn find_reg_for_field<'c>( 120fn find_reg<'c>(rcc: &'c ir::IR, reg_regex: &str, field_name: &str) -> Option<(&'c str, &'c str)> {
121 rcc: &'c ir::IR,
122 reg_regex: &str,
123 field_name: &str,
124) -> Option<(&'c str, &'c str)> {
125 let reg_regex = Regex::new(reg_regex).unwrap(); 121 let reg_regex = Regex::new(reg_regex).unwrap();
126 122
127 for (name, fieldset) in &rcc.fieldsets { 123 for (name, fieldset) in &rcc.fieldsets {
@@ -426,16 +422,16 @@ pub fn gen(options: Options) {
426 422
427 // Workaround for clock registers being split on some chip families. Assume fields are 423 // Workaround for clock registers being split on some chip families. Assume fields are
428 // named after peripheral and look for first field matching and use that register. 424 // named after peripheral and look for first field matching and use that register.
429 let mut en = find_reg_for_field(&rcc, "^.+ENR\\d*$", &format!("{}EN", name)); 425 let mut en = find_reg(&rcc, "^.+ENR\\d*$", &format!("{}EN", name));
430 let mut rst = find_reg_for_field(&rcc, "^.+RSTR\\d*$", &format!("{}RST", name)); 426 let mut rst = find_reg(&rcc, "^.+RSTR\\d*$", &format!("{}RST", name));
431 427
432 if en.is_none() && name.ends_with("1") { 428 if en.is_none() && name.ends_with("1") {
433 en = find_reg_for_field( 429 en = find_reg(
434 &rcc, 430 &rcc,
435 "^.+ENR\\d*$", 431 "^.+ENR\\d*$",
436 &format!("{}EN", &name[..name.len() - 1]), 432 &format!("{}EN", &name[..name.len() - 1]),
437 ); 433 );
438 rst = find_reg_for_field( 434 rst = find_reg(
439 &rcc, 435 &rcc,
440 "^.+RSTR\\d*$", 436 "^.+RSTR\\d*$",
441 &format!("{}RST", &name[..name.len() - 1]), 437 &format!("{}RST", &name[..name.len() - 1]),
@@ -500,6 +496,10 @@ pub fn gen(options: Options) {
500 gpio_rcc_table.push(vec![reg]); 496 gpio_rcc_table.push(vec![reg]);
501 } 497 }
502 498
499 // We should always find GPIO RCC regs. If not, it means something
500 // is broken and GPIO won't work because it's not enabled.
501 assert!(!gpio_rcc_table.is_empty());
502
503 for (id, channel_info) in &core.dma_channels { 503 for (id, channel_info) in &core.dma_channels {
504 let mut row = Vec::new(); 504 let mut row = Vec::new();
505 let dma_peri = core.peripherals.get(&channel_info.dma).unwrap(); 505 let dma_peri = core.peripherals.get(&channel_info.dma).unwrap();