diff options
| author | Ulf Lilleengen <[email protected]> | 2024-08-05 13:18:45 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-08-05 13:18:45 +0000 |
| commit | 059c7b582c29dd04b6f18d9fb1f4c091c1ab6c7d (patch) | |
| tree | daf5399b53f9853d6ef2c338743a9537873670fa | |
| parent | a94f197950189f9c835646186dfe78e6583bba8b (diff) | |
| parent | e322732fdba282f4150a186aed606b88714921fe (diff) | |
Merge pull request #3158 from diondokter/stm-dualcore
Stm dualcore better init
55 files changed, 737 insertions, 108 deletions
| @@ -179,7 +179,7 @@ cargo batch \ | |||
| 179 | --- build --release --manifest-path embassy-boot-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns \ | 179 | --- build --release --manifest-path embassy-boot-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns \ |
| 180 | --- build --release --manifest-path embassy-boot-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9120-ns \ | 180 | --- build --release --manifest-path embassy-boot-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9120-ns \ |
| 181 | --- build --release --manifest-path embassy-boot-rp/Cargo.toml --target thumbv6m-none-eabi \ | 181 | --- build --release --manifest-path embassy-boot-rp/Cargo.toml --target thumbv6m-none-eabi \ |
| 182 | --- build --release --manifest-path embassy-boot-stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \ | 182 | --- build --release --manifest-path embassy-boot-stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32l496zg \ |
| 183 | --- build --release --manifest-path docs/examples/basic/Cargo.toml --target thumbv7em-none-eabi \ | 183 | --- build --release --manifest-path docs/examples/basic/Cargo.toml --target thumbv7em-none-eabi \ |
| 184 | --- build --release --manifest-path docs/examples/layer-by-layer/blinky-pac/Cargo.toml --target thumbv7em-none-eabi \ | 184 | --- build --release --manifest-path docs/examples/layer-by-layer/blinky-pac/Cargo.toml --target thumbv7em-none-eabi \ |
| 185 | --- build --release --manifest-path docs/examples/layer-by-layer/blinky-hal/Cargo.toml --target thumbv7em-none-eabi \ | 185 | --- build --release --manifest-path docs/examples/layer-by-layer/blinky-hal/Cargo.toml --target thumbv7em-none-eabi \ |
| @@ -207,6 +207,8 @@ cargo batch \ | |||
| 207 | --- build --release --manifest-path examples/stm32h5/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/stm32h5 \ | 207 | --- build --release --manifest-path examples/stm32h5/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/stm32h5 \ |
| 208 | --- build --release --manifest-path examples/stm32h7/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32h7 \ | 208 | --- build --release --manifest-path examples/stm32h7/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32h7 \ |
| 209 | --- build --release --manifest-path examples/stm32h735/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32h735 \ | 209 | --- build --release --manifest-path examples/stm32h735/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32h735 \ |
| 210 | --- build --release --manifest-path examples/stm32h755cm4/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32h755cm4 \ | ||
| 211 | --- build --release --manifest-path examples/stm32h755cm7/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32h755cm7 \ | ||
| 210 | --- build --release --manifest-path examples/stm32h7rs/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32h7rs \ | 212 | --- build --release --manifest-path examples/stm32h7rs/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32h7rs \ |
| 211 | --- build --release --manifest-path examples/stm32l0/Cargo.toml --target thumbv6m-none-eabi --out-dir out/examples/stm32l0 \ | 213 | --- build --release --manifest-path examples/stm32l0/Cargo.toml --target thumbv6m-none-eabi --out-dir out/examples/stm32l0 \ |
| 212 | --- build --release --manifest-path examples/stm32l1/Cargo.toml --target thumbv7m-none-eabi --out-dir out/examples/stm32l1 \ | 214 | --- build --release --manifest-path examples/stm32l1/Cargo.toml --target thumbv7m-none-eabi --out-dir out/examples/stm32l1 \ |
| @@ -233,9 +235,9 @@ cargo batch \ | |||
| 233 | --- build --release --manifest-path examples/boot/bootloader/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns \ | 235 | --- build --release --manifest-path examples/boot/bootloader/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns \ |
| 234 | --- build --release --manifest-path examples/boot/bootloader/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9120-ns \ | 236 | --- build --release --manifest-path examples/boot/bootloader/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9120-ns \ |
| 235 | --- build --release --manifest-path examples/boot/bootloader/rp/Cargo.toml --target thumbv6m-none-eabi \ | 237 | --- build --release --manifest-path examples/boot/bootloader/rp/Cargo.toml --target thumbv6m-none-eabi \ |
| 236 | --- build --release --manifest-path examples/boot/bootloader/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \ | 238 | --- build --release --manifest-path examples/boot/bootloader/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32l496zg \ |
| 237 | --- build --release --manifest-path examples/boot/bootloader/stm32wb-dfu/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wb55rg \ | 239 | --- build --release --manifest-path examples/boot/bootloader/stm32wb-dfu/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wb55rg \ |
| 238 | --- build --release --manifest-path examples/boot/bootloader/stm32-dual-bank/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32h747xi-cm7 \ | 240 | --- build --release --manifest-path examples/boot/bootloader/stm32-dual-bank/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32h743zi \ |
| 239 | --- build --release --manifest-path examples/wasm/Cargo.toml --target wasm32-unknown-unknown --out-dir out/examples/wasm \ | 241 | --- build --release --manifest-path examples/wasm/Cargo.toml --target wasm32-unknown-unknown --out-dir out/examples/wasm \ |
| 240 | --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f103c8 --out-dir out/tests/stm32f103c8 \ | 242 | --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f103c8 --out-dir out/tests/stm32f103c8 \ |
| 241 | --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi --out-dir out/tests/stm32f429zi \ | 243 | --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi --out-dir out/tests/stm32f429zi \ |
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index cd120c78d..ac9e9644c 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml | |||
| @@ -80,7 +80,7 @@ stm32-fmc = "0.3.0" | |||
| 80 | cfg-if = "1.0.0" | 80 | cfg-if = "1.0.0" |
| 81 | embedded-io = { version = "0.6.0" } | 81 | embedded-io = { version = "0.6.0" } |
| 82 | embedded-io-async = { version = "0.6.1" } | 82 | embedded-io-async = { version = "0.6.1" } |
| 83 | chrono = { version = "^0.4", default-features = false, optional = true} | 83 | chrono = { version = "^0.4", default-features = false, optional = true } |
| 84 | bit_field = "0.10.2" | 84 | bit_field = "0.10.2" |
| 85 | document-features = "0.2.7" | 85 | document-features = "0.2.7" |
| 86 | 86 | ||
| @@ -181,6 +181,9 @@ split-pc3 = ["_split-pins-enabled"] | |||
| 181 | ## internal use only | 181 | ## internal use only |
| 182 | _split-pins-enabled = [] | 182 | _split-pins-enabled = [] |
| 183 | 183 | ||
| 184 | ## internal use only | ||
| 185 | _dual-core = [] | ||
| 186 | |||
| 184 | #! ## Chip-selection features | 187 | #! ## Chip-selection features |
| 185 | #! Select your chip by specifying the model as a feature, e.g. `stm32c011d6`. | 188 | #! Select your chip by specifying the model as a feature, e.g. `stm32c011d6`. |
| 186 | #! Check the `Cargo.toml` for the latest list of supported chips. | 189 | #! Check the `Cargo.toml` for the latest list of supported chips. |
| @@ -1004,40 +1007,40 @@ stm32h743xg = [ "stm32-metapac/stm32h743xg" ] | |||
| 1004 | stm32h743xi = [ "stm32-metapac/stm32h743xi" ] | 1007 | stm32h743xi = [ "stm32-metapac/stm32h743xi" ] |
| 1005 | stm32h743zg = [ "stm32-metapac/stm32h743zg" ] | 1008 | stm32h743zg = [ "stm32-metapac/stm32h743zg" ] |
| 1006 | stm32h743zi = [ "stm32-metapac/stm32h743zi" ] | 1009 | stm32h743zi = [ "stm32-metapac/stm32h743zi" ] |
| 1007 | stm32h745bg-cm7 = [ "stm32-metapac/stm32h745bg-cm7" ] | 1010 | stm32h745bg-cm7 = [ "stm32-metapac/stm32h745bg-cm7", "_dual-core" ] |
| 1008 | stm32h745bg-cm4 = [ "stm32-metapac/stm32h745bg-cm4" ] | 1011 | stm32h745bg-cm4 = [ "stm32-metapac/stm32h745bg-cm4", "_dual-core" ] |
| 1009 | stm32h745bi-cm7 = [ "stm32-metapac/stm32h745bi-cm7" ] | 1012 | stm32h745bi-cm7 = [ "stm32-metapac/stm32h745bi-cm7", "_dual-core" ] |
| 1010 | stm32h745bi-cm4 = [ "stm32-metapac/stm32h745bi-cm4" ] | 1013 | stm32h745bi-cm4 = [ "stm32-metapac/stm32h745bi-cm4", "_dual-core" ] |
| 1011 | stm32h745ig-cm7 = [ "stm32-metapac/stm32h745ig-cm7" ] | 1014 | stm32h745ig-cm7 = [ "stm32-metapac/stm32h745ig-cm7", "_dual-core" ] |
| 1012 | stm32h745ig-cm4 = [ "stm32-metapac/stm32h745ig-cm4" ] | 1015 | stm32h745ig-cm4 = [ "stm32-metapac/stm32h745ig-cm4", "_dual-core" ] |
| 1013 | stm32h745ii-cm7 = [ "stm32-metapac/stm32h745ii-cm7" ] | 1016 | stm32h745ii-cm7 = [ "stm32-metapac/stm32h745ii-cm7", "_dual-core" ] |
| 1014 | stm32h745ii-cm4 = [ "stm32-metapac/stm32h745ii-cm4" ] | 1017 | stm32h745ii-cm4 = [ "stm32-metapac/stm32h745ii-cm4", "_dual-core" ] |
| 1015 | stm32h745xg-cm7 = [ "stm32-metapac/stm32h745xg-cm7" ] | 1018 | stm32h745xg-cm7 = [ "stm32-metapac/stm32h745xg-cm7", "_dual-core" ] |
| 1016 | stm32h745xg-cm4 = [ "stm32-metapac/stm32h745xg-cm4" ] | 1019 | stm32h745xg-cm4 = [ "stm32-metapac/stm32h745xg-cm4", "_dual-core" ] |
| 1017 | stm32h745xi-cm7 = [ "stm32-metapac/stm32h745xi-cm7" ] | 1020 | stm32h745xi-cm7 = [ "stm32-metapac/stm32h745xi-cm7", "_dual-core" ] |
| 1018 | stm32h745xi-cm4 = [ "stm32-metapac/stm32h745xi-cm4" ] | 1021 | stm32h745xi-cm4 = [ "stm32-metapac/stm32h745xi-cm4", "_dual-core" ] |
| 1019 | stm32h745zg-cm7 = [ "stm32-metapac/stm32h745zg-cm7" ] | 1022 | stm32h745zg-cm7 = [ "stm32-metapac/stm32h745zg-cm7", "_dual-core" ] |
| 1020 | stm32h745zg-cm4 = [ "stm32-metapac/stm32h745zg-cm4" ] | 1023 | stm32h745zg-cm4 = [ "stm32-metapac/stm32h745zg-cm4", "_dual-core" ] |
| 1021 | stm32h745zi-cm7 = [ "stm32-metapac/stm32h745zi-cm7" ] | 1024 | stm32h745zi-cm7 = [ "stm32-metapac/stm32h745zi-cm7", "_dual-core" ] |
| 1022 | stm32h745zi-cm4 = [ "stm32-metapac/stm32h745zi-cm4" ] | 1025 | stm32h745zi-cm4 = [ "stm32-metapac/stm32h745zi-cm4", "_dual-core" ] |
| 1023 | stm32h747ag-cm7 = [ "stm32-metapac/stm32h747ag-cm7" ] | 1026 | stm32h747ag-cm7 = [ "stm32-metapac/stm32h747ag-cm7", "_dual-core" ] |
| 1024 | stm32h747ag-cm4 = [ "stm32-metapac/stm32h747ag-cm4" ] | 1027 | stm32h747ag-cm4 = [ "stm32-metapac/stm32h747ag-cm4", "_dual-core" ] |
| 1025 | stm32h747ai-cm7 = [ "stm32-metapac/stm32h747ai-cm7" ] | 1028 | stm32h747ai-cm7 = [ "stm32-metapac/stm32h747ai-cm7", "_dual-core" ] |
| 1026 | stm32h747ai-cm4 = [ "stm32-metapac/stm32h747ai-cm4" ] | 1029 | stm32h747ai-cm4 = [ "stm32-metapac/stm32h747ai-cm4", "_dual-core" ] |
| 1027 | stm32h747bg-cm7 = [ "stm32-metapac/stm32h747bg-cm7" ] | 1030 | stm32h747bg-cm7 = [ "stm32-metapac/stm32h747bg-cm7", "_dual-core" ] |
| 1028 | stm32h747bg-cm4 = [ "stm32-metapac/stm32h747bg-cm4" ] | 1031 | stm32h747bg-cm4 = [ "stm32-metapac/stm32h747bg-cm4", "_dual-core" ] |
| 1029 | stm32h747bi-cm7 = [ "stm32-metapac/stm32h747bi-cm7" ] | 1032 | stm32h747bi-cm7 = [ "stm32-metapac/stm32h747bi-cm7", "_dual-core" ] |
| 1030 | stm32h747bi-cm4 = [ "stm32-metapac/stm32h747bi-cm4" ] | 1033 | stm32h747bi-cm4 = [ "stm32-metapac/stm32h747bi-cm4", "_dual-core" ] |
| 1031 | stm32h747ig-cm7 = [ "stm32-metapac/stm32h747ig-cm7" ] | 1034 | stm32h747ig-cm7 = [ "stm32-metapac/stm32h747ig-cm7", "_dual-core" ] |
| 1032 | stm32h747ig-cm4 = [ "stm32-metapac/stm32h747ig-cm4" ] | 1035 | stm32h747ig-cm4 = [ "stm32-metapac/stm32h747ig-cm4", "_dual-core" ] |
| 1033 | stm32h747ii-cm7 = [ "stm32-metapac/stm32h747ii-cm7" ] | 1036 | stm32h747ii-cm7 = [ "stm32-metapac/stm32h747ii-cm7", "_dual-core" ] |
| 1034 | stm32h747ii-cm4 = [ "stm32-metapac/stm32h747ii-cm4" ] | 1037 | stm32h747ii-cm4 = [ "stm32-metapac/stm32h747ii-cm4", "_dual-core" ] |
| 1035 | stm32h747xg-cm7 = [ "stm32-metapac/stm32h747xg-cm7" ] | 1038 | stm32h747xg-cm7 = [ "stm32-metapac/stm32h747xg-cm7", "_dual-core" ] |
| 1036 | stm32h747xg-cm4 = [ "stm32-metapac/stm32h747xg-cm4" ] | 1039 | stm32h747xg-cm4 = [ "stm32-metapac/stm32h747xg-cm4", "_dual-core" ] |
| 1037 | stm32h747xi-cm7 = [ "stm32-metapac/stm32h747xi-cm7" ] | 1040 | stm32h747xi-cm7 = [ "stm32-metapac/stm32h747xi-cm7", "_dual-core" ] |
| 1038 | stm32h747xi-cm4 = [ "stm32-metapac/stm32h747xi-cm4" ] | 1041 | stm32h747xi-cm4 = [ "stm32-metapac/stm32h747xi-cm4", "_dual-core" ] |
| 1039 | stm32h747zi-cm7 = [ "stm32-metapac/stm32h747zi-cm7" ] | 1042 | stm32h747zi-cm7 = [ "stm32-metapac/stm32h747zi-cm7", "_dual-core" ] |
| 1040 | stm32h747zi-cm4 = [ "stm32-metapac/stm32h747zi-cm4" ] | 1043 | stm32h747zi-cm4 = [ "stm32-metapac/stm32h747zi-cm4", "_dual-core" ] |
| 1041 | stm32h750ib = [ "stm32-metapac/stm32h750ib" ] | 1044 | stm32h750ib = [ "stm32-metapac/stm32h750ib" ] |
| 1042 | stm32h750vb = [ "stm32-metapac/stm32h750vb" ] | 1045 | stm32h750vb = [ "stm32-metapac/stm32h750vb" ] |
| 1043 | stm32h750xb = [ "stm32-metapac/stm32h750xb" ] | 1046 | stm32h750xb = [ "stm32-metapac/stm32h750xb" ] |
| @@ -1048,24 +1051,24 @@ stm32h753ii = [ "stm32-metapac/stm32h753ii" ] | |||
| 1048 | stm32h753vi = [ "stm32-metapac/stm32h753vi" ] | 1051 | stm32h753vi = [ "stm32-metapac/stm32h753vi" ] |
| 1049 | stm32h753xi = [ "stm32-metapac/stm32h753xi" ] | 1052 | stm32h753xi = [ "stm32-metapac/stm32h753xi" ] |
| 1050 | stm32h753zi = [ "stm32-metapac/stm32h753zi" ] | 1053 | stm32h753zi = [ "stm32-metapac/stm32h753zi" ] |
| 1051 | stm32h755bi-cm7 = [ "stm32-metapac/stm32h755bi-cm7" ] | 1054 | stm32h755bi-cm7 = [ "stm32-metapac/stm32h755bi-cm7", "_dual-core" ] |
| 1052 | stm32h755bi-cm4 = [ "stm32-metapac/stm32h755bi-cm4" ] | 1055 | stm32h755bi-cm4 = [ "stm32-metapac/stm32h755bi-cm4", "_dual-core" ] |
| 1053 | stm32h755ii-cm7 = [ "stm32-metapac/stm32h755ii-cm7" ] | 1056 | stm32h755ii-cm7 = [ "stm32-metapac/stm32h755ii-cm7", "_dual-core" ] |
| 1054 | stm32h755ii-cm4 = [ "stm32-metapac/stm32h755ii-cm4" ] | 1057 | stm32h755ii-cm4 = [ "stm32-metapac/stm32h755ii-cm4", "_dual-core" ] |
| 1055 | stm32h755xi-cm7 = [ "stm32-metapac/stm32h755xi-cm7" ] | 1058 | stm32h755xi-cm7 = [ "stm32-metapac/stm32h755xi-cm7", "_dual-core" ] |
| 1056 | stm32h755xi-cm4 = [ "stm32-metapac/stm32h755xi-cm4" ] | 1059 | stm32h755xi-cm4 = [ "stm32-metapac/stm32h755xi-cm4", "_dual-core" ] |
| 1057 | stm32h755zi-cm7 = [ "stm32-metapac/stm32h755zi-cm7" ] | 1060 | stm32h755zi-cm7 = [ "stm32-metapac/stm32h755zi-cm7", "_dual-core" ] |
| 1058 | stm32h755zi-cm4 = [ "stm32-metapac/stm32h755zi-cm4" ] | 1061 | stm32h755zi-cm4 = [ "stm32-metapac/stm32h755zi-cm4", "_dual-core" ] |
| 1059 | stm32h757ai-cm7 = [ "stm32-metapac/stm32h757ai-cm7" ] | 1062 | stm32h757ai-cm7 = [ "stm32-metapac/stm32h757ai-cm7", "_dual-core" ] |
| 1060 | stm32h757ai-cm4 = [ "stm32-metapac/stm32h757ai-cm4" ] | 1063 | stm32h757ai-cm4 = [ "stm32-metapac/stm32h757ai-cm4", "_dual-core" ] |
| 1061 | stm32h757bi-cm7 = [ "stm32-metapac/stm32h757bi-cm7" ] | 1064 | stm32h757bi-cm7 = [ "stm32-metapac/stm32h757bi-cm7", "_dual-core" ] |
| 1062 | stm32h757bi-cm4 = [ "stm32-metapac/stm32h757bi-cm4" ] | 1065 | stm32h757bi-cm4 = [ "stm32-metapac/stm32h757bi-cm4", "_dual-core" ] |
| 1063 | stm32h757ii-cm7 = [ "stm32-metapac/stm32h757ii-cm7" ] | 1066 | stm32h757ii-cm7 = [ "stm32-metapac/stm32h757ii-cm7", "_dual-core" ] |
| 1064 | stm32h757ii-cm4 = [ "stm32-metapac/stm32h757ii-cm4" ] | 1067 | stm32h757ii-cm4 = [ "stm32-metapac/stm32h757ii-cm4", "_dual-core" ] |
| 1065 | stm32h757xi-cm7 = [ "stm32-metapac/stm32h757xi-cm7" ] | 1068 | stm32h757xi-cm7 = [ "stm32-metapac/stm32h757xi-cm7", "_dual-core" ] |
| 1066 | stm32h757xi-cm4 = [ "stm32-metapac/stm32h757xi-cm4" ] | 1069 | stm32h757xi-cm4 = [ "stm32-metapac/stm32h757xi-cm4", "_dual-core" ] |
| 1067 | stm32h757zi-cm7 = [ "stm32-metapac/stm32h757zi-cm7" ] | 1070 | stm32h757zi-cm7 = [ "stm32-metapac/stm32h757zi-cm7", "_dual-core" ] |
| 1068 | stm32h757zi-cm4 = [ "stm32-metapac/stm32h757zi-cm4" ] | 1071 | stm32h757zi-cm4 = [ "stm32-metapac/stm32h757zi-cm4", "_dual-core" ] |
| 1069 | stm32h7a3ag = [ "stm32-metapac/stm32h7a3ag" ] | 1072 | stm32h7a3ag = [ "stm32-metapac/stm32h7a3ag" ] |
| 1070 | stm32h7a3ai = [ "stm32-metapac/stm32h7a3ai" ] | 1073 | stm32h7a3ai = [ "stm32-metapac/stm32h7a3ai" ] |
| 1071 | stm32h7a3ig = [ "stm32-metapac/stm32h7a3ig" ] | 1074 | stm32h7a3ig = [ "stm32-metapac/stm32h7a3ig" ] |
| @@ -1598,14 +1601,14 @@ stm32wba55he = [ "stm32-metapac/stm32wba55he" ] | |||
| 1598 | stm32wba55hg = [ "stm32-metapac/stm32wba55hg" ] | 1601 | stm32wba55hg = [ "stm32-metapac/stm32wba55hg" ] |
| 1599 | stm32wba55ue = [ "stm32-metapac/stm32wba55ue" ] | 1602 | stm32wba55ue = [ "stm32-metapac/stm32wba55ue" ] |
| 1600 | stm32wba55ug = [ "stm32-metapac/stm32wba55ug" ] | 1603 | stm32wba55ug = [ "stm32-metapac/stm32wba55ug" ] |
| 1601 | stm32wl54cc-cm4 = [ "stm32-metapac/stm32wl54cc-cm4" ] | 1604 | stm32wl54cc-cm4 = [ "stm32-metapac/stm32wl54cc-cm4", "_dual-core" ] |
| 1602 | stm32wl54cc-cm0p = [ "stm32-metapac/stm32wl54cc-cm0p" ] | 1605 | stm32wl54cc-cm0p = [ "stm32-metapac/stm32wl54cc-cm0p", "_dual-core" ] |
| 1603 | stm32wl54jc-cm4 = [ "stm32-metapac/stm32wl54jc-cm4" ] | 1606 | stm32wl54jc-cm4 = [ "stm32-metapac/stm32wl54jc-cm4", "_dual-core" ] |
| 1604 | stm32wl54jc-cm0p = [ "stm32-metapac/stm32wl54jc-cm0p" ] | 1607 | stm32wl54jc-cm0p = [ "stm32-metapac/stm32wl54jc-cm0p", "_dual-core" ] |
| 1605 | stm32wl55cc-cm4 = [ "stm32-metapac/stm32wl55cc-cm4" ] | 1608 | stm32wl55cc-cm4 = [ "stm32-metapac/stm32wl55cc-cm4", "_dual-core" ] |
| 1606 | stm32wl55cc-cm0p = [ "stm32-metapac/stm32wl55cc-cm0p" ] | 1609 | stm32wl55cc-cm0p = [ "stm32-metapac/stm32wl55cc-cm0p", "_dual-core" ] |
| 1607 | stm32wl55jc-cm4 = [ "stm32-metapac/stm32wl55jc-cm4" ] | 1610 | stm32wl55jc-cm4 = [ "stm32-metapac/stm32wl55jc-cm4", "_dual-core" ] |
| 1608 | stm32wl55jc-cm0p = [ "stm32-metapac/stm32wl55jc-cm0p" ] | 1611 | stm32wl55jc-cm0p = [ "stm32-metapac/stm32wl55jc-cm0p", "_dual-core" ] |
| 1609 | stm32wle4c8 = [ "stm32-metapac/stm32wle4c8" ] | 1612 | stm32wle4c8 = [ "stm32-metapac/stm32wle4c8" ] |
| 1610 | stm32wle4cb = [ "stm32-metapac/stm32wle4cb" ] | 1613 | stm32wle4cb = [ "stm32-metapac/stm32wle4cb" ] |
| 1611 | stm32wle4cc = [ "stm32-metapac/stm32wle4cc" ] | 1614 | stm32wle4cc = [ "stm32-metapac/stm32wle4cc" ] |
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 8457e3a13..d8a7ea0e6 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -480,7 +480,7 @@ fn main() { | |||
| 480 | self.clock_names.insert(name.to_ascii_lowercase()); | 480 | self.clock_names.insert(name.to_ascii_lowercase()); |
| 481 | quote!(unsafe { | 481 | quote!(unsafe { |
| 482 | unwrap!( | 482 | unwrap!( |
| 483 | crate::rcc::get_freqs().#clock_name, | 483 | crate::rcc::get_freqs().#clock_name.to_hertz(), |
| 484 | "peripheral '{}' is configured to use the '{}' clock, which is not running. \ | 484 | "peripheral '{}' is configured to use the '{}' clock, which is not running. \ |
| 485 | Either enable it in 'config.rcc' or change 'config.rcc.mux' to use another clock", | 485 | Either enable it in 'config.rcc' or change 'config.rcc.mux' to use another clock", |
| 486 | #peripheral, | 486 | #peripheral, |
| @@ -713,9 +713,10 @@ fn main() { | |||
| 713 | g.extend(quote! { | 713 | g.extend(quote! { |
| 714 | #[derive(Clone, Copy, Debug)] | 714 | #[derive(Clone, Copy, Debug)] |
| 715 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 715 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 716 | #[repr(C)] | ||
| 716 | pub struct Clocks { | 717 | pub struct Clocks { |
| 717 | #( | 718 | #( |
| 718 | pub #clock_idents: Option<crate::time::Hertz>, | 719 | pub #clock_idents: crate::time::MaybeHertz, |
| 719 | )* | 720 | )* |
| 720 | } | 721 | } |
| 721 | }); | 722 | }); |
| @@ -732,7 +733,7 @@ fn main() { | |||
| 732 | $($(#[$m])* $k: $v,)* | 733 | $($(#[$m])* $k: $v,)* |
| 733 | }; | 734 | }; |
| 734 | crate::rcc::set_freqs(crate::rcc::Clocks { | 735 | crate::rcc::set_freqs(crate::rcc::Clocks { |
| 735 | #( #clock_idents: all.#clock_idents, )* | 736 | #( #clock_idents: all.#clock_idents.into(), )* |
| 736 | }); | 737 | }); |
| 737 | } | 738 | } |
| 738 | }; | 739 | }; |
diff --git a/embassy-stm32/src/adc/mod.rs b/embassy-stm32/src/adc/mod.rs index 26b729f70..2f36df240 100644 --- a/embassy-stm32/src/adc/mod.rs +++ b/embassy-stm32/src/adc/mod.rs | |||
| @@ -78,7 +78,7 @@ pub(crate) fn blocking_delay_us(us: u32) { | |||
| 78 | embassy_time::block_for(embassy_time::Duration::from_micros(us as u64)); | 78 | embassy_time::block_for(embassy_time::Duration::from_micros(us as u64)); |
| 79 | #[cfg(not(feature = "time"))] | 79 | #[cfg(not(feature = "time"))] |
| 80 | { | 80 | { |
| 81 | let freq = unsafe { crate::rcc::get_freqs() }.sys.unwrap().0 as u64; | 81 | let freq = unsafe { crate::rcc::get_freqs() }.sys.to_hertz().unwrap().0 as u64; |
| 82 | let us = us as u64; | 82 | let us = us as u64; |
| 83 | let cycles = freq * us / 1_000_000; | 83 | let cycles = freq * us / 1_000_000; |
| 84 | cortex_m::asm::delay(cycles as u32); | 84 | cortex_m::asm::delay(cycles as u32); |
diff --git a/embassy-stm32/src/dsihost.rs b/embassy-stm32/src/dsihost.rs index 51f124542..77c3d95c3 100644 --- a/embassy-stm32/src/dsihost.rs +++ b/embassy-stm32/src/dsihost.rs | |||
| @@ -14,7 +14,7 @@ pub fn blocking_delay_ms(ms: u32) { | |||
| 14 | #[cfg(feature = "time")] | 14 | #[cfg(feature = "time")] |
| 15 | embassy_time::block_for(embassy_time::Duration::from_millis(ms as u64)); | 15 | embassy_time::block_for(embassy_time::Duration::from_millis(ms as u64)); |
| 16 | #[cfg(not(feature = "time"))] | 16 | #[cfg(not(feature = "time"))] |
| 17 | cortex_m::asm::delay(unsafe { crate::rcc::get_freqs() }.sys.unwrap().0 / 1_000 * ms); | 17 | cortex_m::asm::delay(unsafe { crate::rcc::get_freqs() }.sys.to_hertz().unwrap().0 / 1_000 * ms); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | /// PacketTypes extracted from CubeMX | 20 | /// PacketTypes extracted from CubeMX |
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 95f59360a..12ebbae2d 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -273,7 +273,120 @@ impl Default for Config { | |||
| 273 | /// This returns the peripheral singletons that can be used for creating drivers. | 273 | /// This returns the peripheral singletons that can be used for creating drivers. |
| 274 | /// | 274 | /// |
| 275 | /// This should only be called once at startup, otherwise it panics. | 275 | /// This should only be called once at startup, otherwise it panics. |
| 276 | #[cfg(not(feature = "_dual-core"))] | ||
| 276 | pub fn init(config: Config) -> Peripherals { | 277 | pub fn init(config: Config) -> Peripherals { |
| 278 | init_hw(config) | ||
| 279 | } | ||
| 280 | |||
| 281 | #[cfg(feature = "_dual-core")] | ||
| 282 | mod dual_core { | ||
| 283 | use core::cell::UnsafeCell; | ||
| 284 | use core::mem::MaybeUninit; | ||
| 285 | use core::sync::atomic::{AtomicUsize, Ordering}; | ||
| 286 | |||
| 287 | use rcc::Clocks; | ||
| 288 | |||
| 289 | use super::*; | ||
| 290 | |||
| 291 | /// Object containing data that embassy needs to share between cores. | ||
| 292 | /// | ||
| 293 | /// It cannot be initialized by the user. The intended use is: | ||
| 294 | /// | ||
| 295 | /// ``` | ||
| 296 | /// #[link_section = ".ram_d3"] | ||
| 297 | /// static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | ||
| 298 | /// | ||
| 299 | /// init_secondary(&SHARED_DATA); | ||
| 300 | /// ``` | ||
| 301 | /// | ||
| 302 | /// This static must be placed in the same position for both cores. How and where this is done is left to the user. | ||
| 303 | pub struct SharedData { | ||
| 304 | init_flag: AtomicUsize, | ||
| 305 | clocks: UnsafeCell<MaybeUninit<Clocks>>, | ||
| 306 | } | ||
| 307 | |||
| 308 | unsafe impl Sync for SharedData {} | ||
| 309 | |||
| 310 | const INIT_DONE_FLAG: usize = 0xca11ab1e; | ||
| 311 | |||
| 312 | /// Initialize the `embassy-stm32` HAL with the provided configuration. | ||
| 313 | /// This function does the actual initialization of the hardware, in contrast to [init_secondary] or [try_init_secondary]. | ||
| 314 | /// Any core can do the init, but it's important only one core does it. | ||
| 315 | /// | ||
| 316 | /// This returns the peripheral singletons that can be used for creating drivers. | ||
| 317 | /// | ||
| 318 | /// This should only be called once at startup, otherwise it panics. | ||
| 319 | /// | ||
| 320 | /// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs | ||
| 321 | /// for more information on its requirements. | ||
| 322 | pub fn init_primary(config: Config, shared_data: &'static MaybeUninit<SharedData>) -> Peripherals { | ||
| 323 | let shared_data = unsafe { shared_data.assume_init_ref() }; | ||
| 324 | |||
| 325 | rcc::set_freqs_ptr(shared_data.clocks.get()); | ||
| 326 | let p = init_hw(config); | ||
| 327 | |||
| 328 | shared_data.init_flag.store(INIT_DONE_FLAG, Ordering::SeqCst); | ||
| 329 | |||
| 330 | p | ||
| 331 | } | ||
| 332 | |||
| 333 | /// Try to initialize the `embassy-stm32` HAL based on the init done by the other core using [init_primary]. | ||
| 334 | /// | ||
| 335 | /// This returns the peripheral singletons that can be used for creating drivers if the other core is done with its init. | ||
| 336 | /// If the other core is not done yet, this will return `None`. | ||
| 337 | /// | ||
| 338 | /// This should only be called once at startup, otherwise it may panic. | ||
| 339 | /// | ||
| 340 | /// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs | ||
| 341 | /// for more information on its requirements. | ||
| 342 | pub fn try_init_secondary(shared_data: &'static MaybeUninit<SharedData>) -> Option<Peripherals> { | ||
| 343 | let shared_data = unsafe { shared_data.assume_init_ref() }; | ||
| 344 | |||
| 345 | if shared_data.init_flag.load(Ordering::SeqCst) != INIT_DONE_FLAG { | ||
| 346 | return None; | ||
| 347 | } | ||
| 348 | |||
| 349 | // Separate load and store to support the CM0 of the STM32WL | ||
| 350 | shared_data.init_flag.store(0, Ordering::SeqCst); | ||
| 351 | |||
| 352 | Some(init_secondary_hw(shared_data)) | ||
| 353 | } | ||
| 354 | |||
| 355 | /// Initialize the `embassy-stm32` HAL based on the init done by the other core using [init_primary]. | ||
| 356 | /// | ||
| 357 | /// This returns the peripheral singletons that can be used for creating drivers when the other core is done with its init. | ||
| 358 | /// If the other core is not done yet, this will spinloop wait on it. | ||
| 359 | /// | ||
| 360 | /// This should only be called once at startup, otherwise it may panic. | ||
| 361 | /// | ||
| 362 | /// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs | ||
| 363 | /// for more information on its requirements. | ||
| 364 | pub fn init_secondary(shared_data: &'static MaybeUninit<SharedData>) -> Peripherals { | ||
| 365 | loop { | ||
| 366 | if let Some(p) = try_init_secondary(shared_data) { | ||
| 367 | return p; | ||
| 368 | } | ||
| 369 | } | ||
| 370 | } | ||
| 371 | |||
| 372 | fn init_secondary_hw(shared_data: &'static SharedData) -> Peripherals { | ||
| 373 | rcc::set_freqs_ptr(shared_data.clocks.get()); | ||
| 374 | |||
| 375 | // We use different timers on the different cores, so we have to still initialize one here | ||
| 376 | #[cfg(feature = "_time-driver")] | ||
| 377 | critical_section::with(|cs| { | ||
| 378 | // must be after rcc init | ||
| 379 | time_driver::init(cs); | ||
| 380 | }); | ||
| 381 | |||
| 382 | Peripherals::take() | ||
| 383 | } | ||
| 384 | } | ||
| 385 | |||
| 386 | #[cfg(feature = "_dual-core")] | ||
| 387 | pub use dual_core::*; | ||
| 388 | |||
| 389 | fn init_hw(config: Config) -> Peripherals { | ||
| 277 | critical_section::with(|cs| { | 390 | critical_section::with(|cs| { |
| 278 | let p = Peripherals::take_with_cs(cs); | 391 | let p = Peripherals::take_with_cs(cs); |
| 279 | 392 | ||
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs index 024c63cf5..8022a35a4 100644 --- a/embassy-stm32/src/rcc/mod.rs +++ b/embassy-stm32/src/rcc/mod.rs | |||
| @@ -48,11 +48,22 @@ pub(crate) static mut REFCOUNT_STOP1: u32 = 0; | |||
| 48 | /// May be read without a critical section | 48 | /// May be read without a critical section |
| 49 | pub(crate) static mut REFCOUNT_STOP2: u32 = 0; | 49 | pub(crate) static mut REFCOUNT_STOP2: u32 = 0; |
| 50 | 50 | ||
| 51 | #[cfg(not(feature = "_dual-core"))] | ||
| 51 | /// Frozen clock frequencies | 52 | /// Frozen clock frequencies |
| 52 | /// | 53 | /// |
| 53 | /// The existence of this value indicates that the clock configuration can no longer be changed | 54 | /// The existence of this value indicates that the clock configuration can no longer be changed |
| 54 | static mut CLOCK_FREQS: MaybeUninit<Clocks> = MaybeUninit::uninit(); | 55 | static mut CLOCK_FREQS: MaybeUninit<Clocks> = MaybeUninit::uninit(); |
| 55 | 56 | ||
| 57 | #[cfg(feature = "_dual-core")] | ||
| 58 | static CLOCK_FREQS_PTR: core::sync::atomic::AtomicPtr<MaybeUninit<Clocks>> = | ||
| 59 | core::sync::atomic::AtomicPtr::new(core::ptr::null_mut()); | ||
| 60 | |||
| 61 | #[cfg(feature = "_dual-core")] | ||
| 62 | pub(crate) fn set_freqs_ptr(freqs: *mut MaybeUninit<Clocks>) { | ||
| 63 | CLOCK_FREQS_PTR.store(freqs, core::sync::atomic::Ordering::SeqCst); | ||
| 64 | } | ||
| 65 | |||
| 66 | #[cfg(not(feature = "_dual-core"))] | ||
| 56 | /// Sets the clock frequencies | 67 | /// Sets the clock frequencies |
| 57 | /// | 68 | /// |
| 58 | /// Safety: Sets a mutable global. | 69 | /// Safety: Sets a mutable global. |
| @@ -61,11 +72,29 @@ pub(crate) unsafe fn set_freqs(freqs: Clocks) { | |||
| 61 | CLOCK_FREQS = MaybeUninit::new(freqs); | 72 | CLOCK_FREQS = MaybeUninit::new(freqs); |
| 62 | } | 73 | } |
| 63 | 74 | ||
| 75 | #[cfg(feature = "_dual-core")] | ||
| 76 | /// Sets the clock frequencies | ||
| 77 | /// | ||
| 78 | /// Safety: Sets a mutable global. | ||
| 79 | pub(crate) unsafe fn set_freqs(freqs: Clocks) { | ||
| 80 | debug!("rcc: {:?}", freqs); | ||
| 81 | CLOCK_FREQS_PTR | ||
| 82 | .load(core::sync::atomic::Ordering::SeqCst) | ||
| 83 | .write(MaybeUninit::new(freqs)); | ||
| 84 | } | ||
| 85 | |||
| 86 | #[cfg(not(feature = "_dual-core"))] | ||
| 64 | /// Safety: Reads a mutable global. | 87 | /// Safety: Reads a mutable global. |
| 65 | pub(crate) unsafe fn get_freqs() -> &'static Clocks { | 88 | pub(crate) unsafe fn get_freqs() -> &'static Clocks { |
| 66 | CLOCK_FREQS.assume_init_ref() | 89 | CLOCK_FREQS.assume_init_ref() |
| 67 | } | 90 | } |
| 68 | 91 | ||
| 92 | #[cfg(feature = "_dual-core")] | ||
| 93 | /// Safety: Reads a mutable global. | ||
| 94 | pub(crate) unsafe fn get_freqs() -> &'static Clocks { | ||
| 95 | unwrap!(CLOCK_FREQS_PTR.load(core::sync::atomic::Ordering::SeqCst).as_ref()).assume_init_ref() | ||
| 96 | } | ||
| 97 | |||
| 69 | pub(crate) trait SealedRccPeripheral { | 98 | pub(crate) trait SealedRccPeripheral { |
| 70 | fn frequency() -> Hertz; | 99 | fn frequency() -> Hertz; |
| 71 | const RCC_INFO: RccInfo; | 100 | const RCC_INFO: RccInfo; |
diff --git a/embassy-stm32/src/rtc/low_power.rs b/embassy-stm32/src/rtc/low_power.rs index a4ff1acbc..b9aaa63b9 100644 --- a/embassy-stm32/src/rtc/low_power.rs +++ b/embassy-stm32/src/rtc/low_power.rs | |||
| @@ -132,7 +132,7 @@ impl Rtc { | |||
| 132 | 132 | ||
| 133 | // Panic if the rcc mod knows we're not using low-power rtc | 133 | // Panic if the rcc mod knows we're not using low-power rtc |
| 134 | #[cfg(any(rcc_wb, rcc_f4, rcc_f410))] | 134 | #[cfg(any(rcc_wb, rcc_f4, rcc_f410))] |
| 135 | unsafe { crate::rcc::get_freqs() }.rtc.unwrap(); | 135 | unsafe { crate::rcc::get_freqs() }.rtc.to_hertz().unwrap(); |
| 136 | 136 | ||
| 137 | let requested_duration = requested_duration.as_ticks().clamp(0, u32::MAX as u64); | 137 | let requested_duration = requested_duration.as_ticks().clamp(0, u32::MAX as u64); |
| 138 | let rtc_hz = Self::frequency().0 as u64; | 138 | let rtc_hz = Self::frequency().0 as u64; |
diff --git a/embassy-stm32/src/rtc/mod.rs b/embassy-stm32/src/rtc/mod.rs index a7f70b153..fe57cfe66 100644 --- a/embassy-stm32/src/rtc/mod.rs +++ b/embassy-stm32/src/rtc/mod.rs | |||
| @@ -168,7 +168,7 @@ impl Rtc { | |||
| 168 | 168 | ||
| 169 | fn frequency() -> Hertz { | 169 | fn frequency() -> Hertz { |
| 170 | let freqs = unsafe { crate::rcc::get_freqs() }; | 170 | let freqs = unsafe { crate::rcc::get_freqs() }; |
| 171 | freqs.rtc.unwrap() | 171 | freqs.rtc.to_hertz().unwrap() |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | /// Acquire a [`RtcTimeProvider`] instance. | 174 | /// Acquire a [`RtcTimeProvider`] instance. |
diff --git a/embassy-stm32/src/time.rs b/embassy-stm32/src/time.rs index 17690aefc..802ff41ce 100644 --- a/embassy-stm32/src/time.rs +++ b/embassy-stm32/src/time.rs | |||
| @@ -87,3 +87,39 @@ impl Div<Hertz> for Hertz { | |||
| 87 | self.0 / rhs.0 | 87 | self.0 / rhs.0 |
| 88 | } | 88 | } |
| 89 | } | 89 | } |
| 90 | |||
| 91 | #[repr(C)] | ||
| 92 | #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug, Default)] | ||
| 93 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 94 | /// A variant on [Hertz] that acts as an `Option<Hertz>` that is smaller and repr C. | ||
| 95 | /// | ||
| 96 | /// An `Option<Hertz>` can be `.into()`'d into this type and back. | ||
| 97 | /// The only restriction is that that [Hertz] cannot have the value 0 since that's | ||
| 98 | /// seen as the `None` variant. | ||
| 99 | pub struct MaybeHertz(u32); | ||
| 100 | |||
| 101 | impl MaybeHertz { | ||
| 102 | /// Same as calling the `.into()` function, but without type inference. | ||
| 103 | pub fn to_hertz(self) -> Option<Hertz> { | ||
| 104 | self.into() | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | impl From<Option<Hertz>> for MaybeHertz { | ||
| 109 | fn from(value: Option<Hertz>) -> Self { | ||
| 110 | match value { | ||
| 111 | Some(Hertz(0)) => panic!("Hertz cannot be 0"), | ||
| 112 | Some(Hertz(val)) => Self(val), | ||
| 113 | None => Self(0), | ||
| 114 | } | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | impl From<MaybeHertz> for Option<Hertz> { | ||
| 119 | fn from(value: MaybeHertz) -> Self { | ||
| 120 | match value { | ||
| 121 | MaybeHertz(0) => None, | ||
| 122 | MaybeHertz(val) => Some(Hertz(val)), | ||
| 123 | } | ||
| 124 | } | ||
| 125 | } | ||
diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index 1d9d19a73..9384c8688 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs | |||
| @@ -270,7 +270,7 @@ impl<'d, T: Instance> Driver<'d, T> { | |||
| 270 | #[cfg(feature = "time")] | 270 | #[cfg(feature = "time")] |
| 271 | embassy_time::block_for(embassy_time::Duration::from_millis(100)); | 271 | embassy_time::block_for(embassy_time::Duration::from_millis(100)); |
| 272 | #[cfg(not(feature = "time"))] | 272 | #[cfg(not(feature = "time"))] |
| 273 | cortex_m::asm::delay(unsafe { crate::rcc::get_freqs() }.sys.unwrap().0 / 10); | 273 | cortex_m::asm::delay(unsafe { crate::rcc::get_freqs() }.sys.to_hertz().unwrap().0 / 10); |
| 274 | 274 | ||
| 275 | #[cfg(not(usb_v4))] | 275 | #[cfg(not(usb_v4))] |
| 276 | regs.btable().write(|w| w.set_btable(0)); | 276 | regs.btable().write(|w| w.set_btable(0)); |
diff --git a/examples/boot/application/stm32wl/memory.x b/examples/boot/application/stm32wl/memory.x index e1d4e7fa8..5af1723f5 100644 --- a/examples/boot/application/stm32wl/memory.x +++ b/examples/boot/application/stm32wl/memory.x | |||
| @@ -5,7 +5,8 @@ MEMORY | |||
| 5 | BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K | 5 | BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K |
| 6 | FLASH : ORIGIN = 0x08008000, LENGTH = 64K | 6 | FLASH : ORIGIN = 0x08008000, LENGTH = 64K |
| 7 | DFU : ORIGIN = 0x08018000, LENGTH = 68K | 7 | DFU : ORIGIN = 0x08018000, LENGTH = 68K |
| 8 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K | 8 | SHARED_RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 64 |
| 9 | RAM (rwx) : ORIGIN = 0x20000040, LENGTH = 32K - 64 | ||
| 9 | } | 10 | } |
| 10 | 11 | ||
| 11 | __bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER); | 12 | __bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER); |
| @@ -13,3 +14,11 @@ __bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE) - O | |||
| 13 | 14 | ||
| 14 | __bootloader_dfu_start = ORIGIN(DFU) - ORIGIN(BOOTLOADER); | 15 | __bootloader_dfu_start = ORIGIN(DFU) - ORIGIN(BOOTLOADER); |
| 15 | __bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU) - ORIGIN(BOOTLOADER); | 16 | __bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU) - ORIGIN(BOOTLOADER); |
| 17 | |||
| 18 | SECTIONS | ||
| 19 | { | ||
| 20 | .shared_data : | ||
| 21 | { | ||
| 22 | *(.shared_data) | ||
| 23 | } > SHARED_RAM | ||
| 24 | } \ No newline at end of file | ||
diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs index 9f4f0b238..127de0237 100644 --- a/examples/boot/application/stm32wl/src/bin/a.rs +++ b/examples/boot/application/stm32wl/src/bin/a.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use core::mem::MaybeUninit; | ||
| 5 | |||
| 4 | #[cfg(feature = "defmt")] | 6 | #[cfg(feature = "defmt")] |
| 5 | use defmt_rtt::*; | 7 | use defmt_rtt::*; |
| 6 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; | 8 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; |
| @@ -9,6 +11,7 @@ use embassy_executor::Spawner; | |||
| 9 | use embassy_stm32::exti::ExtiInput; | 11 | use embassy_stm32::exti::ExtiInput; |
| 10 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; | 12 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; |
| 11 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; | 13 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; |
| 14 | use embassy_stm32::SharedData; | ||
| 12 | use embassy_sync::mutex::Mutex; | 15 | use embassy_sync::mutex::Mutex; |
| 13 | use panic_reset as _; | 16 | use panic_reset as _; |
| 14 | 17 | ||
| @@ -17,9 +20,12 @@ static APP_B: &[u8] = &[0, 1, 2, 3]; | |||
| 17 | #[cfg(not(feature = "skip-include"))] | 20 | #[cfg(not(feature = "skip-include"))] |
| 18 | static APP_B: &[u8] = include_bytes!("../../b.bin"); | 21 | static APP_B: &[u8] = include_bytes!("../../b.bin"); |
| 19 | 22 | ||
| 23 | #[link_section = ".shared_data"] | ||
| 24 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | ||
| 25 | |||
| 20 | #[embassy_executor::main] | 26 | #[embassy_executor::main] |
| 21 | async fn main(_spawner: Spawner) { | 27 | async fn main(_spawner: Spawner) { |
| 22 | let p = embassy_stm32::init(Default::default()); | 28 | let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA); |
| 23 | let flash = Flash::new_blocking(p.FLASH); | 29 | let flash = Flash::new_blocking(p.FLASH); |
| 24 | let flash = Mutex::new(BlockingAsync::new(flash)); | 30 | let flash = Mutex::new(BlockingAsync::new(flash)); |
| 25 | 31 | ||
diff --git a/examples/boot/application/stm32wl/src/bin/b.rs b/examples/boot/application/stm32wl/src/bin/b.rs index e954d8b91..768dadf8b 100644 --- a/examples/boot/application/stm32wl/src/bin/b.rs +++ b/examples/boot/application/stm32wl/src/bin/b.rs | |||
| @@ -1,16 +1,22 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use core::mem::MaybeUninit; | ||
| 5 | |||
| 4 | #[cfg(feature = "defmt")] | 6 | #[cfg(feature = "defmt")] |
| 5 | use defmt_rtt::*; | 7 | use defmt_rtt::*; |
| 6 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::SharedData; | ||
| 8 | use embassy_time::Timer; | 11 | use embassy_time::Timer; |
| 9 | use panic_reset as _; | 12 | use panic_reset as _; |
| 10 | 13 | ||
| 14 | #[link_section = ".shared_data"] | ||
| 15 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | ||
| 16 | |||
| 11 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner) { | 18 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | 19 | let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA); |
| 14 | let mut led = Output::new(p.PB15, Level::High, Speed::Low); | 20 | let mut led = Output::new(p.PB15, Level::High, Speed::Low); |
| 15 | 21 | ||
| 16 | loop { | 22 | loop { |
diff --git a/examples/stm32h755cm4/.cargo/config.toml b/examples/stm32h755cm4/.cargo/config.toml new file mode 100644 index 000000000..193e6bbc3 --- /dev/null +++ b/examples/stm32h755cm4/.cargo/config.toml | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | [target.thumbv7em-none-eabihf] | ||
| 2 | runner = 'probe-rs run --chip STM32H755ZITx --catch-hardfault --always-print-stacktrace' | ||
| 3 | |||
| 4 | [build] | ||
| 5 | target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU) | ||
| 6 | |||
| 7 | [env] | ||
| 8 | DEFMT_LOG = "trace" | ||
diff --git a/examples/stm32h755cm4/Cargo.toml b/examples/stm32h755cm4/Cargo.toml new file mode 100644 index 000000000..9d2fb9060 --- /dev/null +++ b/examples/stm32h755cm4/Cargo.toml | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | [package] | ||
| 2 | edition = "2021" | ||
| 3 | name = "embassy-stm32h7-examples" | ||
| 4 | version = "0.1.0" | ||
| 5 | license = "MIT OR Apache-2.0" | ||
| 6 | |||
| 7 | [dependencies] | ||
| 8 | # Change stm32h755zi-cm4 to your chip name, if necessary. | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h755zi-cm4", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] } | ||
| 10 | embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt"] } | ||
| 11 | embassy-embedded-hal = { version = "0.2.0", path = "../../embassy-embedded-hal" } | ||
| 12 | embassy-executor = { version = "0.6.0", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } | ||
| 13 | embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | ||
| 14 | embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] } | ||
| 15 | embassy-usb = { version = "0.3.0", path = "../../embassy-usb", features = ["defmt"] } | ||
| 16 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | ||
| 17 | |||
| 18 | defmt = "0.3" | ||
| 19 | defmt-rtt = "0.4" | ||
| 20 | |||
| 21 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | ||
| 22 | cortex-m-rt = "0.7.0" | ||
| 23 | embedded-hal = "0.2.6" | ||
| 24 | embedded-hal-1 = { package = "embedded-hal", version = "1.0" } | ||
| 25 | embedded-hal-async = { version = "1.0" } | ||
| 26 | embedded-nal-async = { version = "0.7.1" } | ||
| 27 | embedded-io-async = { version = "0.6.1" } | ||
| 28 | panic-probe = { version = "0.3", features = ["print-defmt"] } | ||
| 29 | heapless = { version = "0.8", default-features = false } | ||
| 30 | rand_core = "0.6.3" | ||
| 31 | critical-section = "1.1" | ||
| 32 | micromath = "2.0.0" | ||
| 33 | stm32-fmc = "0.3.0" | ||
| 34 | embedded-storage = "0.3.1" | ||
| 35 | static_cell = "2" | ||
| 36 | chrono = { version = "^0.4", default-features = false } | ||
| 37 | grounded = "0.2.0" | ||
| 38 | |||
| 39 | # cargo build/run | ||
| 40 | [profile.dev] | ||
| 41 | codegen-units = 1 | ||
| 42 | debug = 2 | ||
| 43 | debug-assertions = true # <- | ||
| 44 | incremental = false | ||
| 45 | opt-level = 3 # <- | ||
| 46 | overflow-checks = true # <- | ||
| 47 | |||
| 48 | # cargo test | ||
| 49 | [profile.test] | ||
| 50 | codegen-units = 1 | ||
| 51 | debug = 2 | ||
| 52 | debug-assertions = true # <- | ||
| 53 | incremental = false | ||
| 54 | opt-level = 3 # <- | ||
| 55 | overflow-checks = true # <- | ||
| 56 | |||
| 57 | # cargo build/run --release | ||
| 58 | [profile.release] | ||
| 59 | codegen-units = 1 | ||
| 60 | debug = 2 | ||
| 61 | debug-assertions = false # <- | ||
| 62 | incremental = false | ||
| 63 | lto = 'fat' | ||
| 64 | opt-level = 3 # <- | ||
| 65 | overflow-checks = false # <- | ||
| 66 | |||
| 67 | # cargo test --release | ||
| 68 | [profile.bench] | ||
| 69 | codegen-units = 1 | ||
| 70 | debug = 2 | ||
| 71 | debug-assertions = false # <- | ||
| 72 | incremental = false | ||
| 73 | lto = 'fat' | ||
| 74 | opt-level = 3 # <- | ||
| 75 | overflow-checks = false # <- | ||
diff --git a/examples/stm32h755cm4/build.rs b/examples/stm32h755cm4/build.rs new file mode 100644 index 000000000..30691aa97 --- /dev/null +++ b/examples/stm32h755cm4/build.rs | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | //! This build script copies the `memory.x` file from the crate root into | ||
| 2 | //! a directory where the linker can always find it at build time. | ||
| 3 | //! For many projects this is optional, as the linker always searches the | ||
| 4 | //! project root directory -- wherever `Cargo.toml` is. However, if you | ||
| 5 | //! are using a workspace or have a more complicated build setup, this | ||
| 6 | //! build script becomes required. Additionally, by requesting that | ||
| 7 | //! Cargo re-run the build script whenever `memory.x` is changed, | ||
| 8 | //! updating `memory.x` ensures a rebuild of the application with the | ||
| 9 | //! new memory settings. | ||
| 10 | |||
| 11 | use std::env; | ||
| 12 | use std::fs::File; | ||
| 13 | use std::io::Write; | ||
| 14 | use std::path::PathBuf; | ||
| 15 | |||
| 16 | fn main() { | ||
| 17 | // Put `memory.x` in our output directory and ensure it's | ||
| 18 | // on the linker search path. | ||
| 19 | let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); | ||
| 20 | File::create(out.join("memory.x")) | ||
| 21 | .unwrap() | ||
| 22 | .write_all(include_bytes!("memory.x")) | ||
| 23 | .unwrap(); | ||
| 24 | println!("cargo:rustc-link-search={}", out.display()); | ||
| 25 | |||
| 26 | // By default, Cargo will re-run a build script whenever | ||
| 27 | // any file in the project changes. By specifying `memory.x` | ||
| 28 | // here, we ensure the build script is only re-run when | ||
| 29 | // `memory.x` is changed. | ||
| 30 | println!("cargo:rerun-if-changed=memory.x"); | ||
| 31 | |||
| 32 | println!("cargo:rustc-link-arg-bins=--nmagic"); | ||
| 33 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); | ||
| 34 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); | ||
| 35 | } | ||
diff --git a/examples/stm32h755cm4/memory.x b/examples/stm32h755cm4/memory.x new file mode 100644 index 000000000..7d60354e3 --- /dev/null +++ b/examples/stm32h755cm4/memory.x | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | MEMORY | ||
| 2 | { | ||
| 3 | FLASH : ORIGIN = 0x08100000, LENGTH = 1024K /* BANK_2 */ | ||
| 4 | RAM : ORIGIN = 0x10000000, LENGTH = 128K /* SRAM1 */ | ||
| 5 | RAM_D3 : ORIGIN = 0x38000000, LENGTH = 64K /* SRAM4 */ | ||
| 6 | } | ||
| 7 | |||
| 8 | SECTIONS | ||
| 9 | { | ||
| 10 | .ram_d3 : | ||
| 11 | { | ||
| 12 | *(.ram_d3.shared_data) | ||
| 13 | *(.ram_d3) | ||
| 14 | } > RAM_D3 | ||
| 15 | } \ No newline at end of file | ||
diff --git a/examples/stm32h755cm4/src/bin/blinky.rs b/examples/stm32h755cm4/src/bin/blinky.rs new file mode 100644 index 000000000..b5c547839 --- /dev/null +++ b/examples/stm32h755cm4/src/bin/blinky.rs | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use core::mem::MaybeUninit; | ||
| 5 | |||
| 6 | use defmt::*; | ||
| 7 | use embassy_executor::Spawner; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 9 | use embassy_stm32::SharedData; | ||
| 10 | use embassy_time::Timer; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | ||
| 12 | |||
| 13 | #[link_section = ".ram_d3.shared_data"] | ||
| 14 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | ||
| 15 | |||
| 16 | #[embassy_executor::main] | ||
| 17 | async fn main(_spawner: Spawner) { | ||
| 18 | let p = embassy_stm32::init_secondary(&SHARED_DATA); | ||
| 19 | info!("Hello World!"); | ||
| 20 | |||
| 21 | let mut led = Output::new(p.PE1, Level::High, Speed::Low); | ||
| 22 | |||
| 23 | loop { | ||
| 24 | info!("high"); | ||
| 25 | led.set_high(); | ||
| 26 | Timer::after_millis(250).await; | ||
| 27 | |||
| 28 | info!("low"); | ||
| 29 | led.set_low(); | ||
| 30 | Timer::after_millis(250).await; | ||
| 31 | } | ||
| 32 | } | ||
diff --git a/examples/stm32h755cm7/.cargo/config.toml b/examples/stm32h755cm7/.cargo/config.toml new file mode 100644 index 000000000..193e6bbc3 --- /dev/null +++ b/examples/stm32h755cm7/.cargo/config.toml | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | [target.thumbv7em-none-eabihf] | ||
| 2 | runner = 'probe-rs run --chip STM32H755ZITx --catch-hardfault --always-print-stacktrace' | ||
| 3 | |||
| 4 | [build] | ||
| 5 | target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU) | ||
| 6 | |||
| 7 | [env] | ||
| 8 | DEFMT_LOG = "trace" | ||
diff --git a/examples/stm32h755cm7/Cargo.toml b/examples/stm32h755cm7/Cargo.toml new file mode 100644 index 000000000..ab088fd33 --- /dev/null +++ b/examples/stm32h755cm7/Cargo.toml | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | [package] | ||
| 2 | edition = "2021" | ||
| 3 | name = "embassy-stm32h7-examples" | ||
| 4 | version = "0.1.0" | ||
| 5 | license = "MIT OR Apache-2.0" | ||
| 6 | |||
| 7 | [dependencies] | ||
| 8 | # Change stm32h743bi to your chip name, if necessary. | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h755zi-cm7", "time-driver-tim3", "exti", "memory-x", "unstable-pac", "chrono"] } | ||
| 10 | embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt"] } | ||
| 11 | embassy-embedded-hal = { version = "0.2.0", path = "../../embassy-embedded-hal" } | ||
| 12 | embassy-executor = { version = "0.6.0", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } | ||
| 13 | embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | ||
| 14 | embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] } | ||
| 15 | embassy-usb = { version = "0.3.0", path = "../../embassy-usb", features = ["defmt"] } | ||
| 16 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | ||
| 17 | |||
| 18 | defmt = "0.3" | ||
| 19 | defmt-rtt = "0.4" | ||
| 20 | |||
| 21 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | ||
| 22 | cortex-m-rt = "0.7.0" | ||
| 23 | embedded-hal = "0.2.6" | ||
| 24 | embedded-hal-1 = { package = "embedded-hal", version = "1.0" } | ||
| 25 | embedded-hal-async = { version = "1.0" } | ||
| 26 | embedded-nal-async = { version = "0.7.1" } | ||
| 27 | embedded-io-async = { version = "0.6.1" } | ||
| 28 | panic-probe = { version = "0.3", features = ["print-defmt"] } | ||
| 29 | heapless = { version = "0.8", default-features = false } | ||
| 30 | rand_core = "0.6.3" | ||
| 31 | critical-section = "1.1" | ||
| 32 | micromath = "2.0.0" | ||
| 33 | stm32-fmc = "0.3.0" | ||
| 34 | embedded-storage = "0.3.1" | ||
| 35 | static_cell = "2" | ||
| 36 | chrono = { version = "^0.4", default-features = false } | ||
| 37 | grounded = "0.2.0" | ||
| 38 | |||
| 39 | # cargo build/run | ||
| 40 | [profile.dev] | ||
| 41 | codegen-units = 1 | ||
| 42 | debug = 2 | ||
| 43 | debug-assertions = true # <- | ||
| 44 | incremental = false | ||
| 45 | opt-level = 3 # <- | ||
| 46 | overflow-checks = true # <- | ||
| 47 | |||
| 48 | # cargo test | ||
| 49 | [profile.test] | ||
| 50 | codegen-units = 1 | ||
| 51 | debug = 2 | ||
| 52 | debug-assertions = true # <- | ||
| 53 | incremental = false | ||
| 54 | opt-level = 3 # <- | ||
| 55 | overflow-checks = true # <- | ||
| 56 | |||
| 57 | # cargo build/run --release | ||
| 58 | [profile.release] | ||
| 59 | codegen-units = 1 | ||
| 60 | debug = 2 | ||
| 61 | debug-assertions = false # <- | ||
| 62 | incremental = false | ||
| 63 | lto = 'fat' | ||
| 64 | opt-level = 3 # <- | ||
| 65 | overflow-checks = false # <- | ||
| 66 | |||
| 67 | # cargo test --release | ||
| 68 | [profile.bench] | ||
| 69 | codegen-units = 1 | ||
| 70 | debug = 2 | ||
| 71 | debug-assertions = false # <- | ||
| 72 | incremental = false | ||
| 73 | lto = 'fat' | ||
| 74 | opt-level = 3 # <- | ||
| 75 | overflow-checks = false # <- | ||
diff --git a/examples/stm32h755cm7/build.rs b/examples/stm32h755cm7/build.rs new file mode 100644 index 000000000..30691aa97 --- /dev/null +++ b/examples/stm32h755cm7/build.rs | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | //! This build script copies the `memory.x` file from the crate root into | ||
| 2 | //! a directory where the linker can always find it at build time. | ||
| 3 | //! For many projects this is optional, as the linker always searches the | ||
| 4 | //! project root directory -- wherever `Cargo.toml` is. However, if you | ||
| 5 | //! are using a workspace or have a more complicated build setup, this | ||
| 6 | //! build script becomes required. Additionally, by requesting that | ||
| 7 | //! Cargo re-run the build script whenever `memory.x` is changed, | ||
| 8 | //! updating `memory.x` ensures a rebuild of the application with the | ||
| 9 | //! new memory settings. | ||
| 10 | |||
| 11 | use std::env; | ||
| 12 | use std::fs::File; | ||
| 13 | use std::io::Write; | ||
| 14 | use std::path::PathBuf; | ||
| 15 | |||
| 16 | fn main() { | ||
| 17 | // Put `memory.x` in our output directory and ensure it's | ||
| 18 | // on the linker search path. | ||
| 19 | let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); | ||
| 20 | File::create(out.join("memory.x")) | ||
| 21 | .unwrap() | ||
| 22 | .write_all(include_bytes!("memory.x")) | ||
| 23 | .unwrap(); | ||
| 24 | println!("cargo:rustc-link-search={}", out.display()); | ||
| 25 | |||
| 26 | // By default, Cargo will re-run a build script whenever | ||
| 27 | // any file in the project changes. By specifying `memory.x` | ||
| 28 | // here, we ensure the build script is only re-run when | ||
| 29 | // `memory.x` is changed. | ||
| 30 | println!("cargo:rerun-if-changed=memory.x"); | ||
| 31 | |||
| 32 | println!("cargo:rustc-link-arg-bins=--nmagic"); | ||
| 33 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); | ||
| 34 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); | ||
| 35 | } | ||
diff --git a/examples/stm32h755cm7/memory.x b/examples/stm32h755cm7/memory.x new file mode 100644 index 000000000..ef884796a --- /dev/null +++ b/examples/stm32h755cm7/memory.x | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | MEMORY | ||
| 2 | { | ||
| 3 | FLASH : ORIGIN = 0x08000000, LENGTH = 1024K /* BANK_1 */ | ||
| 4 | RAM : ORIGIN = 0x24000000, LENGTH = 512K /* AXIRAM */ | ||
| 5 | RAM_D3 : ORIGIN = 0x38000000, LENGTH = 64K /* SRAM4 */ | ||
| 6 | } | ||
| 7 | |||
| 8 | SECTIONS | ||
| 9 | { | ||
| 10 | .ram_d3 : | ||
| 11 | { | ||
| 12 | *(.ram_d3.shared_data) | ||
| 13 | *(.ram_d3) | ||
| 14 | } > RAM_D3 | ||
| 15 | } \ No newline at end of file | ||
diff --git a/examples/stm32h755cm7/src/bin/blinky.rs b/examples/stm32h755cm7/src/bin/blinky.rs new file mode 100644 index 000000000..94d2226c0 --- /dev/null +++ b/examples/stm32h755cm7/src/bin/blinky.rs | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use core::mem::MaybeUninit; | ||
| 5 | |||
| 6 | use defmt::*; | ||
| 7 | use embassy_executor::Spawner; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 9 | use embassy_stm32::SharedData; | ||
| 10 | use embassy_time::Timer; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | ||
| 12 | |||
| 13 | #[link_section = ".ram_d3.shared_data"] | ||
| 14 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | ||
| 15 | |||
| 16 | #[embassy_executor::main] | ||
| 17 | async fn main(_spawner: Spawner) { | ||
| 18 | let mut config = embassy_stm32::Config::default(); | ||
| 19 | { | ||
| 20 | use embassy_stm32::rcc::*; | ||
| 21 | config.rcc.hsi = Some(HSIPrescaler::DIV1); | ||
| 22 | config.rcc.csi = true; | ||
| 23 | config.rcc.pll1 = Some(Pll { | ||
| 24 | source: PllSource::HSI, | ||
| 25 | prediv: PllPreDiv::DIV4, | ||
| 26 | mul: PllMul::MUL50, | ||
| 27 | divp: Some(PllDiv::DIV2), | ||
| 28 | divq: Some(PllDiv::DIV8), // 100mhz | ||
| 29 | divr: None, | ||
| 30 | }); | ||
| 31 | config.rcc.sys = Sysclk::PLL1_P; // 400 Mhz | ||
| 32 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | ||
| 33 | config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 34 | config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 35 | config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 36 | config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 37 | config.rcc.voltage_scale = VoltageScale::Scale1; | ||
| 38 | config.rcc.supply_config = SupplyConfig::DirectSMPS; | ||
| 39 | } | ||
| 40 | let p = embassy_stm32::init_primary(config, &SHARED_DATA); | ||
| 41 | info!("Hello World!"); | ||
| 42 | |||
| 43 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); | ||
| 44 | |||
| 45 | loop { | ||
| 46 | info!("high"); | ||
| 47 | led.set_high(); | ||
| 48 | Timer::after_millis(500).await; | ||
| 49 | |||
| 50 | info!("low"); | ||
| 51 | led.set_low(); | ||
| 52 | Timer::after_millis(500).await; | ||
| 53 | } | ||
| 54 | } | ||
diff --git a/examples/stm32wl/memory.x b/examples/stm32wl/memory.x new file mode 100644 index 000000000..0298caa4b --- /dev/null +++ b/examples/stm32wl/memory.x | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | MEMORY | ||
| 2 | { | ||
| 3 | /* NOTE 1 K = 1 KiBi = 1024 bytes */ | ||
| 4 | FLASH : ORIGIN = 0x08000000, LENGTH = 256K | ||
| 5 | SHARED_RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 64 | ||
| 6 | RAM (rwx) : ORIGIN = 0x20000040, LENGTH = 64K - 64 | ||
| 7 | } | ||
| 8 | |||
| 9 | SECTIONS | ||
| 10 | { | ||
| 11 | .shared_data : | ||
| 12 | { | ||
| 13 | *(.shared_data) | ||
| 14 | } > SHARED_RAM | ||
| 15 | } \ No newline at end of file | ||
diff --git a/examples/stm32wl/src/bin/blinky.rs b/examples/stm32wl/src/bin/blinky.rs index 347bd093f..ce7d0ec58 100644 --- a/examples/stm32wl/src/bin/blinky.rs +++ b/examples/stm32wl/src/bin/blinky.rs | |||
| @@ -1,15 +1,21 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use core::mem::MaybeUninit; | ||
| 5 | |||
| 4 | use defmt::*; | 6 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::SharedData; | ||
| 7 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 12 | ||
| 13 | #[link_section = ".shared_data"] | ||
| 14 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | ||
| 15 | |||
| 10 | #[embassy_executor::main] | 16 | #[embassy_executor::main] |
| 11 | async fn main(_spawner: Spawner) { | 17 | async fn main(_spawner: Spawner) { |
| 12 | let p = embassy_stm32::init(Default::default()); | 18 | let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA); |
| 13 | info!("Hello World!"); | 19 | info!("Hello World!"); |
| 14 | 20 | ||
| 15 | let mut led = Output::new(p.PB15, Level::High, Speed::Low); | 21 | let mut led = Output::new(p.PB15, Level::High, Speed::Low); |
diff --git a/examples/stm32wl/src/bin/button.rs b/examples/stm32wl/src/bin/button.rs index eccd211e2..8b5204479 100644 --- a/examples/stm32wl/src/bin/button.rs +++ b/examples/stm32wl/src/bin/button.rs | |||
| @@ -1,16 +1,22 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use core::mem::MaybeUninit; | ||
| 5 | |||
| 4 | use cortex_m_rt::entry; | 6 | use cortex_m_rt::entry; |
| 5 | use defmt::*; | 7 | use defmt::*; |
| 6 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 8 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 9 | use embassy_stm32::SharedData; | ||
| 7 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 8 | 11 | ||
| 12 | #[link_section = ".shared_data"] | ||
| 13 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | ||
| 14 | |||
| 9 | #[entry] | 15 | #[entry] |
| 10 | fn main() -> ! { | 16 | fn main() -> ! { |
| 11 | info!("Hello World!"); | 17 | info!("Hello World!"); |
| 12 | 18 | ||
| 13 | let p = embassy_stm32::init(Default::default()); | 19 | let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA); |
| 14 | 20 | ||
| 15 | let button = Input::new(p.PA0, Pull::Up); | 21 | let button = Input::new(p.PA0, Pull::Up); |
| 16 | let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); | 22 | let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); |
diff --git a/examples/stm32wl/src/bin/button_exti.rs b/examples/stm32wl/src/bin/button_exti.rs index 27d5330bd..8dd1a6a5e 100644 --- a/examples/stm32wl/src/bin/button_exti.rs +++ b/examples/stm32wl/src/bin/button_exti.rs | |||
| @@ -1,15 +1,21 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use core::mem::MaybeUninit; | ||
| 5 | |||
| 4 | use defmt::*; | 6 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 8 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::Pull; | 9 | use embassy_stm32::gpio::Pull; |
| 10 | use embassy_stm32::SharedData; | ||
| 8 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 12 | ||
| 13 | #[link_section = ".shared_data"] | ||
| 14 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | ||
| 15 | |||
| 10 | #[embassy_executor::main] | 16 | #[embassy_executor::main] |
| 11 | async fn main(_spawner: Spawner) { | 17 | async fn main(_spawner: Spawner) { |
| 12 | let p = embassy_stm32::init(Default::default()); | 18 | let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA); |
| 13 | info!("Hello World!"); | 19 | info!("Hello World!"); |
| 14 | 20 | ||
| 15 | let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up); | 21 | let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up); |
diff --git a/examples/stm32wl/src/bin/flash.rs b/examples/stm32wl/src/bin/flash.rs index 0b7417c01..147f5d293 100644 --- a/examples/stm32wl/src/bin/flash.rs +++ b/examples/stm32wl/src/bin/flash.rs | |||
| @@ -1,14 +1,20 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use core::mem::MaybeUninit; | ||
| 5 | |||
| 4 | use defmt::{info, unwrap}; | 6 | use defmt::{info, unwrap}; |
| 5 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::flash::Flash; | 8 | use embassy_stm32::flash::Flash; |
| 9 | use embassy_stm32::SharedData; | ||
| 7 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 8 | 11 | ||
| 12 | #[link_section = ".shared_data"] | ||
| 13 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | ||
| 14 | |||
| 9 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| 10 | async fn main(_spawner: Spawner) { | 16 | async fn main(_spawner: Spawner) { |
| 11 | let p = embassy_stm32::init(Default::default()); | 17 | let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA); |
| 12 | info!("Hello Flash!"); | 18 | info!("Hello Flash!"); |
| 13 | 19 | ||
| 14 | const ADDR: u32 = 0x36000; | 20 | const ADDR: u32 = 0x36000; |
diff --git a/examples/stm32wl/src/bin/random.rs b/examples/stm32wl/src/bin/random.rs index 8e9fe02b2..df2ed0054 100644 --- a/examples/stm32wl/src/bin/random.rs +++ b/examples/stm32wl/src/bin/random.rs | |||
| @@ -1,17 +1,22 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use core::mem::MaybeUninit; | ||
| 5 | |||
| 4 | use defmt::*; | 6 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::rng::{self, Rng}; | 8 | use embassy_stm32::rng::{self, Rng}; |
| 7 | use embassy_stm32::time::Hertz; | 9 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals}; | 10 | use embassy_stm32::{bind_interrupts, peripherals, SharedData}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 12 | ||
| 11 | bind_interrupts!(struct Irqs{ | 13 | bind_interrupts!(struct Irqs{ |
| 12 | RNG => rng::InterruptHandler<peripherals::RNG>; | 14 | RNG => rng::InterruptHandler<peripherals::RNG>; |
| 13 | }); | 15 | }); |
| 14 | 16 | ||
| 17 | #[link_section = ".shared_data"] | ||
| 18 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | ||
| 19 | |||
| 15 | #[embassy_executor::main] | 20 | #[embassy_executor::main] |
| 16 | async fn main(_spawner: Spawner) { | 21 | async fn main(_spawner: Spawner) { |
| 17 | let mut config = embassy_stm32::Config::default(); | 22 | let mut config = embassy_stm32::Config::default(); |
| @@ -32,7 +37,7 @@ async fn main(_spawner: Spawner) { | |||
| 32 | divr: Some(PllRDiv::DIV2), // sysclk 48Mhz clock (32 / 2 * 6 / 2) | 37 | divr: Some(PllRDiv::DIV2), // sysclk 48Mhz clock (32 / 2 * 6 / 2) |
| 33 | }); | 38 | }); |
| 34 | } | 39 | } |
| 35 | let p = embassy_stm32::init(config); | 40 | let p = embassy_stm32::init_primary(config, &SHARED_DATA); |
| 36 | 41 | ||
| 37 | info!("Hello World!"); | 42 | info!("Hello World!"); |
| 38 | 43 | ||
diff --git a/examples/stm32wl/src/bin/rtc.rs b/examples/stm32wl/src/bin/rtc.rs index cf7d6d220..69a9ddc4c 100644 --- a/examples/stm32wl/src/bin/rtc.rs +++ b/examples/stm32wl/src/bin/rtc.rs | |||
| @@ -1,15 +1,20 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use core::mem::MaybeUninit; | ||
| 5 | |||
| 4 | use chrono::{NaiveDate, NaiveDateTime}; | 6 | use chrono::{NaiveDate, NaiveDateTime}; |
| 5 | use defmt::*; | 7 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | 9 | use embassy_stm32::rtc::{Rtc, RtcConfig}; |
| 8 | use embassy_stm32::time::Hertz; | 10 | use embassy_stm32::time::Hertz; |
| 9 | use embassy_stm32::Config; | 11 | use embassy_stm32::{Config, SharedData}; |
| 10 | use embassy_time::Timer; | 12 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 14 | ||
| 15 | #[link_section = ".shared_data"] | ||
| 16 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | ||
| 17 | |||
| 13 | #[embassy_executor::main] | 18 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner) { | 19 | async fn main(_spawner: Spawner) { |
| 15 | let mut config = Config::default(); | 20 | let mut config = Config::default(); |
| @@ -31,7 +36,7 @@ async fn main(_spawner: Spawner) { | |||
| 31 | divr: Some(PllRDiv::DIV2), // sysclk 48Mhz clock (32 / 2 * 6 / 2) | 36 | divr: Some(PllRDiv::DIV2), // sysclk 48Mhz clock (32 / 2 * 6 / 2) |
| 32 | }); | 37 | }); |
| 33 | } | 38 | } |
| 34 | let p = embassy_stm32::init(config); | 39 | let p = embassy_stm32::init_primary(config, &SHARED_DATA); |
| 35 | info!("Hello World!"); | 40 | info!("Hello World!"); |
| 36 | 41 | ||
| 37 | let now = NaiveDate::from_ymd_opt(2020, 5, 15) | 42 | let now = NaiveDate::from_ymd_opt(2020, 5, 15) |
diff --git a/examples/stm32wl/src/bin/uart_async.rs b/examples/stm32wl/src/bin/uart_async.rs index 3637243a0..ece9b9201 100644 --- a/examples/stm32wl/src/bin/uart_async.rs +++ b/examples/stm32wl/src/bin/uart_async.rs | |||
| @@ -1,10 +1,12 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use core::mem::MaybeUninit; | ||
| 5 | |||
| 4 | use defmt::*; | 6 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::usart::{Config, InterruptHandler, Uart}; | 8 | use embassy_stm32::usart::{Config, InterruptHandler, Uart}; |
| 7 | use embassy_stm32::{bind_interrupts, peripherals}; | 9 | use embassy_stm32::{bind_interrupts, peripherals, SharedData}; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 11 | ||
| 10 | bind_interrupts!(struct Irqs{ | 12 | bind_interrupts!(struct Irqs{ |
| @@ -12,6 +14,9 @@ bind_interrupts!(struct Irqs{ | |||
| 12 | LPUART1 => InterruptHandler<peripherals::LPUART1>; | 14 | LPUART1 => InterruptHandler<peripherals::LPUART1>; |
| 13 | }); | 15 | }); |
| 14 | 16 | ||
| 17 | #[link_section = ".shared_data"] | ||
| 18 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | ||
| 19 | |||
| 15 | /* | 20 | /* |
| 16 | Pass Incoming data from LPUART1 to USART1 | 21 | Pass Incoming data from LPUART1 to USART1 |
| 17 | Example is written for the LoRa-E5 mini v1.0, | 22 | Example is written for the LoRa-E5 mini v1.0, |
| @@ -21,7 +26,7 @@ but can be surely changed for your needs. | |||
| 21 | async fn main(_spawner: Spawner) { | 26 | async fn main(_spawner: Spawner) { |
| 22 | let mut config = embassy_stm32::Config::default(); | 27 | let mut config = embassy_stm32::Config::default(); |
| 23 | config.rcc.sys = embassy_stm32::rcc::Sysclk::HSE; | 28 | config.rcc.sys = embassy_stm32::rcc::Sysclk::HSE; |
| 24 | let p = embassy_stm32::init(config); | 29 | let p = embassy_stm32::init_primary(config, &SHARED_DATA); |
| 25 | 30 | ||
| 26 | defmt::info!("Starting system"); | 31 | defmt::info!("Starting system"); |
| 27 | 32 | ||
diff --git a/tests/stm32/src/bin/can.rs b/tests/stm32/src/bin/can.rs index ba8a33e34..85a5f8d83 100644 --- a/tests/stm32/src/bin/can.rs +++ b/tests/stm32/src/bin/can.rs | |||
| @@ -27,7 +27,7 @@ bind_interrupts!(struct Irqs { | |||
| 27 | 27 | ||
| 28 | #[embassy_executor::main] | 28 | #[embassy_executor::main] |
| 29 | async fn main(_spawner: Spawner) { | 29 | async fn main(_spawner: Spawner) { |
| 30 | let p = embassy_stm32::init(config()); | 30 | let p = init(); |
| 31 | info!("Hello World!"); | 31 | info!("Hello World!"); |
| 32 | 32 | ||
| 33 | let options = TestOptions { | 33 | let options = TestOptions { |
diff --git a/tests/stm32/src/bin/cordic.rs b/tests/stm32/src/bin/cordic.rs index e09226de8..879ad56b6 100644 --- a/tests/stm32/src/bin/cordic.rs +++ b/tests/stm32/src/bin/cordic.rs | |||
| @@ -29,7 +29,7 @@ const OUTPUT_LENGTH: usize = (INPUT_U32_COUNT - 1) * 2; | |||
| 29 | 29 | ||
| 30 | #[embassy_executor::main] | 30 | #[embassy_executor::main] |
| 31 | async fn main(_spawner: Spawner) { | 31 | async fn main(_spawner: Spawner) { |
| 32 | let dp = embassy_stm32::init(config()); | 32 | let dp = init(); |
| 33 | 33 | ||
| 34 | // | 34 | // |
| 35 | // use RNG generate random Q1.31 value | 35 | // use RNG generate random Q1.31 value |
diff --git a/tests/stm32/src/bin/cryp.rs b/tests/stm32/src/bin/cryp.rs index 60778bdaa..028775ac8 100644 --- a/tests/stm32/src/bin/cryp.rs +++ b/tests/stm32/src/bin/cryp.rs | |||
| @@ -20,7 +20,7 @@ bind_interrupts!(struct Irqs { | |||
| 20 | 20 | ||
| 21 | #[embassy_executor::main] | 21 | #[embassy_executor::main] |
| 22 | async fn main(_spawner: Spawner) { | 22 | async fn main(_spawner: Spawner) { |
| 23 | let p: embassy_stm32::Peripherals = embassy_stm32::init(config()); | 23 | let p: embassy_stm32::Peripherals = init(); |
| 24 | 24 | ||
| 25 | const PAYLOAD1: &[u8] = b"payload data 1 ;zdfhzdfhS;GKJASBDG;ASKDJBAL,zdfhzdfhzdfhzdfhvljhb,jhbjhb,sdhsdghsdhsfhsghzdfhzdfhzdfhzdfdhsdthsthsdhsgaadfhhgkdgfuoyguoft6783567"; | 25 | const PAYLOAD1: &[u8] = b"payload data 1 ;zdfhzdfhS;GKJASBDG;ASKDJBAL,zdfhzdfhzdfhzdfhvljhb,jhbjhb,sdhsdghsdhsfhsghzdfhzdfhzdfhzdfdhsdthsthsdhsgaadfhhgkdgfuoyguoft6783567"; |
| 26 | const PAYLOAD2: &[u8] = b"payload data 2 ;SKEzdfhzdfhzbhgvljhb,jhbjhb,sdhsdghsdhsfhsghshsfhshstsdthadfhsdfjhsfgjsfgjxfgjzdhgDFghSDGHjtfjtjszftjzsdtjhstdsdhsdhsdhsdhsdthsthsdhsgfh"; | 26 | const PAYLOAD2: &[u8] = b"payload data 2 ;SKEzdfhzdfhzbhgvljhb,jhbjhb,sdhsdghsdhsfhsghshsfhshstsdthadfhsdfjhsfgjsfgjxfgjzdhgDFghSDGHjtfjtjszftjzsdtjhstdsdhsdhsdhsdhsdthsthsdhsgfh"; |
diff --git a/tests/stm32/src/bin/dac.rs b/tests/stm32/src/bin/dac.rs index 86a68c530..88e661525 100644 --- a/tests/stm32/src/bin/dac.rs +++ b/tests/stm32/src/bin/dac.rs | |||
| @@ -20,7 +20,7 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 20 | #[embassy_executor::main] | 20 | #[embassy_executor::main] |
| 21 | async fn main(_spawner: Spawner) { | 21 | async fn main(_spawner: Spawner) { |
| 22 | // Initialize the board and obtain a Peripherals instance | 22 | // Initialize the board and obtain a Peripherals instance |
| 23 | let p: embassy_stm32::Peripherals = embassy_stm32::init(config()); | 23 | let p: embassy_stm32::Peripherals = init(); |
| 24 | 24 | ||
| 25 | let adc = peri!(p, ADC); | 25 | let adc = peri!(p, ADC); |
| 26 | let dac = peri!(p, DAC); | 26 | let dac = peri!(p, DAC); |
diff --git a/tests/stm32/src/bin/dac_l1.rs b/tests/stm32/src/bin/dac_l1.rs index d5e9c9722..925db617d 100644 --- a/tests/stm32/src/bin/dac_l1.rs +++ b/tests/stm32/src/bin/dac_l1.rs | |||
| @@ -25,7 +25,7 @@ bind_interrupts!(struct Irqs { | |||
| 25 | #[embassy_executor::main] | 25 | #[embassy_executor::main] |
| 26 | async fn main(_spawner: Spawner) { | 26 | async fn main(_spawner: Spawner) { |
| 27 | // Initialize the board and obtain a Peripherals instance | 27 | // Initialize the board and obtain a Peripherals instance |
| 28 | let p: embassy_stm32::Peripherals = embassy_stm32::init(config()); | 28 | let p: embassy_stm32::Peripherals = init(); |
| 29 | 29 | ||
| 30 | let adc = peri!(p, ADC); | 30 | let adc = peri!(p, ADC); |
| 31 | let dac = peri!(p, DAC); | 31 | let dac = peri!(p, DAC); |
diff --git a/tests/stm32/src/bin/eth.rs b/tests/stm32/src/bin/eth.rs index 7c02f0354..25a06b986 100644 --- a/tests/stm32/src/bin/eth.rs +++ b/tests/stm32/src/bin/eth.rs | |||
| @@ -38,7 +38,7 @@ async fn net_task(stack: &'static Stack<Device>) -> ! { | |||
| 38 | 38 | ||
| 39 | #[embassy_executor::main] | 39 | #[embassy_executor::main] |
| 40 | async fn main(spawner: Spawner) { | 40 | async fn main(spawner: Spawner) { |
| 41 | let p = embassy_stm32::init(config()); | 41 | let p = init(); |
| 42 | info!("Hello World!"); | 42 | info!("Hello World!"); |
| 43 | 43 | ||
| 44 | // Generate random seed. | 44 | // Generate random seed. |
diff --git a/tests/stm32/src/bin/fdcan.rs b/tests/stm32/src/bin/fdcan.rs index bc2b7edd4..83d7eca85 100644 --- a/tests/stm32/src/bin/fdcan.rs +++ b/tests/stm32/src/bin/fdcan.rs | |||
| @@ -102,10 +102,10 @@ fn options() -> (Config, TestOptions) { | |||
| 102 | 102 | ||
| 103 | #[embassy_executor::main] | 103 | #[embassy_executor::main] |
| 104 | async fn main(_spawner: Spawner) { | 104 | async fn main(_spawner: Spawner) { |
| 105 | //let peripherals = embassy_stm32::init(config()); | 105 | //let peripherals = init(); |
| 106 | 106 | ||
| 107 | let (config, options) = options(); | 107 | let (config, options) = options(); |
| 108 | let peripherals = embassy_stm32::init(config); | 108 | let peripherals = init_with_config(config); |
| 109 | 109 | ||
| 110 | let mut can = can::CanConfigurator::new(peripherals.FDCAN1, peripherals.PB8, peripherals.PB9, Irqs1); | 110 | let mut can = can::CanConfigurator::new(peripherals.FDCAN1, peripherals.PB8, peripherals.PB9, Irqs1); |
| 111 | let mut can2 = can::CanConfigurator::new(peripherals.FDCAN2, peripherals.PB12, peripherals.PB13, Irqs2); | 111 | let mut can2 = can::CanConfigurator::new(peripherals.FDCAN2, peripherals.PB12, peripherals.PB13, Irqs2); |
diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index 1d1018c5c..4a2584b4e 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs | |||
| @@ -10,7 +10,7 @@ use embassy_stm32::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull, Spe | |||
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(config()); | 13 | let p = init(); |
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | // Arduino pins D0 and D1 | 16 | // Arduino pins D0 and D1 |
diff --git a/tests/stm32/src/bin/hash.rs b/tests/stm32/src/bin/hash.rs index 5f54ea435..bdb3c9a69 100644 --- a/tests/stm32/src/bin/hash.rs +++ b/tests/stm32/src/bin/hash.rs | |||
| @@ -35,7 +35,7 @@ bind_interrupts!(struct Irqs { | |||
| 35 | 35 | ||
| 36 | #[embassy_executor::main] | 36 | #[embassy_executor::main] |
| 37 | async fn main(_spawner: Spawner) { | 37 | async fn main(_spawner: Spawner) { |
| 38 | let p: embassy_stm32::Peripherals = embassy_stm32::init(config()); | 38 | let p: embassy_stm32::Peripherals = init(); |
| 39 | let mut hw_hasher = Hash::new(p.HASH, NoDma, Irqs); | 39 | let mut hw_hasher = Hash::new(p.HASH, NoDma, Irqs); |
| 40 | 40 | ||
| 41 | let test_1: &[u8] = b"as;dfhaslfhas;oifvnasd;nifvnhasd;nifvhndlkfghsd;nvfnahssdfgsdafgsasdfasdfasdfasdfasdfghjklmnbvcalskdjghalskdjgfbaslkdjfgbalskdjgbalskdjbdfhsdfhsfghsfghfgh"; | 41 | let test_1: &[u8] = b"as;dfhaslfhas;oifvnasd;nifvnhasd;nifvhndlkfghsd;nvfnahssdfgsdafgsasdfasdfasdfasdfasdfghjklmnbvcalskdjghalskdjgfbaslkdjfgbalskdjgbalskdjbdfhsdfhsfghsfghfgh"; |
diff --git a/tests/stm32/src/bin/rng.rs b/tests/stm32/src/bin/rng.rs index 15ef4fb60..8438353a8 100644 --- a/tests/stm32/src/bin/rng.rs +++ b/tests/stm32/src/bin/rng.rs | |||
| @@ -41,7 +41,7 @@ bind_interrupts!(struct Irqs { | |||
| 41 | 41 | ||
| 42 | #[embassy_executor::main] | 42 | #[embassy_executor::main] |
| 43 | async fn main(_spawner: Spawner) { | 43 | async fn main(_spawner: Spawner) { |
| 44 | let p: embassy_stm32::Peripherals = embassy_stm32::init(config()); | 44 | let p: embassy_stm32::Peripherals = init(); |
| 45 | 45 | ||
| 46 | let mut rng = Rng::new(p.RNG, Irqs); | 46 | let mut rng = Rng::new(p.RNG, Irqs); |
| 47 | 47 | ||
diff --git a/tests/stm32/src/bin/rtc.rs b/tests/stm32/src/bin/rtc.rs index c04d616ac..5fe98d807 100644 --- a/tests/stm32/src/bin/rtc.rs +++ b/tests/stm32/src/bin/rtc.rs | |||
| @@ -18,7 +18,7 @@ async fn main(_spawner: Spawner) { | |||
| 18 | let mut config = config(); | 18 | let mut config = config(); |
| 19 | config.rcc.ls = LsConfig::default_lse(); | 19 | config.rcc.ls = LsConfig::default_lse(); |
| 20 | 20 | ||
| 21 | let p = embassy_stm32::init(config); | 21 | let p = init_with_config(config); |
| 22 | info!("Hello World!"); | 22 | info!("Hello World!"); |
| 23 | 23 | ||
| 24 | let now = NaiveDate::from_ymd_opt(2020, 5, 15) | 24 | let now = NaiveDate::from_ymd_opt(2020, 5, 15) |
diff --git a/tests/stm32/src/bin/sdmmc.rs b/tests/stm32/src/bin/sdmmc.rs index 54f55d2d6..a6bc117c0 100644 --- a/tests/stm32/src/bin/sdmmc.rs +++ b/tests/stm32/src/bin/sdmmc.rs | |||
| @@ -20,7 +20,7 @@ bind_interrupts!(struct Irqs { | |||
| 20 | async fn main(_spawner: Spawner) { | 20 | async fn main(_spawner: Spawner) { |
| 21 | info!("Hello World!"); | 21 | info!("Hello World!"); |
| 22 | 22 | ||
| 23 | let p = embassy_stm32::init(config()); | 23 | let p = init(); |
| 24 | 24 | ||
| 25 | let (mut sdmmc, mut dma, mut clk, mut cmd, mut d0, mut d1, mut d2, mut d3) = | 25 | let (mut sdmmc, mut dma, mut clk, mut cmd, mut d0, mut d1, mut d2, mut d3) = |
| 26 | (p.SDIO, p.DMA2_CH3, p.PC12, p.PD2, p.PC8, p.PC9, p.PC10, p.PC11); | 26 | (p.SDIO, p.DMA2_CH3, p.PC12, p.PD2, p.PC8, p.PC9, p.PC10, p.PC11); |
diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index 0ffd0f653..53d44a94a 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs | |||
| @@ -12,7 +12,7 @@ use embassy_stm32::time::Hertz; | |||
| 12 | 12 | ||
| 13 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner) { | 14 | async fn main(_spawner: Spawner) { |
| 15 | let p = embassy_stm32::init(config()); | 15 | let p = init(); |
| 16 | info!("Hello World!"); | 16 | info!("Hello World!"); |
| 17 | 17 | ||
| 18 | let mut spi_peri = peri!(p, SPI); | 18 | let mut spi_peri = peri!(p, SPI); |
diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index fd26d3f71..a1cbc0ed1 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs | |||
| @@ -12,7 +12,7 @@ use embassy_stm32::time::Hertz; | |||
| 12 | 12 | ||
| 13 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner) { | 14 | async fn main(_spawner: Spawner) { |
| 15 | let p = embassy_stm32::init(config()); | 15 | let p = init(); |
| 16 | info!("Hello World!"); | 16 | info!("Hello World!"); |
| 17 | 17 | ||
| 18 | let mut spi_peri = peri!(p, SPI); | 18 | let mut spi_peri = peri!(p, SPI); |
diff --git a/tests/stm32/src/bin/stop.rs b/tests/stm32/src/bin/stop.rs index c1106bb2f..772bc527c 100644 --- a/tests/stm32/src/bin/stop.rs +++ b/tests/stm32/src/bin/stop.rs | |||
| @@ -58,7 +58,7 @@ async fn async_main(spawner: Spawner) { | |||
| 58 | config.rcc.hsi = Some(HSIPrescaler::DIV4); // 64 MHz HSI will need a /4 | 58 | config.rcc.hsi = Some(HSIPrescaler::DIV4); // 64 MHz HSI will need a /4 |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | let p = embassy_stm32::init(config); | 61 | let p = init_with_config(config); |
| 62 | info!("Hello World!"); | 62 | info!("Hello World!"); |
| 63 | 63 | ||
| 64 | let now = NaiveDate::from_ymd_opt(2020, 5, 15) | 64 | let now = NaiveDate::from_ymd_opt(2020, 5, 15) |
diff --git a/tests/stm32/src/bin/timer.rs b/tests/stm32/src/bin/timer.rs index d86f54ad2..8719e7670 100644 --- a/tests/stm32/src/bin/timer.rs +++ b/tests/stm32/src/bin/timer.rs | |||
| @@ -10,7 +10,7 @@ use embassy_time::{Instant, Timer}; | |||
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let _p = embassy_stm32::init(config()); | 13 | let _p = init(); |
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let start = Instant::now(); | 16 | let start = Instant::now(); |
diff --git a/tests/stm32/src/bin/ucpd.rs b/tests/stm32/src/bin/ucpd.rs index c09334ec8..a6d13b34a 100644 --- a/tests/stm32/src/bin/ucpd.rs +++ b/tests/stm32/src/bin/ucpd.rs | |||
| @@ -102,7 +102,7 @@ async fn sink( | |||
| 102 | 102 | ||
| 103 | #[embassy_executor::main] | 103 | #[embassy_executor::main] |
| 104 | async fn main(_spawner: Spawner) { | 104 | async fn main(_spawner: Spawner) { |
| 105 | let p = embassy_stm32::init(config()); | 105 | let p = init(); |
| 106 | info!("Hello World!"); | 106 | info!("Hello World!"); |
| 107 | 107 | ||
| 108 | // Wire between PD0 and PA8 | 108 | // Wire between PD0 and PA8 |
diff --git a/tests/stm32/src/bin/usart.rs b/tests/stm32/src/bin/usart.rs index a6e34674d..53da30fff 100644 --- a/tests/stm32/src/bin/usart.rs +++ b/tests/stm32/src/bin/usart.rs | |||
| @@ -11,7 +11,7 @@ use embassy_time::{block_for, Duration, Instant}; | |||
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(config()); | 14 | let p = init(); |
| 15 | info!("Hello World!"); | 15 | info!("Hello World!"); |
| 16 | 16 | ||
| 17 | // Arduino pins D0 and D1 | 17 | // Arduino pins D0 and D1 |
diff --git a/tests/stm32/src/bin/usart_dma.rs b/tests/stm32/src/bin/usart_dma.rs index 24e2b2896..266b81809 100644 --- a/tests/stm32/src/bin/usart_dma.rs +++ b/tests/stm32/src/bin/usart_dma.rs | |||
| @@ -11,7 +11,7 @@ use embassy_stm32::usart::{Config, Uart}; | |||
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(config()); | 14 | let p = init(); |
| 15 | info!("Hello World!"); | 15 | info!("Hello World!"); |
| 16 | 16 | ||
| 17 | // Arduino pins D0 and D1 | 17 | // Arduino pins D0 and D1 |
diff --git a/tests/stm32/src/bin/usart_rx_ringbuffered.rs b/tests/stm32/src/bin/usart_rx_ringbuffered.rs index ea1e52358..98c7ef312 100644 --- a/tests/stm32/src/bin/usart_rx_ringbuffered.rs +++ b/tests/stm32/src/bin/usart_rx_ringbuffered.rs | |||
| @@ -18,7 +18,7 @@ const DMA_BUF_SIZE: usize = 256; | |||
| 18 | 18 | ||
| 19 | #[embassy_executor::main] | 19 | #[embassy_executor::main] |
| 20 | async fn main(spawner: Spawner) { | 20 | async fn main(spawner: Spawner) { |
| 21 | let p = embassy_stm32::init(config()); | 21 | let p = init(); |
| 22 | info!("Hello World!"); | 22 | info!("Hello World!"); |
| 23 | 23 | ||
| 24 | // Arduino pins D0 and D1 | 24 | // Arduino pins D0 and D1 |
diff --git a/tests/stm32/src/bin/wpan_ble.rs b/tests/stm32/src/bin/wpan_ble.rs index 82a540d45..fde1dfa9b 100644 --- a/tests/stm32/src/bin/wpan_ble.rs +++ b/tests/stm32/src/bin/wpan_ble.rs | |||
| @@ -41,7 +41,7 @@ async fn main(spawner: Spawner) { | |||
| 41 | let mut config = config(); | 41 | let mut config = config(); |
| 42 | config.rcc = WPAN_DEFAULT; | 42 | config.rcc = WPAN_DEFAULT; |
| 43 | 43 | ||
| 44 | let p = embassy_stm32::init(config); | 44 | let p = init_with_config(config); |
| 45 | info!("Hello World!"); | 45 | info!("Hello World!"); |
| 46 | 46 | ||
| 47 | let config = Config::default(); | 47 | let config = Config::default(); |
diff --git a/tests/stm32/src/bin/wpan_mac.rs b/tests/stm32/src/bin/wpan_mac.rs index fe53b8786..b65ace40f 100644 --- a/tests/stm32/src/bin/wpan_mac.rs +++ b/tests/stm32/src/bin/wpan_mac.rs | |||
| @@ -34,7 +34,7 @@ async fn main(spawner: Spawner) { | |||
| 34 | let mut config = config(); | 34 | let mut config = config(); |
| 35 | config.rcc = WPAN_DEFAULT; | 35 | config.rcc = WPAN_DEFAULT; |
| 36 | 36 | ||
| 37 | let p = embassy_stm32::init(config); | 37 | let p = init_with_config(config); |
| 38 | info!("Hello World!"); | 38 | info!("Hello World!"); |
| 39 | 39 | ||
| 40 | let config = Config::default(); | 40 | let config = Config::default(); |
diff --git a/tests/stm32/src/common.rs b/tests/stm32/src/common.rs index 4e0231858..935a41ed2 100644 --- a/tests/stm32/src/common.rs +++ b/tests/stm32/src/common.rs | |||
| @@ -699,3 +699,21 @@ pub fn config() -> Config { | |||
| 699 | 699 | ||
| 700 | config | 700 | config |
| 701 | } | 701 | } |
| 702 | |||
| 703 | #[allow(unused)] | ||
| 704 | pub fn init() -> embassy_stm32::Peripherals { | ||
| 705 | init_with_config(config()) | ||
| 706 | } | ||
| 707 | |||
| 708 | #[allow(unused)] | ||
| 709 | pub fn init_with_config(config: Config) -> embassy_stm32::Peripherals { | ||
| 710 | #[cfg(any(feature = "stm32wl55jc", feature = "stm32h755zi"))] | ||
| 711 | { | ||
| 712 | // Not in shared memory, but we're not running the second core, so it's fine | ||
| 713 | static SHARED_DATA: core::mem::MaybeUninit<embassy_stm32::SharedData> = core::mem::MaybeUninit::uninit(); | ||
| 714 | embassy_stm32::init_primary(config, &SHARED_DATA) | ||
| 715 | } | ||
| 716 | |||
| 717 | #[cfg(not(any(feature = "stm32wl55jc", feature = "stm32h755zi")))] | ||
| 718 | embassy_stm32::init(config) | ||
| 719 | } | ||
