Skip to content

Commit 1bfebd8

Browse files
WratoxHenrik Snöman
andauthored
Add STM32H523/STM32H533 support (#38)
Co-authored-by: Henrik Snöman <[email protected]>
1 parent 9c0bf58 commit 1bfebd8

File tree

6 files changed

+178
-3
lines changed

6 files changed

+178
-3
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
- stable
1616
mcu:
1717
- stm32h503
18+
- stm32h523
19+
- stm32h533
1820
- stm32h562
1921
- stm32h563
2022
- stm32h573

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ rm0481 = [] # STM32H52x/6x/7x
2929

3030
# Different subfamily groups have different selections of identical peripherals
3131
h56x_h573 = ["gpio-h56x_h573"] # STM32H56x/STM32H573
32-
h523_h533 = [] # STM32H523/STM32H533
32+
h523_h533 = ["gpio-h523_h533"] # STM32H523/STM32H533
3333

3434
# Different subfamily groups have different GPIOs available and different alternate functions
3535
# available
3636
gpio-h503 = []
37+
gpio-h523_h533 = []
3738
gpio-h56x_h573 = []
3839

3940
# Some peripherals are only present on specific MCUs within a subfamily group
@@ -43,6 +44,8 @@ sdmmc2 = [] # Only STM32H563/73 have SDMMC2
4344

4445
rt = ["stm32h5/rt"]
4546
stm32h503 = ["stm32h5/stm32h503", "device-selected", "rm0492"]
47+
stm32h523 = ["stm32h5/stm32h523", "device-selected", "rm0481", "h523_h533"]
48+
stm32h533 = ["stm32h5/stm32h533", "device-selected", "rm0481", "h523_h533"]
4649
stm32h562 = ["stm32h5/stm32h562", "device-selected", "rm0481", "h56x_h573"]
4750
stm32h563 = ["stm32h5/stm32h563", "device-selected", "rm0481", "h56x_h573", "sdmmc2", "ethernet"]
4851
stm32h573 = ["stm32h5/stm32h573", "device-selected", "rm0481", "h56x_h573", "otfdec", "sdmmc2", "ethernet"]
@@ -55,7 +58,7 @@ log-semihost = ["log"]
5558

5659
[dependencies]
5760
cortex-m = { version = "^0.7.7", features = ["critical-section-single-core"] }
58-
stm32h5 = { package = "stm32h5-staging", version = "0.17.0" }
61+
stm32h5 = { package = "stm32h5-staging", version = "0.18.1" }
5962
fugit = "0.3.7"
6063
embedded-hal = "1.0.0"
6164
defmt = { version = "0.3.8", optional = true }

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ every single model.
2121
| Part | Supported | RM | Dev board |
2222
| --------- | --------- | -- | --------- |
2323
| stm32h503 | 🚧 (WIP) | [RM0492](https://www.st.com/resource/en/reference_manual/rm0492-stm32h503-line-armbased-32bit-mcus-stmicroelectronics.pdf) <sup>[(errata)](https://www.st.com/resource/en/errata_sheet/es0561-stm32h503cbebkbrb-device-errata-stmicroelectronics.pdf)</sup> | [Nucleo H503RB](https://www.st.com/en/evaluation-tools/nucleo-h503rb.html) |
24+
| stm32h523 | 🚧 (WIP) | [RM0481](https://www.st.com/resource/en/reference_manual/rm0481-stm32h563h573-and-stm32h562-armbased-32bit-mcus-stmicroelectronics.pdf) <sup>[(errata)](https://www.st.com/resource/en/errata_sheet/es0565-stm32h562xx563xx573xx-device-errata-stmicroelectronics.pdf)</sup>| |
25+
| stm32h533 | 🚧 (WIP) | [RM0481](https://www.st.com/resource/en/reference_manual/rm0481-stm32h563h573-and-stm32h562-armbased-32bit-mcus-stmicroelectronics.pdf) <sup>[(errata)](https://www.st.com/resource/en/errata_sheet/es0565-stm32h562xx563xx573xx-device-errata-stmicroelectronics.pdf)</sup>| [Nucleo H533RE](https://www.st.com/en/evaluation-tools/nucleo-h533re.html) |
2426
| stm32h562 |* | [RM0481](https://www.st.com/resource/en/reference_manual/rm0481-stm32h563h573-and-stm32h562-armbased-32bit-mcus-stmicroelectronics.pdf) <sup>[(errata)](https://www.st.com/resource/en/errata_sheet/es0565-stm32h562xx563xx573xx-device-errata-stmicroelectronics.pdf)</sup>| |
2527
| stm32h563 |* | [RM0481](https://www.st.com/resource/en/reference_manual/rm0481-stm32h563h573-and-stm32h562-armbased-32bit-mcus-stmicroelectronics.pdf) <sup>[(errata)](https://www.st.com/resource/en/errata_sheet/es0565-stm32h562xx563xx573xx-device-errata-stmicroelectronics.pdf)</sup> | [Nucleo H563ZI](https://www.st.com/en/evaluation-tools/nucleo-h563zi.html) |
2628
| stm32h573 |* | [RM0481](https://www.st.com/resource/en/reference_manual/rm0481-stm32h563h573-and-stm32h562-armbased-32bit-mcus-stmicroelectronics.pdf) <sup>[(errata)](https://www.st.com/resource/en/errata_sheet/es0565-stm32h562xx563xx573xx-device-errata-stmicroelectronics.pdf)</sup> | |

src/gpio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub struct PushPull;
167167
/// Analog mode (type state)
168168
pub struct Analog;
169169

170-
/// JTAG/SWD mote (type state)
170+
/// JTAG/SWD mode (type state)
171171
pub type Debugger = Alternate<0, PushPull>;
172172

173173
mod marker {

src/gpio/gpio_def.rs

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,166 @@ mod h503 {
145145
}
146146
}
147147

148+
#[cfg(feature = "gpio-h523_h533")]
149+
pub use h523_h533::*;
150+
151+
#[cfg(feature = "gpio-h523_h533")]
152+
mod h523_h533 {
153+
use super::Gpio;
154+
155+
gpio!(GPIOA, gpioa, Gpioa, PA, 'A', PAn, [
156+
PA0: (pa0, 0, [1, 2, 3, 4, 5, 6, 7, 8, 9, 14, 15]),
157+
PA1: (pa1, 1, [1, 2, 4, 5, 6, 7, 8, 9, 14, 15]),
158+
PA2: (pa2, 2, [1, 2, 3, 4, 5, 7, 15]),
159+
PA3: (pa3, 3, [1, 2, 3, 4, 5, 6, 7, 15]),
160+
PA4: (pa4, 4, [2, 3, 4, 5, 6, 7, 13, 15]),
161+
PA5: (pa5, 5, [1, 3, 5, 13, 14, 15]),
162+
PA6: (pa6, 6, [1, 2, 3, 5, 6, 13, 15]),
163+
PA7: (pa7, 7, [1, 2, 3, 5, 10, 13, 15]),
164+
PA8: (pa8, 8, [0, 1, 3, 4, 5, 6, 7, 9, 10, 12, 13, 15]),
165+
PA9: (pa9, 9, [1, 3, 4, 5, 7, 12, 13, 15]),
166+
PA10: (pa10, 10, [1, 3, 4, 6, 7, 9, 12, 13, 15]),
167+
PA11: (pa11, 11, [1, 3, 5, 6, 7, 9, 10, 15]),
168+
PA12: (pa12, 12, [1, 3, 5, 6, 7, 9, 10, 15]),
169+
PA13: (pa13, 13, [0, 15], crate::gpio::Debugger),
170+
PA14: (pa14, 14, [0, 15], crate::gpio::Debugger),
171+
PA15: (pa15, 15, [0, 1, 4, 5, 6, 7, 8, 9, 12, 13, 14, 15], crate::gpio::Debugger),
172+
]);
173+
174+
gpio!(GPIOB, gpiob, Gpiob, PB, 'B', PBn, [
175+
PB0: (pb0, 0, [1, 2, 3, 5, 6, 7, 8, 15]),
176+
PB1: (pb1, 1, [1, 2, 3, 4, 5, 6, 7, 15]),
177+
PB2: (pb2, 2, [0, 3, 4, 5, 6, 7, 9, 10, 12, 15]),
178+
PB3: (pb3, 3, [0, 1, 3, 4, 5, 6, 8, 9, 10, 14, 15], crate::gpio::Debugger),
179+
PB4: (pb4, 4, [0, 2, 3, 4, 5, 6, 7, 9, 10, 13, 15], crate::gpio::Debugger),
180+
PB5: (pb5, 5, [2, 3, 4, 5, 6, 7, 9, 10, 13, 14, 15]),
181+
PB6: (pb6, 6, [2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 14, 15]),
182+
PB7: (pb7, 7, [2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 15]),
183+
PB8: (pb8, 8, [2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 15]),
184+
PB9: (pb9, 9, [2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 15]),
185+
PB10: (pb10, 10, [1, 2, 3, 4, 5, 7, 9, 15]),
186+
PB12: (pb12, 12, [1, 2, 3, 4, 5, 6, 7, 9, 14, 15]),
187+
PB13: (pb13, 13, [1, 2, 3, 4, 5, 7, 8, 9, 12, 14, 15]),
188+
PB14: (pb14, 14, [1, 2, 3, 4, 5, 7, 8, 15]),
189+
PB15: (pb15, 15, [0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 14, 15]),
190+
]);
191+
192+
gpio!(GPIOC, gpioc, Gpioc, PC, 'C', PCn, [
193+
PC0: (pc0, 0, [6, 7, 9, 10, 15]),
194+
PC1: (pc1, 1, [0, 5, 6, 10, 15]),
195+
PC2: (pc2, 2, [0, 2, 5, 6, 9, 15]),
196+
PC3: (pc3, 3, [0, 3, 5, 6, 9, 15]),
197+
PC4: (pc4, 4, [1, 3, 5, 7, 15]),
198+
PC5: (pc5, 5, [1, 4, 6, 10, 15]),
199+
PC6: (pc6, 6, [2, 3, 5, 7, 8, 9, 10, 11, 12, 13, 15]),
200+
PC7: (pc7, 7, [0, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 15]), //TRGIO (AF0) was missing from autogenerated code
201+
PC8: (pc8, 8, [0, 2, 3, 7, 8, 9, 10, 11, 12, 13, 15]),
202+
PC9: (pc9, 9, [0, 2, 3, 4, 5, 8, 9, 11, 12, 13, 15]),
203+
PC10: (pc10, 10, [3, 6, 7, 8, 9, 12, 13, 15]),
204+
PC11: (pc11, 11, [3, 6, 7, 8, 9, 12, 13, 15]),
205+
PC12: (pc12, 12, [0, 2, 3, 6, 7, 8, 12, 13, 15]),
206+
PC13: (pc13, 13, [15]),
207+
PC14: (pc14, 14, [15]),
208+
PC15: (pc15, 15, [15]),
209+
]);
210+
211+
gpio!(GPIOD, gpiod, Gpiod, PD, 'D', PDn, [
212+
PD0: (pd0, 0, [3, 8, 9, 12, 15]),
213+
PD1: (pd1, 1, [8, 9, 12, 15]),
214+
PD2: (pd2, 2, [0, 2, 4, 8, 12, 13, 15]),
215+
PD3: (pd3, 3, [5, 7, 12, 13, 15]),
216+
PD4: (pd4, 4, [7, 10, 12, 15]),
217+
PD5: (pd5, 5, [1, 5, 7, 9, 10, 12, 15]),
218+
PD6: (pd6, 6, [3, 4, 5, 7, 10, 11, 12, 13, 15]),
219+
PD7: (pd7, 7, [3, 4, 5, 6, 7, 10, 11, 12, 15]),
220+
PD8: (pd8, 8, [7, 12, 15]),
221+
PD9: (pd9, 9, [7, 9, 12, 15]),
222+
PD10: (pd10, 10, [3, 7, 12, 15]),
223+
PD11: (pd11, 11, [3, 7, 8, 9, 12, 15]),
224+
PD12: (pd12, 12, [1, 2, 3, 5, 7, 8, 9, 12, 13, 15]),
225+
PD13: (pd13, 13, [1, 2, 3, 5, 9, 12, 13, 15]),
226+
PD14: (pd14, 14, [2, 12, 15]),
227+
PD15: (pd15, 15, [2, 12, 15]),
228+
]);
229+
230+
gpio!(GPIOE, gpioe, Gpioe, PE, 'E', PEn, [
231+
PE0: (pe0, 0, [1, 2, 3, 4, 6, 9, 12, 13, 15]),
232+
PE2: (pe2, 2, [0, 1, 5, 9, 12, 13, 15]),
233+
PE3: (pe3, 3, [0, 4, 12, 15]),
234+
PE4: (pe4, 4, [0, 4, 5, 12, 13, 15]),
235+
PE5: (pe5, 5, [0, 4, 5, 12, 13, 15]),
236+
PE6: (pe6, 6, [0, 1, 4, 5, 12, 13, 15]),
237+
PE7: (pe7, 7, [1, 10, 12, 15]),
238+
PE8: (pe8, 8, [1, 10, 12, 15]),
239+
PE9: (pe9, 9, [1, 10, 12, 15]),
240+
PE10: (pe10, 10, [1, 10, 12, 15]),
241+
PE11: (pe11, 11, [1, 4, 5, 6, 12, 15]),
242+
PE12: (pe12, 12, [1, 5, 12, 15]),
243+
PE13: (pe13, 13, [1, 5, 12, 15]),
244+
PE14: (pe14, 14, [1, 5, 12, 15]),
245+
PE15: (pe15, 15, [1, 3, 12, 15]),
246+
]);
247+
248+
gpio!(GPIOF, gpiof, Gpiof, PF, 'F', PFn, [
249+
PF0: (pf0, 0, [3, 4, 12, 15]),
250+
PF1: (pf1, 1, [3, 4, 12, 15]),
251+
PF2: (pf2, 2, [4, 12, 15]),
252+
PF3: (pf3, 3, [12, 15]),
253+
PF4: (pf4, 4, [12, 15]),
254+
PF5: (pf5, 5, [5, 12, 15]),
255+
PF6: (pf6, 6, [10, 15]),
256+
PF7: (pf7, 7, [10, 15]),
257+
PF8: (pf8, 8, [10, 15]),
258+
PF9: (pf9, 9, [10, 15]),
259+
PF10: (pf10, 10, [4, 9, 13, 15]),
260+
PF11: (pf11, 11, [9, 13, 15]),
261+
PF12: (pf12, 12, [12, 15]),
262+
PF13: (pf13, 13, [12, 15]),
263+
PF14: (pf14, 14, [12, 15]),
264+
PF15: (pf15, 15, [5, 12, 15]),
265+
]);
266+
267+
gpio!(GPIOG, gpiog, Gpiog, PG, 'G', PGn, [
268+
PG0: (pg0, 0, [12, 15]),
269+
PG1: (pg1, 1, [7, 12, 15]),
270+
PG2: (pg2, 2, [3, 12, 15]),
271+
PG3: (pg3, 3, [3, 12, 15]),
272+
PG4: (pg4, 4, [1, 12, 15]),
273+
PG5: (pg5, 5, [1, 12, 15]),
274+
PG6: (pg6, 6, [3, 5, 10, 11, 12, 13, 15]),
275+
PG7: (pg7, 7, [3, 7, 11, 12, 13, 15]),
276+
PG8: (pg8, 8, [3, 5, 7, 15]),
277+
PG9: (pg9, 9, [5, 7, 9, 11, 12, 13, 15]),
278+
PG10: (pg10, 10, [5, 11, 12, 13, 15]),
279+
PG11: (pg11, 11, [1, 5, 10, 13, 15]),
280+
PG12: (pg12, 12, [1, 4, 7, 10, 12, 13, 15]),
281+
PG13: (pg13, 13, [0, 1, 7, 12, 15]),
282+
PG14: (pg14, 14, [0, 1, 4, 7, 9, 12, 15]),
283+
PG15: (pg15, 15, [5, 7, 13, 15]),
284+
]);
285+
286+
gpio!(GPIOH, gpioh, Gpioh, PH, 'H', PHn, [
287+
PH0: (ph0, 0, [15]),
288+
PH1: (ph1, 1, [15]),
289+
]);
290+
291+
impl<const P: char> Gpio<P> {
292+
pub(crate) const fn ptr() -> *const crate::pac::gpioa::RegisterBlock {
293+
match P {
294+
'A' => crate::pac::GPIOA::ptr(),
295+
'B' => crate::pac::GPIOB::ptr() as _,
296+
'C' => crate::pac::GPIOC::ptr() as _,
297+
'D' => crate::pac::GPIOD::ptr() as _,
298+
'E' => crate::pac::GPIOE::ptr() as _,
299+
'F' => crate::pac::GPIOF::ptr() as _,
300+
'G' => crate::pac::GPIOG::ptr() as _,
301+
'H' => crate::pac::GPIOH::ptr() as _,
302+
_ => panic!("Unknown GPIO port"),
303+
}
304+
}
305+
}
306+
}
307+
148308
#[cfg(feature = "gpio-h56x_h573")]
149309
pub use h56x_h573::*;
150310

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
compile_error!(
77
"This crate requires one of the following device features enabled:
88
stm32h503
9+
stm32h523
10+
stm32h533
911
stm32h562
1012
stm32h563
1113
stm32h573
@@ -18,6 +20,12 @@ compile_error!("Cannot not select both rm0492 and rm0481");
1820
#[cfg(feature = "stm32h503")]
1921
pub use stm32h5::stm32h503 as stm32;
2022

23+
#[cfg(feature = "stm32h523")]
24+
pub use stm32h5::stm32h523 as stm32;
25+
26+
#[cfg(feature = "stm32h533")]
27+
pub use stm32h5::stm32h533 as stm32;
28+
2129
#[cfg(feature = "stm32h562")]
2230
pub use stm32h5::stm32h562 as stm32;
2331

0 commit comments

Comments
 (0)