Skip to content

Commit 5e7a293

Browse files
authored
rcc: add peripheral clock definitions for the rest of the H5 family (#30)
Add Peripheral clock + reset/enable definitions for the rest of the H5 family (for which we have SVDs - still waiting on the H523/H533 SVDs).
1 parent 86ec4c5 commit 5e7a293

File tree

3 files changed

+126
-39
lines changed

3 files changed

+126
-39
lines changed

Cargo.toml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,28 @@ device-selected = []
2525

2626
# rmXXXX represent processor subfamilies and their common features
2727
rm0492 = ["gpio-h503"]
28-
rm0481 = ["gpio-h5x"] # STM32H52x/6x/7x
28+
rm0481 = [] # STM32H52x/6x/7x
2929

30-
# Different subfamilies have different GPIOs available
30+
# Different subfamily groups have different selections of identical peripherals
31+
h56x_h573 = ["gpio-h56x_h573"] # STM32H56x/STM32H573
32+
h523_h533 = [] # STM32H523/STM32H533
33+
34+
# Different subfamily groups have different GPIOs available and different alternate functions
35+
# available
3136
gpio-h503 = []
32-
gpio-h5x = []
37+
gpio-h56x_h573 = []
38+
39+
# Some peripherals are only present on specific MCUs within a subfamily group
40+
ethernet = [] # Only STM32H563/73 have ethernet
41+
otfdec = [] # Only STM32H573/33 have OTFDEC
42+
sdmmc2 = [] # Only STM32H563/73 have SDMMC2
3343

3444
rt = ["stm32h5/rt"]
3545
stm32h503 = ["stm32h5/stm32h503", "device-selected", "rm0492"]
36-
stm32h562 = ["stm32h5/stm32h562", "device-selected", "rm0481"]
37-
stm32h563 = ["stm32h5/stm32h563", "device-selected", "rm0481"]
38-
stm32h573 = ["stm32h5/stm32h573", "device-selected", "rm0481"]
46+
stm32h562 = ["stm32h5/stm32h562", "device-selected", "rm0481", "h56x_h573"]
47+
stm32h563 = ["stm32h5/stm32h563", "device-selected", "rm0481", "h56x_h573", "sdmmc2", "ethernet"]
48+
stm32h573 = ["stm32h5/stm32h573", "device-selected", "rm0481", "h56x_h573", "otfdec", "sdmmc2", "ethernet"]
49+
3950
# Flags for examples
4051
log = ["dep:log"]
4152
log-itm = ["log"]

src/gpio/gpio_def.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ mod h503 {
145145
}
146146
}
147147

148-
#[cfg(feature = "gpio-h5x")]
149-
pub use h5x::*;
148+
#[cfg(feature = "gpio-h56x_h573")]
149+
pub use h56x_h573::*;
150150

