aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-10-22 21:05:27 +0000
committerGitHub <[email protected]>2023-10-22 21:05:27 +0000
commit46ff2c82aa3193dd1378b142be284aa746045923 (patch)
tree41c2abe14f76529e2c56679c87f2aa2f9acf82d5
parente70c531d3d28565b6926d99d8e977c4df6c13c60 (diff)
parenta84ad741a48dfce29b7f764e0cfb6877eba9a027 (diff)
Merge pull request #2101 from embassy-rs/rcc-no-spaghetti
stm32/tests: add stm32wba52cg, stm32u5a9zj
-rwxr-xr-xci.sh7
-rw-r--r--embassy-stm32/Cargo.toml4
-rw-r--r--embassy-stm32/src/rcc/g0.rs20
-rw-r--r--embassy-stm32/src/rcc/g4.rs14
-rw-r--r--embassy-stm32/src/rcc/l0l1.rs20
-rw-r--r--embassy-stm32/src/rcc/l4l5.rs14
-rw-r--r--embassy-stm32/src/rcc/u5.rs29
-rw-r--r--embassy-stm32/src/rcc/wba.rs12
-rw-r--r--embassy-stm32/src/rcc/wl.rs8
-rw-r--r--examples/stm32g4/src/bin/adc.rs2
-rw-r--r--examples/stm32g4/src/bin/pll.rs2
-rw-r--r--examples/stm32l0/src/bin/lora_cad.rs2
-rw-r--r--examples/stm32l0/src/bin/lora_lorawan.rs2
-rw-r--r--examples/stm32l0/src/bin/lora_p2p_receive.rs2
-rw-r--r--examples/stm32l0/src/bin/lora_p2p_send.rs2
-rw-r--r--examples/stm32l4/src/bin/rng.rs2
-rw-r--r--examples/stm32l4/src/bin/usb_serial.rs2
-rw-r--r--examples/stm32l5/src/bin/rng.rs2
-rw-r--r--examples/stm32l5/src/bin/usb_ethernet.rs2
-rw-r--r--examples/stm32l5/src/bin/usb_hid_mouse.rs2
-rw-r--r--examples/stm32l5/src/bin/usb_serial.rs2
-rw-r--r--examples/stm32u5/src/bin/usb_serial.rs4
-rw-r--r--tests/stm32/Cargo.toml2
-rw-r--r--tests/stm32/src/common.rs43
24 files changed, 122 insertions, 79 deletions
diff --git a/ci.sh b/ci.sh
index efe98c7af..ffd36a455 100755
--- a/ci.sh
+++ b/ci.sh
@@ -197,6 +197,8 @@ cargo batch \
197 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55rg --out-dir out/tests/stm32wb55rg \ 197 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55rg --out-dir out/tests/stm32wb55rg \
198 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h563zi --out-dir out/tests/stm32h563zi \ 198 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h563zi --out-dir out/tests/stm32h563zi \
199 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585ai --out-dir out/tests/stm32u585ai \ 199 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585ai --out-dir out/tests/stm32u585ai \
200 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u5a5zj --out-dir out/tests/stm32u5a5zj \
201 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wba52cg --out-dir out/tests/stm32wba52cg \
200 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l073rz --out-dir out/tests/stm32l073rz \ 202 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l073rz --out-dir out/tests/stm32l073rz \
201 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l152re --out-dir out/tests/stm32l152re \ 203 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l152re --out-dir out/tests/stm32l152re \
202 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l4a6zg --out-dir out/tests/stm32l4a6zg \ 204 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l4a6zg --out-dir out/tests/stm32l4a6zg \
@@ -215,8 +217,13 @@ cargo batch \
215 217
216rm out/tests/stm32wb55rg/wpan_mac 218rm out/tests/stm32wb55rg/wpan_mac
217rm out/tests/stm32wb55rg/wpan_ble 219rm out/tests/stm32wb55rg/wpan_ble
220
221# unstable, I think it's running out of RAM?
218rm out/tests/stm32f207zg/eth 222rm out/tests/stm32f207zg/eth
219 223
224# doesn't work. Wire in D0-D1 might be bad, or the special IOVDD2 PGx pins.
225rm out/tests/stm32u5a5zj/{gpio,usart*}
226
220if [[ -z "${TELEPROBE_TOKEN-}" ]]; then 227if [[ -z "${TELEPROBE_TOKEN-}" ]]; then
221 echo No teleprobe token found, skipping running HIL tests 228 echo No teleprobe token found, skipping running HIL tests
222 exit 229 exit
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml
index f70e75d44..2d694267a 100644
--- a/embassy-stm32/Cargo.toml
+++ b/embassy-stm32/Cargo.toml
@@ -58,7 +58,7 @@ rand_core = "0.6.3"
58sdio-host = "0.5.0" 58sdio-host = "0.5.0"
59embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true } 59embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true }
60critical-section = "1.1" 60critical-section = "1.1"
61stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-296dd041cce492e3b2b7fb3b8a6c05c9a34a90a1" } 61stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-ee64389697d9234af374a89788aa52bb93d59284" }
62vcell = "0.1.3" 62vcell = "0.1.3"
63bxcan = "0.7.0" 63bxcan = "0.7.0"
64nb = "1.0.0" 64nb = "1.0.0"
@@ -76,7 +76,7 @@ critical-section = { version = "1.1", features = ["std"] }
76[build-dependencies] 76[build-dependencies]
77proc-macro2 = "1.0.36" 77proc-macro2 = "1.0.36"
78quote = "1.0.15" 78quote = "1.0.15"
79stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-296dd041cce492e3b2b7fb3b8a6c05c9a34a90a1", default-features = false, features = ["metadata"]} 79stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-ee64389697d9234af374a89788aa52bb93d59284", default-features = false, features = ["metadata"]}
80 80
81 81
82[features] 82[features]
diff --git a/embassy-stm32/src/rcc/g0.rs b/embassy-stm32/src/rcc/g0.rs
index 85ebd32e1..45d41a4e0 100644
--- a/embassy-stm32/src/rcc/g0.rs
+++ b/embassy-stm32/src/rcc/g0.rs
@@ -1,7 +1,7 @@
1use crate::pac::flash::vals::Latency; 1use crate::pac::flash::vals::Latency;
2use crate::pac::rcc::vals::{self, Sw}; 2use crate::pac::rcc::vals::{self, Sw};
3pub use crate::pac::rcc::vals::{ 3pub use crate::pac::rcc::vals::{
4 Hpre as AHBPrescaler, Hsidiv as HSI16Prescaler, Pllm, Plln, Pllp, Pllq, Pllr, Ppre as APBPrescaler, 4 Hpre as AHBPrescaler, Hsidiv as HSIPrescaler, Pllm, Plln, Pllp, Pllq, Pllr, Ppre as APBPrescaler,
5}; 5};
6use crate::pac::{FLASH, PWR, RCC}; 6use crate::pac::{FLASH, PWR, RCC};
7use crate::rcc::{set_freqs, Clocks}; 7use crate::rcc::{set_freqs, Clocks};
@@ -14,7 +14,7 @@ pub const HSI_FREQ: Hertz = Hertz(16_000_000);
14#[derive(Clone, Copy)] 14#[derive(Clone, Copy)]
15pub enum ClockSrc { 15pub enum ClockSrc {
16 HSE(Hertz), 16 HSE(Hertz),
17 HSI16(HSI16Prescaler), 17 HSI(HSIPrescaler),
18 PLL(PllConfig), 18 PLL(PllConfig),
19 LSI, 19 LSI,
20} 20}
@@ -46,9 +46,9 @@ pub struct PllConfig {
46impl Default for PllConfig { 46impl Default for PllConfig {
47 #[inline] 47 #[inline]
48 fn default() -> PllConfig { 48 fn default() -> PllConfig {
49 // HSI16 / 1 * 8 / 2 = 64 MHz 49 // HSI / 1 * 8 / 2 = 64 MHz
50 PllConfig { 50 PllConfig {
51 source: PllSrc::HSI16, 51 source: PllSrc::HSI,
52 m: Pllm::DIV1, 52 m: Pllm::DIV1,
53 n: Plln::MUL8, 53 n: Plln::MUL8,
54 r: Pllr::DIV2, 54 r: Pllr::DIV2,
@@ -60,7 +60,7 @@ impl Default for PllConfig {
60 60
61#[derive(Clone, Copy, Eq, PartialEq)] 61#[derive(Clone, Copy, Eq, PartialEq)]
62pub enum PllSrc { 62pub enum PllSrc {
63 HSI16, 63 HSI,
64 HSE(Hertz), 64 HSE(Hertz),
65} 65}
66 66
@@ -77,7 +77,7 @@ impl Default for Config {
77 #[inline] 77 #[inline]
78 fn default() -> Config { 78 fn default() -> Config {
79 Config { 79 Config {
80 mux: ClockSrc::HSI16(HSI16Prescaler::DIV1), 80 mux: ClockSrc::HSI(HSIPrescaler::DIV1),
81 ahb_pre: AHBPrescaler::DIV1, 81 ahb_pre: AHBPrescaler::DIV1,
82 apb_pre: APBPrescaler::DIV1, 82 apb_pre: APBPrescaler::DIV1,
83 low_power_run: false, 83 low_power_run: false,
@@ -89,7 +89,7 @@ impl Default for Config {
89impl PllConfig { 89impl PllConfig {
90 pub(crate) fn init(self) -> Hertz { 90 pub(crate) fn init(self) -> Hertz {
91 let (src, input_freq) = match self.source { 91 let (src, input_freq) = match self.source {
92 PllSrc::HSI16 => (vals::Pllsrc::HSI, HSI_FREQ), 92 PllSrc::HSI => (vals::Pllsrc::HSI, HSI_FREQ),
93 PllSrc::HSE(freq) => (vals::Pllsrc::HSE, freq), 93 PllSrc::HSE(freq) => (vals::Pllsrc::HSE, freq),
94 }; 94 };
95 95
@@ -121,7 +121,7 @@ impl PllConfig {
121 // > 3. Change the desired parameter. 121 // > 3. Change the desired parameter.
122 // Enable whichever clock source we're using, and wait for it to become ready 122 // Enable whichever clock source we're using, and wait for it to become ready
123 match self.source { 123 match self.source {
124 PllSrc::HSI16 => { 124 PllSrc::HSI => {
125 RCC.cr().write(|w| w.set_hsion(true)); 125 RCC.cr().write(|w| w.set_hsion(true));
126 while !RCC.cr().read().hsirdy() {} 126 while !RCC.cr().read().hsirdy() {}
127 } 127 }
@@ -167,8 +167,8 @@ impl PllConfig {
167 167
168pub(crate) unsafe fn init(config: Config) { 168pub(crate) unsafe fn init(config: Config) {
169 let (sys_clk, sw) = match config.mux { 169 let (sys_clk, sw) = match config.mux {
170 ClockSrc::HSI16(div) => { 170 ClockSrc::HSI(div) => {
171 // Enable HSI16 171 // Enable HSI
172 RCC.cr().write(|w| { 172 RCC.cr().write(|w| {
173 w.set_hsidiv(div); 173 w.set_hsidiv(div);
174 w.set_hsion(true) 174 w.set_hsion(true)
diff --git a/embassy-stm32/src/rcc/g4.rs b/embassy-stm32/src/rcc/g4.rs
index ba2a5e19c..b14a61973 100644
--- a/embassy-stm32/src/rcc/g4.rs
+++ b/embassy-stm32/src/rcc/g4.rs
@@ -18,14 +18,14 @@ pub const HSI_FREQ: Hertz = Hertz(16_000_000);
18#[derive(Clone, Copy)] 18#[derive(Clone, Copy)]
19pub enum ClockSrc { 19pub enum ClockSrc {
20 HSE(Hertz), 20 HSE(Hertz),
21 HSI16, 21 HSI,
22 PLL, 22 PLL,
23} 23}
24 24
25/// PLL clock input source 25/// PLL clock input source
26#[derive(Clone, Copy, Debug)] 26#[derive(Clone, Copy, Debug)]
27pub enum PllSrc { 27pub enum PllSrc {
28 HSI16, 28 HSI,
29 HSE(Hertz), 29 HSE(Hertz),
30} 30}
31 31
@@ -33,7 +33,7 @@ impl Into<Pllsrc> for PllSrc {
33 fn into(self) -> Pllsrc { 33 fn into(self) -> Pllsrc {
34 match self { 34 match self {
35 PllSrc::HSE(..) => Pllsrc::HSE, 35 PllSrc::HSE(..) => Pllsrc::HSE,
36 PllSrc::HSI16 => Pllsrc::HSI, 36 PllSrc::HSI => Pllsrc::HSI,
37 } 37 }
38 } 38 }
39} 39}
@@ -112,7 +112,7 @@ impl Default for Config {
112 #[inline] 112 #[inline]
113 fn default() -> Config { 113 fn default() -> Config {
114 Config { 114 Config {
115 mux: ClockSrc::HSI16, 115 mux: ClockSrc::HSI,
116 ahb_pre: AHBPrescaler::DIV1, 116 ahb_pre: AHBPrescaler::DIV1,
117 apb1_pre: APBPrescaler::DIV1, 117 apb1_pre: APBPrescaler::DIV1,
118 apb2_pre: APBPrescaler::DIV1, 118 apb2_pre: APBPrescaler::DIV1,
@@ -135,7 +135,7 @@ pub struct PllFreq {
135pub(crate) unsafe fn init(config: Config) { 135pub(crate) unsafe fn init(config: Config) {
136 let pll_freq = config.pll.map(|pll_config| { 136 let pll_freq = config.pll.map(|pll_config| {
137 let src_freq = match pll_config.source { 137 let src_freq = match pll_config.source {
138 PllSrc::HSI16 => { 138 PllSrc::HSI => {
139 RCC.cr().write(|w| w.set_hsion(true)); 139 RCC.cr().write(|w| w.set_hsion(true));
140 while !RCC.cr().read().hsirdy() {} 140 while !RCC.cr().read().hsirdy() {}
141 141
@@ -196,8 +196,8 @@ pub(crate) unsafe fn init(config: Config) {
196 }); 196 });
197 197
198 let (sys_clk, sw) = match config.mux { 198 let (sys_clk, sw) = match config.mux {
199 ClockSrc::HSI16 => { 199 ClockSrc::HSI => {
200 // Enable HSI16 200 // Enable HSI
201 RCC.cr().write(|w| w.set_hsion(true)); 201 RCC.cr().write(|w| w.set_hsion(true));
202 while !RCC.cr().read().hsirdy() {} 202 while !RCC.cr().read().hsirdy() {}
203 203
diff --git a/embassy-stm32/src/rcc/l0l1.rs b/embassy-stm32/src/rcc/l0l1.rs
index f10c5962a..52e9ccb3c 100644
--- a/embassy-stm32/src/rcc/l0l1.rs
+++ b/embassy-stm32/src/rcc/l0l1.rs
@@ -18,20 +18,20 @@ pub enum ClockSrc {
18 MSI(MSIRange), 18 MSI(MSIRange),
19 PLL(PLLSource, PLLMul, PLLDiv), 19 PLL(PLLSource, PLLMul, PLLDiv),
20 HSE(Hertz), 20 HSE(Hertz),
21 HSI16, 21 HSI,
22} 22}
23 23
24/// PLL clock input source 24/// PLL clock input source
25#[derive(Clone, Copy)] 25#[derive(Clone, Copy)]
26pub enum PLLSource { 26pub enum PLLSource {
27 HSI16, 27 HSI,
28 HSE(Hertz), 28 HSE(Hertz),
29} 29}
30 30
31impl From<PLLSource> for Pllsrc { 31impl From<PLLSource> for Pllsrc {
32 fn from(val: PLLSource) -> Pllsrc { 32 fn from(val: PLLSource) -> Pllsrc {
33 match val { 33 match val {
34 PLLSource::HSI16 => Pllsrc::HSI, 34 PLLSource::HSI => Pllsrc::HSI,
35 PLLSource::HSE(_) => Pllsrc::HSE, 35 PLLSource::HSE(_) => Pllsrc::HSE,
36 } 36 }
37 } 37 }
@@ -83,10 +83,10 @@ pub(crate) unsafe fn init(config: Config) {
83 let freq = 32_768 * (1 << (range as u8 + 1)); 83 let freq = 32_768 * (1 << (range as u8 + 1));
84 (Hertz(freq), Sw::MSI) 84 (Hertz(freq), Sw::MSI)
85 } 85 }
86 ClockSrc::HSI16 => { 86 ClockSrc::HSI => {
87 // Enable HSI16 87 // Enable HSI
88 RCC.cr().write(|w| w.set_hsi16on(true)); 88 RCC.cr().write(|w| w.set_hsion(true));
89 while !RCC.cr().read().hsi16rdy() {} 89 while !RCC.cr().read().hsirdy() {}
90 90
91 (HSI_FREQ, Sw::HSI) 91 (HSI_FREQ, Sw::HSI)
92 } 92 }
@@ -105,10 +105,10 @@ pub(crate) unsafe fn init(config: Config) {
105 while !RCC.cr().read().hserdy() {} 105 while !RCC.cr().read().hserdy() {}
106 freq 106 freq
107 } 107 }
108 PLLSource::HSI16 => { 108 PLLSource::HSI => {
109 // Enable HSI 109 // Enable HSI
110 RCC.cr().write(|w| w.set_hsi16on(true)); 110 RCC.cr().write(|w| w.set_hsion(true));
111 while !RCC.cr().read().hsi16rdy() {} 111 while !RCC.cr().read().hsirdy() {}
112 HSI_FREQ 112 HSI_FREQ
113 } 113 }
114 }; 114 };
diff --git a/embassy-stm32/src/rcc/l4l5.rs b/embassy-stm32/src/rcc/l4l5.rs
index e54bfa0e6..8cf284d1e 100644
--- a/embassy-stm32/src/rcc/l4l5.rs
+++ b/embassy-stm32/src/rcc/l4l5.rs
@@ -34,7 +34,7 @@ pub struct Pll {
34pub struct Config { 34pub struct Config {
35 // base clock sources 35 // base clock sources
36 pub msi: Option<MSIRange>, 36 pub msi: Option<MSIRange>,
37 pub hsi16: bool, 37 pub hsi: bool,
38 pub hse: Option<Hertz>, 38 pub hse: Option<Hertz>,
39 #[cfg(not(any(stm32l47x, stm32l48x)))] 39 #[cfg(not(any(stm32l47x, stm32l48x)))]
40 pub hsi48: bool, 40 pub hsi48: bool,
@@ -63,7 +63,7 @@ impl Default for Config {
63 fn default() -> Config { 63 fn default() -> Config {
64 Config { 64 Config {
65 hse: None, 65 hse: None,
66 hsi16: false, 66 hsi: false,
67 msi: Some(MSIRange::RANGE4M), 67 msi: Some(MSIRange::RANGE4M),
68 mux: ClockSrc::MSI, 68 mux: ClockSrc::MSI,
69 ahb_pre: AHBPrescaler::DIV1, 69 ahb_pre: AHBPrescaler::DIV1,
@@ -127,7 +127,7 @@ pub(crate) unsafe fn init(config: Config) {
127 msirange_to_hertz(range) 127 msirange_to_hertz(range)
128 }); 128 });
129 129
130 let hsi16 = config.hsi16.then(|| { 130 let hsi = config.hsi.then(|| {
131 RCC.cr().write(|w| w.set_hsion(true)); 131 RCC.cr().write(|w| w.set_hsion(true));
132 while !RCC.cr().read().hsirdy() {} 132 while !RCC.cr().read().hsirdy() {}
133 133
@@ -179,7 +179,7 @@ pub(crate) unsafe fn init(config: Config) {
179 }), 179 }),
180 }; 180 };
181 181
182 let pll_input = PllInput { hse, hsi16, msi }; 182 let pll_input = PllInput { hse, hsi, msi };
183 let pll = init_pll(PllInstance::Pll, config.pll, &pll_input); 183 let pll = init_pll(PllInstance::Pll, config.pll, &pll_input);
184 let pllsai1 = init_pll(PllInstance::Pllsai1, config.pllsai1, &pll_input); 184 let pllsai1 = init_pll(PllInstance::Pllsai1, config.pllsai1, &pll_input);
185 #[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))] 185 #[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))]
@@ -187,7 +187,7 @@ pub(crate) unsafe fn init(config: Config) {
187 187
188 let sys_clk = match config.mux { 188 let sys_clk = match config.mux {
189 ClockSrc::HSE => hse.unwrap(), 189 ClockSrc::HSE => hse.unwrap(),
190 ClockSrc::HSI => hsi16.unwrap(), 190 ClockSrc::HSI => hsi.unwrap(),
191 ClockSrc::MSI => msi.unwrap(), 191 ClockSrc::MSI => msi.unwrap(),
192 ClockSrc::PLL1_R => pll._r.unwrap(), 192 ClockSrc::PLL1_R => pll._r.unwrap(),
193 }; 193 };
@@ -315,7 +315,7 @@ fn get_equal<T: Eq>(mut iter: impl Iterator<Item = T>) -> Result<Option<T>, ()>
315} 315}
316 316
317struct PllInput { 317struct PllInput {
318 hsi16: Option<Hertz>, 318 hsi: Option<Hertz>,
319 hse: Option<Hertz>, 319 hse: Option<Hertz>,
320 msi: Option<Hertz>, 320 msi: Option<Hertz>,
321} 321}
@@ -358,7 +358,7 @@ fn init_pll(instance: PllInstance, config: Option<Pll>, input: &PllInput) -> Pll
358 let pll_src = match pll.source { 358 let pll_src = match pll.source {
359 PLLSource::NONE => panic!("must not select PLL source as NONE"), 359 PLLSource::NONE => panic!("must not select PLL source as NONE"),
360 PLLSource::HSE => input.hse, 360 PLLSource::HSE => input.hse,
361 PLLSource::HSI => input.hsi16, 361 PLLSource::HSI => input.hsi,
362 PLLSource::MSI => input.msi, 362 PLLSource::MSI => input.msi,
363 }; 363 };
364 364
diff --git a/embassy-stm32/src/rcc/u5.rs b/embassy-stm32/src/rcc/u5.rs
index 62bed8be2..7664557e9 100644
--- a/embassy-stm32/src/rcc/u5.rs
+++ b/embassy-stm32/src/rcc/u5.rs
@@ -10,6 +10,7 @@ pub const HSI_FREQ: Hertz = Hertz(16_000_000);
10pub use crate::pac::pwr::vals::Vos as VoltageScale; 10pub use crate::pac::pwr::vals::Vos as VoltageScale;
11 11
12#[derive(Copy, Clone)] 12#[derive(Copy, Clone)]
13#[allow(non_camel_case_types)]
13pub enum ClockSrc { 14pub enum ClockSrc {
14 /// Use an internal medium speed oscillator (MSIS) as the system clock. 15 /// Use an internal medium speed oscillator (MSIS) as the system clock.
15 MSI(Msirange), 16 MSI(Msirange),
@@ -19,9 +20,9 @@ pub enum ClockSrc {
19 /// never exceed 50 MHz. 20 /// never exceed 50 MHz.
20 HSE(Hertz), 21 HSE(Hertz),
21 /// Use the 16 MHz internal high speed oscillator as the system clock. 22 /// Use the 16 MHz internal high speed oscillator as the system clock.
22 HSI16, 23 HSI,
23 /// Use PLL1 as the system clock. 24 /// Use PLL1 as the system clock.
24 PLL1R(PllConfig), 25 PLL1_R(PllConfig),
25} 26}
26 27
27impl Default for ClockSrc { 28impl Default for ClockSrc {
@@ -53,10 +54,10 @@ pub struct PllConfig {
53} 54}
54 55
55impl PllConfig { 56impl PllConfig {
56 /// A configuration for HSI16 / 1 * 10 / 1 = 160 MHz 57 /// A configuration for HSI / 1 * 10 / 1 = 160 MHz
57 pub const fn hsi16_160mhz() -> Self { 58 pub const fn hsi_160mhz() -> Self {
58 PllConfig { 59 PllConfig {
59 source: PllSrc::HSI16, 60 source: PllSrc::HSI,
60 m: Pllm::DIV1, 61 m: Pllm::DIV1,
61 n: Plln::MUL10, 62 n: Plln::MUL10,
62 r: Plldiv::DIV1, 63 r: Plldiv::DIV1,
@@ -84,7 +85,7 @@ pub enum PllSrc {
84 /// never exceed 50 MHz. 85 /// never exceed 50 MHz.
85 HSE(Hertz), 86 HSE(Hertz),
86 /// Use the 16 MHz internal high speed oscillator as the PLL source. 87 /// Use the 16 MHz internal high speed oscillator as the PLL source.
87 HSI16, 88 HSI,
88} 89}
89 90
90impl Into<Pllsrc> for PllSrc { 91impl Into<Pllsrc> for PllSrc {
@@ -92,7 +93,7 @@ impl Into<Pllsrc> for PllSrc {
92 match self { 93 match self {
93 PllSrc::MSIS(..) => Pllsrc::MSIS, 94 PllSrc::MSIS(..) => Pllsrc::MSIS,
94 PllSrc::HSE(..) => Pllsrc::HSE, 95 PllSrc::HSE(..) => Pllsrc::HSE,
95 PllSrc::HSI16 => Pllsrc::HSI, 96 PllSrc::HSI => Pllsrc::HSI,
96 } 97 }
97 } 98 }
98} 99}
@@ -102,8 +103,8 @@ impl Into<Sw> for ClockSrc {
102 match self { 103 match self {
103 ClockSrc::MSI(..) => Sw::MSIS, 104 ClockSrc::MSI(..) => Sw::MSIS,
104 ClockSrc::HSE(..) => Sw::HSE, 105 ClockSrc::HSE(..) => Sw::HSE,
105 ClockSrc::HSI16 => Sw::HSI, 106 ClockSrc::HSI => Sw::HSI,
106 ClockSrc::PLL1R(..) => Sw::PLL1_R, 107 ClockSrc::PLL1_R(..) => Sw::PLL1_R,
107 } 108 }
108 } 109 }
109} 110}
@@ -125,7 +126,7 @@ pub struct Config {
125} 126}
126 127
127impl Config { 128impl Config {
128 unsafe fn init_hsi16(&self) -> Hertz { 129 unsafe fn init_hsi(&self) -> Hertz {
129 RCC.cr().write(|w| w.set_hsion(true)); 130 RCC.cr().write(|w| w.set_hsion(true));
130 while !RCC.cr().read().hsirdy() {} 131 while !RCC.cr().read().hsirdy() {}
131 132
@@ -211,13 +212,13 @@ pub(crate) unsafe fn init(config: Config) {
211 let sys_clk = match config.mux { 212 let sys_clk = match config.mux {
212 ClockSrc::MSI(range) => config.init_msis(range), 213 ClockSrc::MSI(range) => config.init_msis(range),
213 ClockSrc::HSE(freq) => config.init_hse(freq), 214 ClockSrc::HSE(freq) => config.init_hse(freq),
214 ClockSrc::HSI16 => config.init_hsi16(), 215 ClockSrc::HSI => config.init_hsi(),
215 ClockSrc::PLL1R(pll) => { 216 ClockSrc::PLL1_R(pll) => {
216 // Configure the PLL source 217 // Configure the PLL source
217 let source_clk = match pll.source { 218 let source_clk = match pll.source {
218 PllSrc::MSIS(range) => config.init_msis(range), 219 PllSrc::MSIS(range) => config.init_msis(range),
219 PllSrc::HSE(hertz) => config.init_hse(hertz), 220 PllSrc::HSE(hertz) => config.init_hse(hertz),
220 PllSrc::HSI16 => config.init_hsi16(), 221 PllSrc::HSI => config.init_hsi(),
221 }; 222 };
222 223
223 // Calculate the reference clock, which is the source divided by m 224 // Calculate the reference clock, which is the source divided by m
@@ -292,7 +293,7 @@ pub(crate) unsafe fn init(config: Config) {
292 // Set the prescaler for PWR EPOD 293 // Set the prescaler for PWR EPOD
293 w.set_pllmboost(mboost); 294 w.set_pllmboost(mboost);
294 295
295 // Enable PLL1R output 296 // Enable PLL1_R output
296 w.set_pllren(true); 297 w.set_pllren(true);
297 }); 298 });
298 299
diff --git a/embassy-stm32/src/rcc/wba.rs b/embassy-stm32/src/rcc/wba.rs
index aabf782e7..8925d9606 100644
--- a/embassy-stm32/src/rcc/wba.rs
+++ b/embassy-stm32/src/rcc/wba.rs
@@ -13,20 +13,20 @@ pub use crate::pac::rcc::vals::{Hpre as AHBPrescaler, Ppre as APBPrescaler};
13#[derive(Copy, Clone)] 13#[derive(Copy, Clone)]
14pub enum ClockSrc { 14pub enum ClockSrc {
15 HSE(Hertz), 15 HSE(Hertz),
16 HSI16, 16 HSI,
17} 17}
18 18
19#[derive(Clone, Copy, Debug)] 19#[derive(Clone, Copy, Debug)]
20pub enum PllSrc { 20pub enum PllSrc {
21 HSE(Hertz), 21 HSE(Hertz),
22 HSI16, 22 HSI,
23} 23}
24 24
25impl Into<Pllsrc> for PllSrc { 25impl Into<Pllsrc> for PllSrc {
26 fn into(self) -> Pllsrc { 26 fn into(self) -> Pllsrc {
27 match self { 27 match self {
28 PllSrc::HSE(..) => Pllsrc::HSE, 28 PllSrc::HSE(..) => Pllsrc::HSE,
29 PllSrc::HSI16 => Pllsrc::HSI, 29 PllSrc::HSI => Pllsrc::HSI,
30 } 30 }
31 } 31 }
32} 32}
@@ -35,7 +35,7 @@ impl Into<Sw> for ClockSrc {
35 fn into(self) -> Sw { 35 fn into(self) -> Sw {
36 match self { 36 match self {
37 ClockSrc::HSE(..) => Sw::HSE, 37 ClockSrc::HSE(..) => Sw::HSE,
38 ClockSrc::HSI16 => Sw::HSI, 38 ClockSrc::HSI => Sw::HSI,
39 } 39 }
40 } 40 }
41} 41}
@@ -52,7 +52,7 @@ pub struct Config {
52impl Default for Config { 52impl Default for Config {
53 fn default() -> Self { 53 fn default() -> Self {
54 Self { 54 Self {
55 mux: ClockSrc::HSI16, 55 mux: ClockSrc::HSI,
56 ahb_pre: AHBPrescaler::DIV1, 56 ahb_pre: AHBPrescaler::DIV1,
57 apb1_pre: APBPrescaler::DIV1, 57 apb1_pre: APBPrescaler::DIV1,
58 apb2_pre: APBPrescaler::DIV1, 58 apb2_pre: APBPrescaler::DIV1,
@@ -70,7 +70,7 @@ pub(crate) unsafe fn init(config: Config) {
70 70
71 freq 71 freq
72 } 72 }
73 ClockSrc::HSI16 => { 73 ClockSrc::HSI => {
74 RCC.cr().write(|w| w.set_hsion(true)); 74 RCC.cr().write(|w| w.set_hsion(true));
75 while !RCC.cr().read().hsirdy() {} 75 while !RCC.cr().read().hsirdy() {}
76 76
diff --git a/embassy-stm32/src/rcc/wl.rs b/embassy-stm32/src/rcc/wl.rs
index 401486bbb..4d68b55c2 100644
--- a/embassy-stm32/src/rcc/wl.rs
+++ b/embassy-stm32/src/rcc/wl.rs
@@ -19,7 +19,7 @@ pub const HSE_FREQ: Hertz = Hertz(32_000_000);
19pub enum ClockSrc { 19pub enum ClockSrc {
20 MSI(MSIRange), 20 MSI(MSIRange),
21 HSE, 21 HSE,
22 HSI16, 22 HSI,
23} 23}
24 24
25/// Clocks configutation 25/// Clocks configutation
@@ -50,7 +50,7 @@ impl Default for Config {
50 50
51pub(crate) unsafe fn init(config: Config) { 51pub(crate) unsafe fn init(config: Config) {
52 let (sys_clk, sw, vos) = match config.mux { 52 let (sys_clk, sw, vos) = match config.mux {
53 ClockSrc::HSI16 => (HSI_FREQ, Sw::HSI, VoltageScale::RANGE2), 53 ClockSrc::HSI => (HSI_FREQ, Sw::HSI, VoltageScale::RANGE2),
54 ClockSrc::HSE => (HSE_FREQ, Sw::HSE, VoltageScale::RANGE1), 54 ClockSrc::HSE => (HSE_FREQ, Sw::HSE, VoltageScale::RANGE1),
55 ClockSrc::MSI(range) => (msirange_to_hertz(range), Sw::MSI, msirange_to_vos(range)), 55 ClockSrc::MSI(range) => (msirange_to_hertz(range), Sw::MSI, msirange_to_vos(range)),
56 }; 56 };
@@ -97,8 +97,8 @@ pub(crate) unsafe fn init(config: Config) {
97 while FLASH.acr().read().latency() != ws {} 97 while FLASH.acr().read().latency() != ws {}
98 98
99 match config.mux { 99 match config.mux {
100 ClockSrc::HSI16 => { 100 ClockSrc::HSI => {
101 // Enable HSI16 101 // Enable HSI
102 RCC.cr().write(|w| w.set_hsion(true)); 102 RCC.cr().write(|w| w.set_hsion(true));
103 while !RCC.cr().read().hsirdy() {} 103 while !RCC.cr().read().hsirdy() {}
104 } 104 }
diff --git a/examples/stm32g4/src/bin/adc.rs b/examples/stm32g4/src/bin/adc.rs
index db7f6ecb5..f05733847 100644
--- a/examples/stm32g4/src/bin/adc.rs
+++ b/examples/stm32g4/src/bin/adc.rs
@@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) {
15 let mut config = Config::default(); 15 let mut config = Config::default();
16 16
17 config.rcc.pll = Some(Pll { 17 config.rcc.pll = Some(Pll {
18 source: PllSrc::HSI16, 18 source: PllSrc::HSI,
19 prediv_m: PllM::DIV4, 19 prediv_m: PllM::DIV4,
20 mul_n: PllN::MUL85, 20 mul_n: PllN::MUL85,
21 div_p: None, 21 div_p: None,
diff --git a/examples/stm32g4/src/bin/pll.rs b/examples/stm32g4/src/bin/pll.rs
index 43242647f..90c3f8dce 100644
--- a/examples/stm32g4/src/bin/pll.rs
+++ b/examples/stm32g4/src/bin/pll.rs
@@ -14,7 +14,7 @@ async fn main(_spawner: Spawner) {
14 let mut config = Config::default(); 14 let mut config = Config::default();
15 15
16 config.rcc.pll = Some(Pll { 16 config.rcc.pll = Some(Pll {
17 source: PllSrc::HSI16, 17 source: PllSrc::HSI,
18 prediv_m: PllM::DIV4, 18 prediv_m: PllM::DIV4,
19 mul_n: PllN::MUL85, 19 mul_n: PllN::MUL85,
20 div_p: None, 20 div_p: None,
diff --git a/examples/stm32l0/src/bin/lora_cad.rs b/examples/stm32l0/src/bin/lora_cad.rs
index 987cdba01..5c2b331cc 100644
--- a/examples/stm32l0/src/bin/lora_cad.rs
+++ b/examples/stm32l0/src/bin/lora_cad.rs
@@ -23,7 +23,7 @@ const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriatel
23#[embassy_executor::main] 23#[embassy_executor::main]
24async fn main(_spawner: Spawner) { 24async fn main(_spawner: Spawner) {
25 let mut config = embassy_stm32::Config::default(); 25 let mut config = embassy_stm32::Config::default();
26 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; 26 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI;
27 config.rcc.enable_hsi48 = true; 27 config.rcc.enable_hsi48 = true;
28 let p = embassy_stm32::init(config); 28 let p = embassy_stm32::init(config);
29 29
diff --git a/examples/stm32l0/src/bin/lora_lorawan.rs b/examples/stm32l0/src/bin/lora_lorawan.rs
index 7a93737e1..d44d03d3b 100644
--- a/examples/stm32l0/src/bin/lora_lorawan.rs
+++ b/examples/stm32l0/src/bin/lora_lorawan.rs
@@ -33,7 +33,7 @@ const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set th
33#[embassy_executor::main] 33#[embassy_executor::main]
34async fn main(_spawner: Spawner) { 34async fn main(_spawner: Spawner) {
35 let mut config = embassy_stm32::Config::default(); 35 let mut config = embassy_stm32::Config::default();
36 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; 36 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI;
37 config.rcc.enable_hsi48 = true; 37 config.rcc.enable_hsi48 = true;
38 let p = embassy_stm32::init(config); 38 let p = embassy_stm32::init(config);
39 39
diff --git a/examples/stm32l0/src/bin/lora_p2p_receive.rs b/examples/stm32l0/src/bin/lora_p2p_receive.rs
index 06e2744a4..0478ce1ea 100644
--- a/examples/stm32l0/src/bin/lora_p2p_receive.rs
+++ b/examples/stm32l0/src/bin/lora_p2p_receive.rs
@@ -23,7 +23,7 @@ const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriatel
23#[embassy_executor::main] 23#[embassy_executor::main]
24async fn main(_spawner: Spawner) { 24async fn main(_spawner: Spawner) {
25 let mut config = embassy_stm32::Config::default(); 25 let mut config = embassy_stm32::Config::default();
26 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; 26 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI;
27 config.rcc.enable_hsi48 = true; 27 config.rcc.enable_hsi48 = true;
28 let p = embassy_stm32::init(config); 28 let p = embassy_stm32::init(config);
29 29
diff --git a/examples/stm32l0/src/bin/lora_p2p_send.rs b/examples/stm32l0/src/bin/lora_p2p_send.rs
index 23cc1c6f7..88a836d36 100644
--- a/examples/stm32l0/src/bin/lora_p2p_send.rs
+++ b/examples/stm32l0/src/bin/lora_p2p_send.rs
@@ -23,7 +23,7 @@ const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriatel
23#[embassy_executor::main] 23#[embassy_executor::main]
24async fn main(_spawner: Spawner) { 24async fn main(_spawner: Spawner) {
25 let mut config = embassy_stm32::Config::default(); 25 let mut config = embassy_stm32::Config::default();
26 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; 26 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI;
27 config.rcc.enable_hsi48 = true; 27 config.rcc.enable_hsi48 = true;
28 let p = embassy_stm32::init(config); 28 let p = embassy_stm32::init(config);
29 29
diff --git a/examples/stm32l4/src/bin/rng.rs b/examples/stm32l4/src/bin/rng.rs
index d8a4e825f..553d11c03 100644
--- a/examples/stm32l4/src/bin/rng.rs
+++ b/examples/stm32l4/src/bin/rng.rs
@@ -17,7 +17,7 @@ bind_interrupts!(struct Irqs {
17async fn main(_spawner: Spawner) { 17async fn main(_spawner: Spawner) {
18 let mut config = Config::default(); 18 let mut config = Config::default();
19 config.rcc.mux = ClockSrc::PLL1_R; 19 config.rcc.mux = ClockSrc::PLL1_R;
20 config.rcc.hsi16 = true; 20 config.rcc.hsi = true;
21 config.rcc.pll = Some(Pll { 21 config.rcc.pll = Some(Pll {
22 source: PLLSource::HSI, 22 source: PLLSource::HSI,
23 prediv: PllPreDiv::DIV1, 23 prediv: PllPreDiv::DIV1,
diff --git a/examples/stm32l4/src/bin/usb_serial.rs b/examples/stm32l4/src/bin/usb_serial.rs
index 282476547..15c6f1982 100644
--- a/examples/stm32l4/src/bin/usb_serial.rs
+++ b/examples/stm32l4/src/bin/usb_serial.rs
@@ -25,7 +25,7 @@ async fn main(_spawner: Spawner) {
25 let mut config = Config::default(); 25 let mut config = Config::default();
26 config.rcc.hsi48 = true; 26 config.rcc.hsi48 = true;
27 config.rcc.mux = ClockSrc::PLL1_R; 27 config.rcc.mux = ClockSrc::PLL1_R;
28 config.rcc.hsi16 = true; 28 config.rcc.hsi = true;
29 config.rcc.pll = Some(Pll { 29 config.rcc.pll = Some(Pll {
30 source: PLLSource::HSI, 30 source: PLLSource::HSI,
31 prediv: PllPreDiv::DIV1, 31 prediv: PllPreDiv::DIV1,
diff --git a/examples/stm32l5/src/bin/rng.rs b/examples/stm32l5/src/bin/rng.rs
index b57f438ff..b9d4cd255 100644
--- a/examples/stm32l5/src/bin/rng.rs
+++ b/examples/stm32l5/src/bin/rng.rs
@@ -16,7 +16,7 @@ bind_interrupts!(struct Irqs {
16#[embassy_executor::main] 16#[embassy_executor::main]
17async fn main(_spawner: Spawner) { 17async fn main(_spawner: Spawner) {
18 let mut config = Config::default(); 18 let mut config = Config::default();
19 config.rcc.hsi16 = true; 19 config.rcc.hsi = true;
20 config.rcc.mux = ClockSrc::PLL1_R; 20 config.rcc.mux = ClockSrc::PLL1_R;
21 config.rcc.pll = Some(Pll { 21 config.rcc.pll = Some(Pll {
22 // 64Mhz clock (16 / 1 * 8 / 2) 22 // 64Mhz clock (16 / 1 * 8 / 2)
diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs
index bbe44642b..f5b3ca34c 100644
--- a/examples/stm32l5/src/bin/usb_ethernet.rs
+++ b/examples/stm32l5/src/bin/usb_ethernet.rs
@@ -45,7 +45,7 @@ async fn net_task(stack: &'static Stack<Device<'static, MTU>>) -> ! {
45#[embassy_executor::main] 45#[embassy_executor::main]
46async fn main(spawner: Spawner) { 46async fn main(spawner: Spawner) {
47 let mut config = Config::default(); 47 let mut config = Config::default();
48 config.rcc.hsi16 = true; 48 config.rcc.hsi = true;
49 config.rcc.mux = ClockSrc::PLL1_R; 49 config.rcc.mux = ClockSrc::PLL1_R;
50 config.rcc.pll = Some(Pll { 50 config.rcc.pll = Some(Pll {
51 // 80Mhz clock (16 / 1 * 10 / 2) 51 // 80Mhz clock (16 / 1 * 10 / 2)
diff --git a/examples/stm32l5/src/bin/usb_hid_mouse.rs b/examples/stm32l5/src/bin/usb_hid_mouse.rs
index 44e29ee9c..bec3d5e4e 100644
--- a/examples/stm32l5/src/bin/usb_hid_mouse.rs
+++ b/examples/stm32l5/src/bin/usb_hid_mouse.rs
@@ -22,7 +22,7 @@ bind_interrupts!(struct Irqs {
22#[embassy_executor::main] 22#[embassy_executor::main]
23async fn main(_spawner: Spawner) { 23async fn main(_spawner: Spawner) {
24 let mut config = Config::default(); 24 let mut config = Config::default();
25 config.rcc.hsi16 = true; 25 config.rcc.hsi = true;
26 config.rcc.mux = ClockSrc::PLL1_R; 26 config.rcc.mux = ClockSrc::PLL1_R;
27 config.rcc.pll = Some(Pll { 27 config.rcc.pll = Some(Pll {
28 // 80Mhz clock (16 / 1 * 10 / 2) 28 // 80Mhz clock (16 / 1 * 10 / 2)
diff --git a/examples/stm32l5/src/bin/usb_serial.rs b/examples/stm32l5/src/bin/usb_serial.rs
index 612b891ac..ff1154f92 100644
--- a/examples/stm32l5/src/bin/usb_serial.rs
+++ b/examples/stm32l5/src/bin/usb_serial.rs
@@ -20,7 +20,7 @@ bind_interrupts!(struct Irqs {
20#[embassy_executor::main] 20#[embassy_executor::main]
21async fn main(_spawner: Spawner) { 21async fn main(_spawner: Spawner) {
22 let mut config = Config::default(); 22 let mut config = Config::default();
23 config.rcc.hsi16 = true; 23 config.rcc.hsi = true;
24 config.rcc.mux = ClockSrc::PLL1_R; 24 config.rcc.mux = ClockSrc::PLL1_R;
25 config.rcc.pll = Some(Pll { 25 config.rcc.pll = Some(Pll {
26 // 80Mhz clock (16 / 1 * 10 / 2) 26 // 80Mhz clock (16 / 1 * 10 / 2)
diff --git a/examples/stm32u5/src/bin/usb_serial.rs b/examples/stm32u5/src/bin/usb_serial.rs
index 9b2adb0ac..f59f623b3 100644
--- a/examples/stm32u5/src/bin/usb_serial.rs
+++ b/examples/stm32u5/src/bin/usb_serial.rs
@@ -23,8 +23,8 @@ async fn main(_spawner: Spawner) {
23 info!("Hello World!"); 23 info!("Hello World!");
24 24
25 let mut config = Config::default(); 25 let mut config = Config::default();
26 config.rcc.mux = ClockSrc::PLL1R(PllConfig { 26 config.rcc.mux = ClockSrc::PLL1_R(PllConfig {
27 source: PllSrc::HSI16, 27 source: PllSrc::HSI,
28 m: Pllm::DIV2, 28 m: Pllm::DIV2,
29 n: Plln::MUL10, 29 n: Plln::MUL10,
30 r: Plldiv::DIV1, 30 r: Plldiv::DIV1,
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml
index 48598ec2d..c6a50e2c5 100644
--- a/tests/stm32/Cargo.toml
+++ b/tests/stm32/Cargo.toml
@@ -17,6 +17,8 @@ stm32h7a3zi = ["embassy-stm32/stm32h7a3zi", "not-gpdma", "rng"]
17stm32wb55rg = ["embassy-stm32/stm32wb55rg", "chrono", "not-gpdma", "ble", "mac" , "rng"] 17stm32wb55rg = ["embassy-stm32/stm32wb55rg", "chrono", "not-gpdma", "ble", "mac" , "rng"]
18stm32h563zi = ["embassy-stm32/stm32h563zi", "chrono", "eth", "rng"] 18stm32h563zi = ["embassy-stm32/stm32h563zi", "chrono", "eth", "rng"]
19stm32u585ai = ["embassy-stm32/stm32u585ai", "chrono", "rng"] 19stm32u585ai = ["embassy-stm32/stm32u585ai", "chrono", "rng"]
20stm32u5a5zj = ["embassy-stm32/stm32u5a5zj", "chrono", "rng"]
21stm32wba52cg = ["embassy-stm32/stm32wba52cg", "chrono", "rng"]
20stm32l073rz = ["embassy-stm32/stm32l073rz", "not-gpdma", "rng"] 22stm32l073rz = ["embassy-stm32/stm32l073rz", "not-gpdma", "rng"]
21stm32l152re = ["embassy-stm32/stm32l152re", "chrono", "not-gpdma"] 23stm32l152re = ["embassy-stm32/stm32l152re", "chrono", "not-gpdma"]
22stm32l4a6zg = ["embassy-stm32/stm32l4a6zg", "chrono", "not-gpdma", "rng"] 24stm32l4a6zg = ["embassy-stm32/stm32l4a6zg", "chrono", "not-gpdma", "rng"]
diff --git a/tests/stm32/src/common.rs b/tests/stm32/src/common.rs
index a0ccfe3a4..0a70e6a7e 100644
--- a/tests/stm32/src/common.rs
+++ b/tests/stm32/src/common.rs
@@ -24,6 +24,8 @@ teleprobe_meta::target!(b"nucleo-stm32h753zi");
24teleprobe_meta::target!(b"nucleo-stm32h7a3zi"); 24teleprobe_meta::target!(b"nucleo-stm32h7a3zi");
25#[cfg(feature = "stm32u585ai")] 25#[cfg(feature = "stm32u585ai")]
26teleprobe_meta::target!(b"iot-stm32u585ai"); 26teleprobe_meta::target!(b"iot-stm32u585ai");
27#[cfg(feature = "stm32u5a5zj")]
28teleprobe_meta::target!(b"nucleo-stm32u5a5zj");
27#[cfg(feature = "stm32h563zi")] 29#[cfg(feature = "stm32h563zi")]
28teleprobe_meta::target!(b"nucleo-stm32h563zi"); 30teleprobe_meta::target!(b"nucleo-stm32h563zi");
29#[cfg(feature = "stm32c031c6")] 31#[cfg(feature = "stm32c031c6")]
@@ -48,6 +50,8 @@ teleprobe_meta::target!(b"nucleo-stm32f303ze");
48teleprobe_meta::target!(b"nucleo-stm32l496zg"); 50teleprobe_meta::target!(b"nucleo-stm32l496zg");
49#[cfg(feature = "stm32wl55jc")] 51#[cfg(feature = "stm32wl55jc")]
50teleprobe_meta::target!(b"nucleo-stm32wl55jc"); 52teleprobe_meta::target!(b"nucleo-stm32wl55jc");
53#[cfg(feature = "stm32wba52cg")]
54teleprobe_meta::target!(b"nucleo-stm32wba52cg");
51 55
52macro_rules! define_peris { 56macro_rules! define_peris {
53 ($($name:ident = $peri:ident,)* $(@irq $irq_name:ident = $irq_code:tt,)*) => { 57 ($($name:ident = $peri:ident,)* $(@irq $irq_name:ident = $irq_code:tt,)*) => {
@@ -127,6 +131,12 @@ define_peris!(
127 SPI = SPI1, SPI_SCK = PE13, SPI_MOSI = PE15, SPI_MISO = PE14, SPI_TX_DMA = GPDMA1_CH0, SPI_RX_DMA = GPDMA1_CH1, 131 SPI = SPI1, SPI_SCK = PE13, SPI_MOSI = PE15, SPI_MISO = PE14, SPI_TX_DMA = GPDMA1_CH0, SPI_RX_DMA = GPDMA1_CH1,
128 @irq UART = {USART3 => embassy_stm32::usart::InterruptHandler<embassy_stm32::peripherals::USART3>;}, 132 @irq UART = {USART3 => embassy_stm32::usart::InterruptHandler<embassy_stm32::peripherals::USART3>;},
129); 133);
134#[cfg(feature = "stm32u5a5zj")]
135define_peris!(
136 UART = LPUART1, UART_TX = PG7, UART_RX = PG8, UART_TX_DMA = GPDMA1_CH0, UART_RX_DMA = GPDMA1_CH1,
137 SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = GPDMA1_CH0, SPI_RX_DMA = GPDMA1_CH1,
138 @irq UART = {LPUART1 => embassy_stm32::usart::InterruptHandler<embassy_stm32::peripherals::LPUART1>;},
139);
130#[cfg(feature = "stm32h563zi")] 140#[cfg(feature = "stm32h563zi")]
131define_peris!( 141define_peris!(
132 UART = LPUART1, UART_TX = PB6, UART_RX = PB7, UART_TX_DMA = GPDMA1_CH0, UART_RX_DMA = GPDMA1_CH1, 142 UART = LPUART1, UART_TX = PB6, UART_RX = PB7, UART_TX_DMA = GPDMA1_CH0, UART_RX_DMA = GPDMA1_CH1,
@@ -199,8 +209,21 @@ define_peris!(
199 SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA1_CH3, SPI_RX_DMA = DMA1_CH2, 209 SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA1_CH3, SPI_RX_DMA = DMA1_CH2,
200 @irq UART = {USART1 => embassy_stm32::usart::InterruptHandler<embassy_stm32::peripherals::USART1>;}, 210 @irq UART = {USART1 => embassy_stm32::usart::InterruptHandler<embassy_stm32::peripherals::USART1>;},
201); 211);
212#[cfg(feature = "stm32wba52cg")]
213define_peris!(
214 UART = LPUART1, UART_TX = PB5, UART_RX = PA10, UART_TX_DMA = GPDMA1_CH0, UART_RX_DMA = GPDMA1_CH1,
215 SPI = SPI1, SPI_SCK = PB4, SPI_MOSI = PA15, SPI_MISO = PB3, SPI_TX_DMA = GPDMA1_CH0, SPI_RX_DMA = GPDMA1_CH1,
216 @irq UART = {LPUART1 => embassy_stm32::usart::InterruptHandler<embassy_stm32::peripherals::LPUART1>;},
217);
202 218
203pub fn config() -> Config { 219pub fn config() -> Config {
220 // Setting this bit is mandatory to use PG[15:2].
221 #[cfg(feature = "stm32u5a5zj")]
222 embassy_stm32::pac::PWR.svmcr().modify(|w| {
223 w.set_io2sv(true);
224 w.set_io2vmen(true);
225 });
226
204 #[allow(unused_mut)] 227 #[allow(unused_mut)]
205 let mut config = Config::default(); 228 let mut config = Config::default();
206 229
@@ -365,7 +388,7 @@ pub fn config() -> Config {
365 { 388 {
366 use embassy_stm32::rcc::*; 389 use embassy_stm32::rcc::*;
367 config.rcc.mux = ClockSrc::PLL1_R; 390 config.rcc.mux = ClockSrc::PLL1_R;
368 config.rcc.hsi16 = true; 391 config.rcc.hsi = true;
369 config.rcc.pll = Some(Pll { 392 config.rcc.pll = Some(Pll {
370 source: PLLSource::HSI, 393 source: PLLSource::HSI,
371 prediv: PllPreDiv::DIV1, 394 prediv: PllPreDiv::DIV1,
@@ -388,7 +411,7 @@ pub fn config() -> Config {
388 #[cfg(any(feature = "stm32l552ze"))] 411 #[cfg(any(feature = "stm32l552ze"))]
389 { 412 {
390 use embassy_stm32::rcc::*; 413 use embassy_stm32::rcc::*;
391 config.rcc.hsi16 = true; 414 config.rcc.hsi = true;
392 config.rcc.mux = ClockSrc::PLL1_R; 415 config.rcc.mux = ClockSrc::PLL1_R;
393 config.rcc.pll = Some(Pll { 416 config.rcc.pll = Some(Pll {
394 // 110Mhz clock (16 / 4 * 55 / 2) 417 // 110Mhz clock (16 / 4 * 55 / 2)
@@ -401,18 +424,28 @@ pub fn config() -> Config {
401 }); 424 });
402 } 425 }
403 426
404 #[cfg(feature = "stm32u585ai")] 427 #[cfg(any(feature = "stm32u585ai", feature = "stm32u5a5zj"))]
405 { 428 {
406 use embassy_stm32::rcc::*; 429 use embassy_stm32::rcc::*;
407 config.rcc.mux = ClockSrc::MSI(Msirange::RANGE_48MHZ); 430 config.rcc.mux = ClockSrc::MSI(Msirange::RANGE_48MHZ);
408 } 431 }
409 432
433 #[cfg(feature = "stm32wba52cg")]
434 {
435 use embassy_stm32::rcc::*;
436 config.rcc.mux = ClockSrc::HSI;
437
438 embassy_stm32::pac::RCC.ccipr2().write(|w| {
439 w.set_rngsel(embassy_stm32::pac::rcc::vals::Rngsel::HSI);
440 });
441 }
442
410 #[cfg(feature = "stm32l073rz")] 443 #[cfg(feature = "stm32l073rz")]
411 { 444 {
412 use embassy_stm32::rcc::*; 445 use embassy_stm32::rcc::*;
413 config.rcc.mux = ClockSrc::PLL( 446 config.rcc.mux = ClockSrc::PLL(
414 // 32Mhz clock (16 * 4 / 2) 447 // 32Mhz clock (16 * 4 / 2)
415 PLLSource::HSI16, 448 PLLSource::HSI,
416 PLLMul::MUL4, 449 PLLMul::MUL4,
417 PLLDiv::DIV2, 450 PLLDiv::DIV2,
418 ); 451 );
@@ -423,7 +456,7 @@ pub fn config() -> Config {
423 use embassy_stm32::rcc::*; 456 use embassy_stm32::rcc::*;
424 config.rcc.mux = ClockSrc::PLL( 457 config.rcc.mux = ClockSrc::PLL(
425 // 32Mhz clock (16 * 4 / 2) 458 // 32Mhz clock (16 * 4 / 2)
426 PLLSource::HSI16, 459 PLLSource::HSI,
427 PLLMul::MUL4, 460 PLLMul::MUL4,
428 PLLDiv::DIV2, 461 PLLDiv::DIV2,
429 ); 462 );