aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-02-26 03:28:27 +0100
committerDario Nieuwenhuis <[email protected]>2024-03-01 23:54:37 +0100
commit95234cddbac6f21fce0f5df510d49816f343b87d (patch)
treea9daf8a1bb9449191a7174269bc348f3ce61bfef /tests
parentd5c9c611fa317e066d6cf7c5af0513b40bd69d8c (diff)
stm32: autogenerate mux config for all chips.
Diffstat (limited to 'tests')
-rw-r--r--tests/stm32/src/bin/fdcan.rs4
-rw-r--r--tests/stm32/src/common.rs47
2 files changed, 25 insertions, 26 deletions
diff --git a/tests/stm32/src/bin/fdcan.rs b/tests/stm32/src/bin/fdcan.rs
index f21aa797c..dd78d7fb3 100644
--- a/tests/stm32/src/bin/fdcan.rs
+++ b/tests/stm32/src/bin/fdcan.rs
@@ -33,7 +33,7 @@ fn options() -> TestOptions {
33 freq: embassy_stm32::time::Hertz(25_000_000), 33 freq: embassy_stm32::time::Hertz(25_000_000),
34 mode: rcc::HseMode::Oscillator, 34 mode: rcc::HseMode::Oscillator,
35 }); 35 });
36 c.rcc.fdcan_clock_source = rcc::FdCanClockSource::HSE; 36 c.rcc.mux.fdcansel = rcc::mux::Fdcansel::HSE;
37 TestOptions { 37 TestOptions {
38 config: c, 38 config: c,
39 max_latency: Duration::from_micros(1200), 39 max_latency: Duration::from_micros(1200),
@@ -50,7 +50,7 @@ fn options() -> TestOptions {
50 freq: embassy_stm32::time::Hertz(25_000_000), 50 freq: embassy_stm32::time::Hertz(25_000_000),
51 mode: rcc::HseMode::Oscillator, 51 mode: rcc::HseMode::Oscillator,
52 }); 52 });
53 c.rcc.fdcan_clock_source = rcc::FdCanClockSource::HSE; 53 c.rcc.mux.fdcansel = rcc::mux::Fdcansel::HSE;
54 TestOptions { 54 TestOptions {
55 config: c, 55 config: c,
56 max_latency: Duration::from_micros(1200), 56 max_latency: Duration::from_micros(1200),
diff --git a/tests/stm32/src/common.rs b/tests/stm32/src/common.rs
index 7b9585afd..cf3e04a4b 100644
--- a/tests/stm32/src/common.rs
+++ b/tests/stm32/src/common.rs
@@ -2,6 +2,8 @@
2 2
3pub use defmt::*; 3pub use defmt::*;
4#[allow(unused)] 4#[allow(unused)]
5use embassy_stm32::rcc::*;
6#[allow(unused)]
5use embassy_stm32::time::Hertz; 7use embassy_stm32::time::Hertz;
6use embassy_stm32::Config; 8use embassy_stm32::Config;
7use {defmt_rtt as _, panic_probe as _}; 9use {defmt_rtt as _, panic_probe as _};
@@ -265,7 +267,6 @@ pub fn config() -> Config {
265 267
266 #[cfg(feature = "stm32f091rc")] 268 #[cfg(feature = "stm32f091rc")]
267 { 269 {
268 use embassy_stm32::rcc::*;
269 config.rcc.hse = Some(Hse { 270 config.rcc.hse = Some(Hse {
270 freq: Hertz(8_000_000), 271 freq: Hertz(8_000_000),
271 mode: HseMode::Bypass, 272 mode: HseMode::Bypass,
@@ -281,7 +282,6 @@ pub fn config() -> Config {
281 } 282 }
282 #[cfg(feature = "stm32f103c8")] 283 #[cfg(feature = "stm32f103c8")]
283 { 284 {
284 use embassy_stm32::rcc::*;
285 config.rcc.hse = Some(Hse { 285 config.rcc.hse = Some(Hse {
286 freq: Hertz(8_000_000), 286 freq: Hertz(8_000_000),
287 mode: HseMode::Oscillator, 287 mode: HseMode::Oscillator,
@@ -298,7 +298,6 @@ pub fn config() -> Config {
298 } 298 }
299 #[cfg(feature = "stm32f207zg")] 299 #[cfg(feature = "stm32f207zg")]
300 { 300 {
301 use embassy_stm32::rcc::*;
302 // By default, HSE on the board comes from a 8 MHz clock signal (not a crystal) 301 // By default, HSE on the board comes from a 8 MHz clock signal (not a crystal)
303 config.rcc.hse = Some(Hse { 302 config.rcc.hse = Some(Hse {
304 freq: Hertz(8_000_000), 303 freq: Hertz(8_000_000),
@@ -327,7 +326,6 @@ pub fn config() -> Config {
327 326
328 #[cfg(feature = "stm32f303ze")] 327 #[cfg(feature = "stm32f303ze")]
329 { 328 {
330 use embassy_stm32::rcc::*;
331 config.rcc.hse = Some(Hse { 329 config.rcc.hse = Some(Hse {
332 freq: Hertz(8_000_000), 330 freq: Hertz(8_000_000),
333 mode: HseMode::Bypass, 331 mode: HseMode::Bypass,
@@ -345,7 +343,6 @@ pub fn config() -> Config {
345 343
346 #[cfg(feature = "stm32f429zi")] 344 #[cfg(feature = "stm32f429zi")]
347 { 345 {
348 use embassy_stm32::rcc::*;
349 config.rcc.hse = Some(Hse { 346 config.rcc.hse = Some(Hse {
350 freq: Hertz(8_000_000), 347 freq: Hertz(8_000_000),
351 mode: HseMode::Bypass, 348 mode: HseMode::Bypass,
@@ -366,7 +363,6 @@ pub fn config() -> Config {
366 363
367 #[cfg(feature = "stm32f446re")] 364 #[cfg(feature = "stm32f446re")]
368 { 365 {
369 use embassy_stm32::rcc::*;
370 config.rcc.hse = Some(Hse { 366 config.rcc.hse = Some(Hse {
371 freq: Hertz(8_000_000), 367 freq: Hertz(8_000_000),
372 mode: HseMode::Oscillator, 368 mode: HseMode::Oscillator,
@@ -387,7 +383,6 @@ pub fn config() -> Config {
387 383
388 #[cfg(feature = "stm32f767zi")] 384 #[cfg(feature = "stm32f767zi")]
389 { 385 {
390 use embassy_stm32::rcc::*;
391 config.rcc.hse = Some(Hse { 386 config.rcc.hse = Some(Hse {
392 freq: Hertz(8_000_000), 387 freq: Hertz(8_000_000),
393 mode: HseMode::Bypass, 388 mode: HseMode::Bypass,
@@ -408,7 +403,6 @@ pub fn config() -> Config {
408 403
409 #[cfg(feature = "stm32h563zi")] 404 #[cfg(feature = "stm32h563zi")]
410 { 405 {
411 use embassy_stm32::rcc::*;
412 config.rcc.hsi = None; 406 config.rcc.hsi = None;
413 config.rcc.hsi48 = Some(Default::default()); // needed for RNG 407 config.rcc.hsi48 = Some(Default::default()); // needed for RNG
414 config.rcc.hse = Some(Hse { 408 config.rcc.hse = Some(Hse {
@@ -433,7 +427,6 @@ pub fn config() -> Config {
433 427
434 #[cfg(feature = "stm32h503rb")] 428 #[cfg(feature = "stm32h503rb")]
435 { 429 {
436 use embassy_stm32::rcc::*;
437 config.rcc.hsi = None; 430 config.rcc.hsi = None;
438 config.rcc.hsi48 = Some(Default::default()); // needed for RNG 431 config.rcc.hsi48 = Some(Default::default()); // needed for RNG
439 config.rcc.hse = Some(Hse { 432 config.rcc.hse = Some(Hse {
@@ -456,9 +449,26 @@ pub fn config() -> Config {
456 config.rcc.voltage_scale = VoltageScale::Scale0; 449 config.rcc.voltage_scale = VoltageScale::Scale0;
457 } 450 }
458 451
452 #[cfg(feature = "stm32g491re")]
453 {
454 config.rcc.hse = Some(Hse {
455 freq: Hertz(24_000_000),
456 mode: HseMode::Oscillator,
457 });
458 config.rcc.pll = Some(Pll {
459 source: Pllsrc::HSE,
460 prediv: PllPreDiv::DIV6,
461 mul: PllMul::MUL85,
462 divp: None,
463 divq: Some(PllQDiv::DIV8), // 42.5 Mhz for fdcan.
464 divr: Some(PllRDiv::DIV2), // Main system clock at 170 MHz
465 });
466 config.rcc.mux.fdcansel = mux::Fdcansel::PLL1_Q;
467 config.rcc.sys = Sysclk::PLL1_R;
468 }
469
459 #[cfg(any(feature = "stm32h755zi", feature = "stm32h753zi"))] 470 #[cfg(any(feature = "stm32h755zi", feature = "stm32h753zi"))]
460 { 471 {
461 use embassy_stm32::rcc::*;
462 config.rcc.hsi = Some(HSIPrescaler::DIV1); 472 config.rcc.hsi = Some(HSIPrescaler::DIV1);
463 config.rcc.csi = true; 473 config.rcc.csi = true;
464 config.rcc.hsi48 = Some(Default::default()); // needed for RNG 474 config.rcc.hsi48 = Some(Default::default()); // needed for RNG
@@ -485,7 +495,7 @@ pub fn config() -> Config {
485 config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz 495 config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz
486 config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz 496 config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz
487 config.rcc.voltage_scale = VoltageScale::Scale1; 497 config.rcc.voltage_scale = VoltageScale::Scale1;
488 config.rcc.adc_clock_source = AdcClockSource::PLL2_P; 498 config.rcc.mux.adcsel = mux::Adcsel::PLL2_P;
489 #[cfg(any(feature = "stm32h755zi"))] 499 #[cfg(any(feature = "stm32h755zi"))]
490 { 500 {
491 config.rcc.supply_config = SupplyConfig::DirectSMPS; 501 config.rcc.supply_config = SupplyConfig::DirectSMPS;
@@ -494,7 +504,6 @@ pub fn config() -> Config {
494 504
495 #[cfg(any(feature = "stm32h7a3zi"))] 505 #[cfg(any(feature = "stm32h7a3zi"))]
496 { 506 {
497 use embassy_stm32::rcc::*;
498 config.rcc.hsi = Some(HSIPrescaler::DIV1); 507 config.rcc.hsi = Some(HSIPrescaler::DIV1);
499 config.rcc.csi = true; 508 config.rcc.csi = true;
500 config.rcc.hsi48 = Some(Default::default()); // needed for RNG 509 config.rcc.hsi48 = Some(Default::default()); // needed for RNG
@@ -521,12 +530,11 @@ pub fn config() -> Config {
521 config.rcc.apb3_pre = APBPrescaler::DIV2; // 140 Mhz 530 config.rcc.apb3_pre = APBPrescaler::DIV2; // 140 Mhz
522 config.rcc.apb4_pre = APBPrescaler::DIV2; // 140 Mhz 531 config.rcc.apb4_pre = APBPrescaler::DIV2; // 140 Mhz
523 config.rcc.voltage_scale = VoltageScale::Scale0; 532 config.rcc.voltage_scale = VoltageScale::Scale0;
524 config.rcc.adc_clock_source = AdcClockSource::PLL2_P; 533 config.rcc.mux.adcsel = mux::Adcsel::PLL2_P;
525 } 534 }
526 535
527 #[cfg(any(feature = "stm32l496zg", feature = "stm32l4a6zg", feature = "stm32l4r5zi"))] 536 #[cfg(any(feature = "stm32l496zg", feature = "stm32l4a6zg", feature = "stm32l4r5zi"))]
528 { 537 {
529 use embassy_stm32::rcc::*;
530 config.rcc.sys = Sysclk::PLL1_R; 538 config.rcc.sys = Sysclk::PLL1_R;
531 config.rcc.hsi = true; 539 config.rcc.hsi = true;
532 config.rcc.pll = Some(Pll { 540 config.rcc.pll = Some(Pll {
@@ -541,7 +549,6 @@ pub fn config() -> Config {
541 549
542 #[cfg(feature = "stm32wl55jc")] 550 #[cfg(feature = "stm32wl55jc")]
543 { 551 {
544 use embassy_stm32::rcc::*;
545 config.rcc.hse = Some(Hse { 552 config.rcc.hse = Some(Hse {
546 freq: Hertz(32_000_000), 553 freq: Hertz(32_000_000),
547 mode: HseMode::Bypass, 554 mode: HseMode::Bypass,
@@ -560,7 +567,6 @@ pub fn config() -> Config {
560 567
561 #[cfg(any(feature = "stm32l552ze"))] 568 #[cfg(any(feature = "stm32l552ze"))]
562 { 569 {
563 use embassy_stm32::rcc::*;
564 config.rcc.hsi = true; 570 config.rcc.hsi = true;
565 config.rcc.sys = Sysclk::PLL1_R; 571 config.rcc.sys = Sysclk::PLL1_R;
566 config.rcc.pll = Some(Pll { 572 config.rcc.pll = Some(Pll {
@@ -576,7 +582,6 @@ pub fn config() -> Config {
576 582
577 #[cfg(any(feature = "stm32u585ai", feature = "stm32u5a5zj"))] 583 #[cfg(any(feature = "stm32u585ai", feature = "stm32u5a5zj"))]
578 { 584 {
579 use embassy_stm32::rcc::*;
580 config.rcc.hsi = true; 585 config.rcc.hsi = true;
581 config.rcc.pll1 = Some(Pll { 586 config.rcc.pll1 = Some(Pll {
582 source: PllSource::HSI, // 16 MHz 587 source: PllSource::HSI, // 16 MHz
@@ -593,17 +598,12 @@ pub fn config() -> Config {
593 598
594 #[cfg(feature = "stm32wba52cg")] 599 #[cfg(feature = "stm32wba52cg")]
595 { 600 {
596 use embassy_stm32::rcc::*;
597 config.rcc.sys = Sysclk::HSI; 601 config.rcc.sys = Sysclk::HSI;
598 602 config.rcc.mux.rngsel = mux::Rngsel::HSI;
599 embassy_stm32::pac::RCC.ccipr2().write(|w| {
600 w.set_rngsel(embassy_stm32::pac::rcc::vals::Rngsel::HSI);
601 });
602 } 603 }
603 604
604 #[cfg(feature = "stm32l073rz")] 605 #[cfg(feature = "stm32l073rz")]
605 { 606 {
606 use embassy_stm32::rcc::*;
607 config.rcc.hsi = true; 607 config.rcc.hsi = true;
608 config.rcc.pll = Some(Pll { 608 config.rcc.pll = Some(Pll {
609 source: PllSource::HSI, 609 source: PllSource::HSI,
@@ -615,7 +615,6 @@ pub fn config() -> Config {
615 615
616 #[cfg(any(feature = "stm32l152re"))] 616 #[cfg(any(feature = "stm32l152re"))]
617 { 617 {
618 use embassy_stm32::rcc::*;
619 config.rcc.hsi = true; 618 config.rcc.hsi = true;
620 config.rcc.pll = Some(Pll { 619 config.rcc.pll = Some(Pll {
621 source: PllSource::HSI, 620 source: PllSource::HSI,