151-
#[cfg(feature = "gpio-h5x")]
152-
mod h5x {
151+
#[cfg(feature = "gpio-h56x_h573")]
152+
mod h56x_h573 {
153153
use super::Gpio;
154154

155155
impl<const P: char> Gpio<P> {

src/rcc/rec.rs

Lines changed: 105 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,6 @@ macro_rules! variant_return_type {
475475
// Peripherals with an individual kernel clock must be marked "kernel clk". If a
476476
// kernel clock multiplexer is shared between multiple peripherals, all those
477477
// peripherals must instead be marked with a common "group clk".
478-
//
479-
// NOTE: The stm32h5 crate does not have definitions for the clock source variants for registers for
480-
// any processors other than the STM32H503 at this time. Therefore, peripherals which have
481-
// selectable clock sources are currently only specified for the H503 (rm0492).
482478
peripheral_reset_and_enable_control! {
483479

484480
#[cfg(all())]
@@ -495,6 +491,19 @@ peripheral_reset_and_enable_control! {
495491
AHB1, "" => [
496492
(NoReset) Gtzc1
497493
];
494+
#[cfg(feature = "rm0481")]
495+
AHB1, "" => [
496+
(NoReset) Dcache,
497+
(NoReset) Tzsc1,
498+
Fmac,
499+
Cordic
500+
];
501+
#[cfg(feature = "ethernet")]
502+
AHB1, "" => [
503+
(NoReset) Ethrx,
504+
(NoReset) Ethtx,
505+
Eth
506+
];
498507

499508
#[cfg(all())]
500509
AHB2, "AMBA High-performance Bus (AHB2) peripherals" => [
@@ -504,69 +513,136 @@ peripheral_reset_and_enable_control! {
504513
Gpiod,
505514
Gpioc,
506515
Gpiob,
507-
Gpioa
516+
Gpioa,
517+
Rng [kernel clk: Rng RNG ccipr5 "RNG"],
518+
Adc [group clk: AdcDac(Variant) ADCDAC ccipr5 "ADC/DAC"]
508519
];
509520
#[cfg(feature = "rm0492")]
510521
AHB2, "" => [
511-
Rng [kernel clk: Rng RNG ccipr5 "RNG"],
512-
Adc [group clk: AdcDac(Variant) ADCDAC ccipr5 "ADC/DAC"],
513522
Dac12 [group clk: AdcDac]
514523
];
524+
#[cfg(feature = "rm0481")]
525+
AHB2, "" => [
526+
Gpiog,
527+
Gpiof,
528+
Gpioe,
529+
Dac1 [group clk: AdcDac]
530+
];
531+
#[cfg(feature = "h56x_h573")]
532+
AHB2, "" => [
533+
Gpioi
534+
];
515535

536+
#[cfg(feature = "rm0481")]
537+
AHB4, "AMBA High-performance Bus (AHB4) peripherals" => [
538+
Octospi1 [kernel clk: Octospi1 OCTOSPI1 ccipr4 "OCTOSPI1"],
539+
Fmc,
540+
541+
Sdmmc1 [kernel clk: Sdmmc1 SDMMC ccipr4 "SDMMC1"]
542+
];
543+
#[cfg(feature = "sdmmc2")]
544+
AHB4, "" => [
545+
Sdmmc2 [kernel clk: Sdmmc2 SDMMC ccipr4 "SDMMC2"]
546+
];
547+
#[cfg(feature = "otfdec")]
548+
AHB4, "" => [
549+
Otfdec1
550+
];
516551

517552
#[cfg(all())]
518553
APB1L, "Advanced Peripheral Bus 1L (APB1L) peripherals" => [
554+
Usart2 [kernel clk: Usart2(Variant) USART ccipr1 "USART2"],
555+
Usart3 [kernel clk: Usart3(Variant) USART ccipr1 "USART3"],
519556
Crs,
557+
I3c1 [kernel clk: I3c1(Variant) I3C ccipr4 "I3C1"],
558+
I2c2 [kernel clk: I2c2 I2C ccipr4 "I2C2"],
559+
I2c1 [kernel clk: I2c1 I2C ccipr4 "I2C1"],
560+
Spi3 [kernel clk: Spi3(Variant) SPI123 ccipr3 "SPI3"],
561+
Spi2 [kernel clk: Spi2(Variant) SPI123 ccipr3 "SPI2"],
520562
(NoReset) Wwdg,
521563
Tim2, Tim3, Tim6, Tim7
522564
];
523565
#[cfg(feature = "rm0492")]
524566
APB1L, "" => [
525-
I3c1 [kernel clk: I3c1(Variant) I3C ccipr4 "I3C1"],
526-
527-
I2c1 [kernel clk: I2c1 I2C ccipr4 "I2C1"],
528-
I2c2 [kernel clk: I2c2 I2C ccipr4 "I2C2"],
529-
530-
Usart2 [kernel clk: Usart2(Variant) USART ccipr1 "USART2"],
531-
Usart3 [kernel clk: Usart3(Variant) USART ccipr1 "USART3"],
532-
533-
Spi2 [kernel clk: Spi2(Variant) SPI123 ccipr3 "SPI2"],
534-
Spi3 [kernel clk: Spi3(Variant) SPI123 ccipr3 "SPI3"],
535567
Opamp,
536568
Comp
537569
];
570+
#[cfg(feature = "rm0481")]
571+
APB1L, "" => [
572+
Cec [kernel clk: Cec(Variant) CEC ccipr5 "CEC"],
573+
Usart6 [kernel clk: Usart6(Variant) USART ccipr1 "USART6"],
574+
Uart5 [kernel clk: Uart5(Variant) USART ccipr1 "USART5"],
575+
Uart4 [kernel clk: Uart4(Variant) USART ccipr1 "USART4"],
576+
Tim12, Tim5, Tim4
577+
];
578+
#[cfg(feature = "h56x_h573")]
579+
APB1L, "" => [
580+
Uart8 [kernel clk: Uart8(Variant) USART ccipr1 "UART8"],
581+
Uart7 [kernel clk: Uart7(Variant) USART ccipr1 "UART7"],
582+
Usart11 [kernel clk: Usart11(Variant) USART ccipr2 "USART11"],
583+
Usart10 [kernel clk: Usart10(Variant) USART ccipr1 "USART10"],
584+
Tim14, Tim13
585+
];
538586

539587
#[cfg(all())]
540588
APB1H, "Advanced Peripheral Bus 1H (APB1H) peripherals" => [
589+
Fdcan [kernel clk: Fdcan(Variant) FDCAN ccipr5 "FDCAN"],
590+
Lptim2 [kernel clk: Lptim2(Variant) LPTIM ccipr2 "LPTIM2"],
541591
Dts
542592
];
543-
#[cfg(feature = "rm0492")]
593+
#[cfg(feature = "rm0481")]
544594
APB1H, "" => [
545-
Lptim2 [kernel clk: Lptim2(Variant) LPTIM ccipr2 "LPTIM2"],
546-
Fdcan [kernel clk: Fdcan(Variant) FDCAN ccipr5 "FDCAN"]
595+
Ucpd1
596+
];
597+
#[cfg(feature = "h56x_h573")]
598+
APB1H, "" => [
599+
Uart12 [kernel clk: Uart12(Variant) USART ccipr2 "USART12"],
600+
Uart9 [kernel clk: Uart9(Variant) USART ccipr1 "UART9"]
547601
];
548602

549603
#[cfg(all())]
550604
APB2, "Advanced Peripheral Bus 2 (APB2) peripherals" => [
605+
Usb [kernel clk: Usb USB ccipr4 "USB"],
606+
Usart1 [kernel clk: Usart1(Variant) USART ccipr1 "USART1"],
607+
Spi1 [kernel clk: Spi1(Variant) SPI123 ccipr3 "SPI1"],
551608
Tim1
552609
];
553-
#[cfg(feature = "rm0492")]
610+
#[cfg(feature = "rm0481")]
554611
APB2, "" => [
555-
Usb [kernel clk: Usb USB ccipr4 "USB"],
556-
Usart1 [kernel clk: Usart1(Variant) USART ccipr1 "USART1"],
557-
Spi1 [kernel clk: Spi1(Variant) SPI123 ccipr3 "SPI1"]
612+
Sai2 [kernel clk: Sai2(Variant) SAI ccipr5 "SAI2"],
613+
Sai1 [kernel clk: Sai1(Variant) SAI ccipr5 "SAI1"],
614+
Spi4 [kernel clk: Spi4(Variant) SPI456 ccipr3 "SPI4"],
615+
Tim15, Tim8
616+
];
617+
#[cfg(feature = "h56x_h573")]
618+
APB2, "" => [
619+
Spi6 [kernel clk: Spi6(Variant) SPI456 ccipr3 "SPI6"],
620+
Tim17, Tim16
558621
];
559622

560623
#[cfg(all())]
561624
APB3, "Advanced Peripheral Bus 3 (APB3) peripherals" => [
562625
(NoReset) RtcApb,
626+
LpTim1 [kernel clk: LpTim1(Variant) LPTIM ccipr2 "LPTIM1"],
627+
LpUart1 [kernel clk: LpUart1(Variant) USART ccipr3 "LPUART1"],
563628
(NoReset) Sbs
564629
];
565-
#[cfg(feature = "rm0492")]
630+
#[cfg(feature = "rm0481")]
566631
APB3, "" => [
567-
I3c2 [kernel clk: I3c2(Variant) I3C ccipr4 "I3C2"],
568-
LpTim1 [kernel clk: LpTim1(Variant) LPTIM ccipr2 "LPTIM1"],
569-
LpUart1 [kernel clk: LpUart1(Variant) USART ccipr3 "LPUART1"]
632+
Vref,
633+
I2c3 [kernel clk: I2c3 I2C ccipr4 "I2C3"]
634+
];
635+
#[cfg(feature = "h56x_h573")]
636+
APB3, "" => [
637+
LpTim6 [kernel clk: LpTim6(Variant) LPTIM ccipr2 "LPTIM6"],
638+
LpTim5 [kernel clk: LpTim5(Variant) LPTIM ccipr2 "LPTIM5"],
639+
LpTim4 [kernel clk: LpTim4(Variant) LPTIM ccipr2 "LPTIM4"],
640+
LpTim3 [kernel clk: LpTim3(Variant) LPTIM ccipr2 "LPTIM3"],
641+
I2c4 [kernel clk: I2c4 I2C ccipr4 "I2C4"],
642+
Spi5 [kernel clk: Spi5(Variant) SPI456 ccipr3 "SPI5"]
643+
];
644+
#[cfg(any(feature = "rm0492", feature = "h523_h533"))]
645+
APB3, "" => [
646+
I3c2 [kernel clk: I3c2(Variant) I3C ccipr4 "I3C2"]
570647
];
571-
572648
}

0 commit comments

Comments
 (0)