diff options
| author | goueslati <[email protected]> | 2023-06-12 14:27:53 +0100 |
|---|---|---|
| committer | goueslati <[email protected]> | 2023-06-12 14:27:53 +0100 |
| commit | 2d89cfb18f00aefbfa108728dfea3398e80ea3e4 (patch) | |
| tree | 6485dacac7e61c4378ac522e709edb0a86bd7523 | |
| parent | 2dd5ce83ec0421564e85b667f5dabd592f313e5c (diff) | |
| parent | ab86b060500ceda1c80e39f35af69cb08a7b63a2 (diff) | |
fix merge conflict
146 files changed, 1594 insertions, 1393 deletions
diff --git a/.github/ci/doc.sh b/.github/ci/doc.sh index 736249368..72c6465f7 100755 --- a/.github/ci/doc.sh +++ b/.github/ci/doc.sh | |||
| @@ -14,7 +14,6 @@ docserver-builder -i ./embassy-boot/boot -o crates/embassy-boot/git.zup | |||
| 14 | docserver-builder -i ./embassy-boot/nrf -o crates/embassy-boot-nrf/git.zup | 14 | docserver-builder -i ./embassy-boot/nrf -o crates/embassy-boot-nrf/git.zup |
| 15 | docserver-builder -i ./embassy-boot/rp -o crates/embassy-boot-rp/git.zup | 15 | docserver-builder -i ./embassy-boot/rp -o crates/embassy-boot-rp/git.zup |
| 16 | docserver-builder -i ./embassy-boot/stm32 -o crates/embassy-boot-stm32/git.zup | 16 | docserver-builder -i ./embassy-boot/stm32 -o crates/embassy-boot-stm32/git.zup |
| 17 | docserver-builder -i ./embassy-cortex-m -o crates/embassy-cortex-m/git.zup | ||
| 18 | docserver-builder -i ./embassy-embedded-hal -o crates/embassy-embedded-hal/git.zup | 17 | docserver-builder -i ./embassy-embedded-hal -o crates/embassy-embedded-hal/git.zup |
| 19 | docserver-builder -i ./embassy-executor -o crates/embassy-executor/git.zup | 18 | docserver-builder -i ./embassy-executor -o crates/embassy-executor/git.zup |
| 20 | docserver-builder -i ./embassy-futures -o crates/embassy-futures/git.zup | 19 | docserver-builder -i ./embassy-futures -o crates/embassy-futures/git.zup |
| @@ -25,11 +25,19 @@ cargo batch \ | |||
| 25 | --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt \ | 25 | --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt \ |
| 26 | --- build --release --manifest-path embassy-sync/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt \ | 26 | --- build --release --manifest-path embassy-sync/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt \ |
| 27 | --- build --release --manifest-path embassy-time/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits,defmt,defmt-timestamp-uptime,tick-hz-32_768,generic-queue-8 \ | 27 | --- build --release --manifest-path embassy-time/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits,defmt,defmt-timestamp-uptime,tick-hz-32_768,generic-queue-8 \ |
| 28 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,medium-ethernet \ | 28 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,medium-ethernet \ |
| 29 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet \ | 29 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet \ |
| 30 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,unstable-traits \ | 30 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,unstable-traits \ |
| 31 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,nightly \ | 31 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,nightly \ |
| 32 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,unstable-traits,nightly \ | 32 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,unstable-traits,nightly \ |
| 33 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet \ | ||
| 34 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet,unstable-traits \ | ||
| 35 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet,nightly \ | ||
| 36 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet,unstable-traits,nightly \ | ||
| 37 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ethernet \ | ||
| 38 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ethernet,unstable-traits \ | ||
| 39 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ethernet,nightly \ | ||
| 40 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ethernet,unstable-traits,nightly \ | ||
| 33 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52805,gpiote,time-driver-rtc1 \ | 41 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52805,gpiote,time-driver-rtc1 \ |
| 34 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52810,gpiote,time-driver-rtc1 \ | 42 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52810,gpiote,time-driver-rtc1 \ |
| 35 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52811,gpiote,time-driver-rtc1 \ | 43 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52811,gpiote,time-driver-rtc1 \ |
| @@ -104,6 +112,7 @@ cargo batch \ | |||
| 104 | --- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-irq/Cargo.toml --target thumbv7em-none-eabi \ | 112 | --- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-irq/Cargo.toml --target thumbv7em-none-eabi \ |
| 105 | --- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml --target thumbv7em-none-eabi \ | 113 | --- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml --target thumbv7em-none-eabi \ |
| 106 | --- build --release --manifest-path examples/nrf52840/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/nrf52840 \ | 114 | --- build --release --manifest-path examples/nrf52840/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/nrf52840 \ |
| 115 | --- build --release --manifest-path examples/nrf52840-rtic/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/nrf52840-rtic \ | ||
| 107 | --- build --release --manifest-path examples/nrf5340/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/nrf5340 \ | 116 | --- build --release --manifest-path examples/nrf5340/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/nrf5340 \ |
| 108 | --- build --release --manifest-path examples/rp/Cargo.toml --target thumbv6m-none-eabi --out-dir out/examples/rp \ | 117 | --- build --release --manifest-path examples/rp/Cargo.toml --target thumbv6m-none-eabi --out-dir out/examples/rp \ |
| 109 | --- build --release --manifest-path examples/stm32f0/Cargo.toml --target thumbv6m-none-eabi --out-dir out/examples/stm32f0 \ | 118 | --- build --release --manifest-path examples/stm32f0/Cargo.toml --target thumbv6m-none-eabi --out-dir out/examples/stm32f0 \ |
| @@ -159,4 +168,4 @@ if [[ -z "${TELEPROBE_TOKEN-}" ]]; then | |||
| 159 | exit | 168 | exit |
| 160 | fi | 169 | fi |
| 161 | 170 | ||
| 162 | teleprobe client run -r out/tests \ No newline at end of file | 171 | teleprobe client run -r out/tests |
diff --git a/ci_stable.sh b/ci_stable.sh index a67087ffb..daae98961 100755 --- a/ci_stable.sh +++ b/ci_stable.sh | |||
| @@ -14,9 +14,11 @@ cargo batch \ | |||
| 14 | --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features log \ | 14 | --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features log \ |
| 15 | --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features defmt \ | 15 | --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features defmt \ |
| 16 | --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv6m-none-eabi --features defmt \ | 16 | --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv6m-none-eabi --features defmt \ |
| 17 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,medium-ethernet \ | 17 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,medium-ethernet \ |
| 18 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet \ | 18 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet \ |
| 19 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,unstable-traits \ | 19 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,unstable-traits \ |
| 20 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet \ | ||
| 21 | --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet,unstable-traits \ | ||
| 20 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52805,gpiote,time-driver-rtc1 \ | 22 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52805,gpiote,time-driver-rtc1 \ |
| 21 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52810,gpiote,time-driver-rtc1 \ | 23 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52810,gpiote,time-driver-rtc1 \ |
| 22 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52811,gpiote,time-driver-rtc1 \ | 24 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52811,gpiote,time-driver-rtc1 \ |
diff --git a/cyw43/src/control.rs b/cyw43/src/control.rs index 6919d569e..c67614dd6 100644 --- a/cyw43/src/control.rs +++ b/cyw43/src/control.rs | |||
| @@ -381,10 +381,7 @@ impl<'a> Control<'a> { | |||
| 381 | } | 381 | } |
| 382 | 382 | ||
| 383 | let ioctl = CancelOnDrop(self.ioctl_state); | 383 | let ioctl = CancelOnDrop(self.ioctl_state); |
| 384 | 384 | let resp_len = ioctl.0.do_ioctl(kind, cmd, iface, buf).await; | |
| 385 | ioctl.0.do_ioctl(kind, cmd, iface, buf).await; | ||
| 386 | let resp_len = ioctl.0.wait_complete().await; | ||
| 387 | |||
| 388 | ioctl.defuse(); | 385 | ioctl.defuse(); |
| 389 | 386 | ||
| 390 | resp_len | 387 | resp_len |
diff --git a/cyw43/src/fmt.rs b/cyw43/src/fmt.rs index 5730447b3..9534c101c 100644 --- a/cyw43/src/fmt.rs +++ b/cyw43/src/fmt.rs | |||
| @@ -197,9 +197,6 @@ macro_rules! unwrap { | |||
| 197 | } | 197 | } |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | #[cfg(feature = "defmt-timestamp-uptime")] | ||
| 201 | defmt::timestamp! {"{=u64:us}", crate::time::Instant::now().as_micros() } | ||
| 202 | |||
| 203 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | 200 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] |
| 204 | pub struct NoneError; | 201 | pub struct NoneError; |
| 205 | 202 | ||
diff --git a/embassy-cortex-m/Cargo.toml b/embassy-cortex-m/Cargo.toml deleted file mode 100644 index 70adda7df..000000000 --- a/embassy-cortex-m/Cargo.toml +++ /dev/null | |||
| @@ -1,45 +0,0 @@ | |||
| 1 | [package] | ||
| 2 | name = "embassy-cortex-m" | ||
| 3 | version = "0.1.0" | ||
| 4 | edition = "2021" | ||
| 5 | license = "MIT OR Apache-2.0" | ||
| 6 | |||
| 7 | [package.metadata.embassy_docs] | ||
| 8 | src_base = "https://github.com/embassy-rs/embassy/blob/embassy-cortex-m-v$VERSION/embassy-cortex-m/src/" | ||
| 9 | src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-cortex-m/src/" | ||
| 10 | features = ["prio-bits-3"] | ||
| 11 | flavors = [ | ||
| 12 | { name = "thumbv6m-none-eabi", target = "thumbv6m-none-eabi", features = [] }, | ||
| 13 | { name = "thumbv7m-none-eabi", target = "thumbv7m-none-eabi", features = [] }, | ||
| 14 | { name = "thumbv7em-none-eabi", target = "thumbv7em-none-eabi", features = [] }, | ||
| 15 | { name = "thumbv7em-none-eabihf", target = "thumbv7em-none-eabihf", features = [] }, | ||
| 16 | { name = "thumbv8m.main-none-eabihf", target = "thumbv8m.main-none-eabihf", features = [] }, | ||
| 17 | ] | ||
| 18 | |||
| 19 | [features] | ||
| 20 | default = [] | ||
| 21 | |||
| 22 | # Define the number of NVIC priority bits. | ||
| 23 | prio-bits-0 = [] | ||
| 24 | prio-bits-1 = [] | ||
| 25 | prio-bits-2 = [] | ||
| 26 | prio-bits-3 = [] | ||
| 27 | prio-bits-4 = [] | ||
| 28 | prio-bits-5 = [] | ||
| 29 | prio-bits-6 = [] | ||
| 30 | prio-bits-7 = [] | ||
| 31 | prio-bits-8 = [] | ||
| 32 | |||
| 33 | [dependencies] | ||
| 34 | defmt = { version = "0.3", optional = true } | ||
| 35 | log = { version = "0.4.14", optional = true } | ||
| 36 | |||
| 37 | embassy-sync = { version = "0.2.0", path = "../embassy-sync" } | ||
| 38 | embassy-executor = { version = "0.2.0", path = "../embassy-executor"} | ||
| 39 | embassy-macros = { version = "0.2.0", path = "../embassy-macros"} | ||
| 40 | embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common"} | ||
| 41 | atomic-polyfill = "1.0.1" | ||
| 42 | critical-section = "1.1" | ||
| 43 | cfg-if = "1.0.0" | ||
| 44 | cortex-m = "0.7.6" | ||
| 45 | |||
diff --git a/embassy-cortex-m/src/fmt.rs b/embassy-cortex-m/src/fmt.rs deleted file mode 100644 index f8bb0a035..000000000 --- a/embassy-cortex-m/src/fmt.rs +++ /dev/null | |||
| @@ -1,228 +0,0 @@ | |||
| 1 | #![macro_use] | ||
| 2 | #![allow(unused_macros)] | ||
| 3 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | ||
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | ||
| 6 | |||
| 7 | macro_rules! assert { | ||
| 8 | ($($x:tt)*) => { | ||
| 9 | { | ||
| 10 | #[cfg(not(feature = "defmt"))] | ||
| 11 | ::core::assert!($($x)*); | ||
| 12 | #[cfg(feature = "defmt")] | ||
| 13 | ::defmt::assert!($($x)*); | ||
| 14 | } | ||
| 15 | }; | ||
| 16 | } | ||
| 17 | |||
| 18 | macro_rules! assert_eq { | ||
| 19 | ($($x:tt)*) => { | ||
| 20 | { | ||
| 21 | #[cfg(not(feature = "defmt"))] | ||
| 22 | ::core::assert_eq!($($x)*); | ||
| 23 | #[cfg(feature = "defmt")] | ||
| 24 | ::defmt::assert_eq!($($x)*); | ||
| 25 | } | ||
| 26 | }; | ||
| 27 | } | ||
| 28 | |||
| 29 | macro_rules! assert_ne { | ||
| 30 | ($($x:tt)*) => { | ||
| 31 | { | ||
| 32 | #[cfg(not(feature = "defmt"))] | ||
| 33 | ::core::assert_ne!($($x)*); | ||
| 34 | #[cfg(feature = "defmt")] | ||
| 35 | ::defmt::assert_ne!($($x)*); | ||
| 36 | } | ||
| 37 | }; | ||
| 38 | } | ||
| 39 | |||
| 40 | macro_rules! debug_assert { | ||
| 41 | ($($x:tt)*) => { | ||
| 42 | { | ||
| 43 | #[cfg(not(feature = "defmt"))] | ||
| 44 | ::core::debug_assert!($($x)*); | ||
| 45 | #[cfg(feature = "defmt")] | ||
| 46 | ::defmt::debug_assert!($($x)*); | ||
| 47 | } | ||
| 48 | }; | ||
| 49 | } | ||
| 50 | |||
| 51 | macro_rules! debug_assert_eq { | ||
| 52 | ($($x:tt)*) => { | ||
| 53 | { | ||
| 54 | #[cfg(not(feature = "defmt"))] | ||
| 55 | ::core::debug_assert_eq!($($x)*); | ||
| 56 | #[cfg(feature = "defmt")] | ||
| 57 | ::defmt::debug_assert_eq!($($x)*); | ||
| 58 | } | ||
| 59 | }; | ||
| 60 | } | ||
| 61 | |||
| 62 | macro_rules! debug_assert_ne { | ||
| 63 | ($($x:tt)*) => { | ||
| 64 | { | ||
| 65 | #[cfg(not(feature = "defmt"))] | ||
| 66 | ::core::debug_assert_ne!($($x)*); | ||
| 67 | #[cfg(feature = "defmt")] | ||
| 68 | ::defmt::debug_assert_ne!($($x)*); | ||
| 69 | } | ||
| 70 | }; | ||
| 71 | } | ||
| 72 | |||
| 73 | macro_rules! todo { | ||
| 74 | ($($x:tt)*) => { | ||
| 75 | { | ||
| 76 | #[cfg(not(feature = "defmt"))] | ||
| 77 | ::core::todo!($($x)*); | ||
| 78 | #[cfg(feature = "defmt")] | ||
| 79 | ::defmt::todo!($($x)*); | ||
| 80 | } | ||
| 81 | }; | ||
| 82 | } | ||
| 83 | |||
| 84 | macro_rules! unreachable { | ||
| 85 | ($($x:tt)*) => { | ||
| 86 | { | ||
| 87 | #[cfg(not(feature = "defmt"))] | ||
| 88 | ::core::unreachable!($($x)*); | ||
| 89 | #[cfg(feature = "defmt")] | ||
| 90 | ::defmt::unreachable!($($x)*); | ||
| 91 | } | ||
| 92 | }; | ||
| 93 | } | ||
| 94 | |||
| 95 | macro_rules! panic { | ||
| 96 | ($($x:tt)*) => { | ||
| 97 | { | ||
| 98 | #[cfg(not(feature = "defmt"))] | ||
| 99 | ::core::panic!($($x)*); | ||
| 100 | #[cfg(feature = "defmt")] | ||
| 101 | ::defmt::panic!($($x)*); | ||
| 102 | } | ||
| 103 | }; | ||
| 104 | } | ||
| 105 | |||
| 106 | macro_rules! trace { | ||
| 107 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 108 | { | ||
| 109 | #[cfg(feature = "log")] | ||
| 110 | ::log::trace!($s $(, $x)*); | ||
| 111 | #[cfg(feature = "defmt")] | ||
| 112 | ::defmt::trace!($s $(, $x)*); | ||
| 113 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 114 | let _ = ($( & $x ),*); | ||
| 115 | } | ||
| 116 | }; | ||
| 117 | } | ||
| 118 | |||
| 119 | macro_rules! debug { | ||
| 120 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 121 | { | ||
| 122 | #[cfg(feature = "log")] | ||
| 123 | ::log::debug!($s $(, $x)*); | ||
| 124 | #[cfg(feature = "defmt")] | ||
| 125 | ::defmt::debug!($s $(, $x)*); | ||
| 126 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 127 | let _ = ($( & $x ),*); | ||
| 128 | } | ||
| 129 | }; | ||
| 130 | } | ||
| 131 | |||
| 132 | macro_rules! info { | ||
| 133 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 134 | { | ||
| 135 | #[cfg(feature = "log")] | ||
| 136 | ::log::info!($s $(, $x)*); | ||
| 137 | #[cfg(feature = "defmt")] | ||
| 138 | ::defmt::info!($s $(, $x)*); | ||
| 139 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 140 | let _ = ($( & $x ),*); | ||
| 141 | } | ||
| 142 | }; | ||
| 143 | } | ||
| 144 | |||
| 145 | macro_rules! warn { | ||
| 146 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 147 | { | ||
| 148 | #[cfg(feature = "log")] | ||
| 149 | ::log::warn!($s $(, $x)*); | ||
| 150 | #[cfg(feature = "defmt")] | ||
| 151 | ::defmt::warn!($s $(, $x)*); | ||
| 152 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 153 | let _ = ($( & $x ),*); | ||
| 154 | } | ||
| 155 | }; | ||
| 156 | } | ||
| 157 | |||
| 158 | macro_rules! error { | ||
| 159 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 160 | { | ||
| 161 | #[cfg(feature = "log")] | ||
| 162 | ::log::error!($s $(, $x)*); | ||
| 163 | #[cfg(feature = "defmt")] | ||
| 164 | ::defmt::error!($s $(, $x)*); | ||
| 165 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 166 | let _ = ($( & $x ),*); | ||
| 167 | } | ||
| 168 | }; | ||
| 169 | } | ||
| 170 | |||
| 171 | #[cfg(feature = "defmt")] | ||
| 172 | macro_rules! unwrap { | ||
| 173 | ($($x:tt)*) => { | ||
| 174 | ::defmt::unwrap!($($x)*) | ||
| 175 | }; | ||
| 176 | } | ||
| 177 | |||
| 178 | #[cfg(not(feature = "defmt"))] | ||
| 179 | macro_rules! unwrap { | ||
| 180 | ($arg:expr) => { | ||
| 181 | match $crate::fmt::Try::into_result($arg) { | ||
| 182 | ::core::result::Result::Ok(t) => t, | ||
| 183 | ::core::result::Result::Err(e) => { | ||
| 184 | ::core::panic!("unwrap of `{}` failed: {:?}", ::core::stringify!($arg), e); | ||
| 185 | } | ||
| 186 | } | ||
| 187 | }; | ||
| 188 | ($arg:expr, $($msg:expr),+ $(,)? ) => { | ||
| 189 | match $crate::fmt::Try::into_result($arg) { | ||
| 190 | ::core::result::Result::Ok(t) => t, | ||
| 191 | ::core::result::Result::Err(e) => { | ||
| 192 | ::core::panic!("unwrap of `{}` failed: {}: {:?}", ::core::stringify!($arg), ::core::format_args!($($msg,)*), e); | ||
| 193 | } | ||
| 194 | } | ||
| 195 | } | ||
| 196 | } | ||
| 197 | |||
| 198 | #[cfg(feature = "defmt-timestamp-uptime")] | ||
| 199 | defmt::timestamp! {"{=u64:us}", crate::time::Instant::now().as_micros() } | ||
| 200 | |||
| 201 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
| 202 | pub struct NoneError; | ||
| 203 | |||
| 204 | pub trait Try { | ||
| 205 | type Ok; | ||
| 206 | type Error; | ||
| 207 | fn into_result(self) -> Result<Self::Ok, Self::Error>; | ||
| 208 | } | ||
| 209 | |||
| 210 | impl<T> Try for Option<T> { | ||
| 211 | type Ok = T; | ||
| 212 | type Error = NoneError; | ||
| 213 | |||
| 214 | #[inline] | ||
| 215 | fn into_result(self) -> Result<T, NoneError> { | ||
| 216 | self.ok_or(NoneError) | ||
| 217 | } | ||
| 218 | } | ||
| 219 | |||
| 220 | impl<T, E> Try for Result<T, E> { | ||
| 221 | type Ok = T; | ||
| 222 | type Error = E; | ||
| 223 | |||
| 224 | #[inline] | ||
| 225 | fn into_result(self) -> Self { | ||
| 226 | self | ||
| 227 | } | ||
| 228 | } | ||
diff --git a/embassy-cortex-m/src/lib.rs b/embassy-cortex-m/src/lib.rs deleted file mode 100644 index 7bc16d3ba..000000000 --- a/embassy-cortex-m/src/lib.rs +++ /dev/null | |||
| @@ -1,9 +0,0 @@ | |||
| 1 | //! Embassy executor and interrupt handling specific to cortex-m devices. | ||
| 2 | #![no_std] | ||
| 3 | #![warn(missing_docs)] | ||
| 4 | |||
| 5 | // This mod MUST go first, so that the others see its macros. | ||
| 6 | pub(crate) mod fmt; | ||
| 7 | |||
| 8 | pub use embassy_executor as executor; | ||
| 9 | pub mod interrupt; | ||
diff --git a/embassy-futures/src/fmt.rs b/embassy-futures/src/fmt.rs index f8bb0a035..066970813 100644 --- a/embassy-futures/src/fmt.rs +++ b/embassy-futures/src/fmt.rs | |||
| @@ -195,9 +195,6 @@ macro_rules! unwrap { | |||
| 195 | } | 195 | } |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | #[cfg(feature = "defmt-timestamp-uptime")] | ||
| 199 | defmt::timestamp! {"{=u64:us}", crate::time::Instant::now().as_micros() } | ||
| 200 | |||
| 201 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | 198 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] |
| 202 | pub struct NoneError; | 199 | pub struct NoneError; |
| 203 | 200 | ||
diff --git a/embassy-hal-common/Cargo.toml b/embassy-hal-common/Cargo.toml index e8617c02f..18c758d7b 100644 --- a/embassy-hal-common/Cargo.toml +++ b/embassy-hal-common/Cargo.toml | |||
| @@ -6,8 +6,24 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [features] | 7 | [features] |
| 8 | 8 | ||
| 9 | # Define the number of NVIC priority bits. | ||
| 10 | prio-bits-0 = [] | ||
| 11 | prio-bits-1 = [] | ||
| 12 | prio-bits-2 = [] | ||
| 13 | prio-bits-3 = [] | ||
| 14 | prio-bits-4 = [] | ||
| 15 | prio-bits-5 = [] | ||
| 16 | prio-bits-6 = [] | ||
| 17 | prio-bits-7 = [] | ||
| 18 | prio-bits-8 = [] | ||
| 19 | |||
| 20 | cortex-m = ["dep:cortex-m", "dep:critical-section"] | ||
| 21 | |||
| 9 | [dependencies] | 22 | [dependencies] |
| 10 | defmt = { version = "0.3", optional = true } | 23 | defmt = { version = "0.3", optional = true } |
| 11 | log = { version = "0.4.14", optional = true } | 24 | log = { version = "0.4.14", optional = true } |
| 12 | 25 | ||
| 13 | num-traits = { version = "0.2.14", default-features = false } | 26 | num-traits = { version = "0.2.14", default-features = false } |
| 27 | |||
| 28 | cortex-m = { version = "0.7.6", optional = true } | ||
| 29 | critical-section = { version = "1", optional = true } \ No newline at end of file | ||
diff --git a/embassy-cortex-m/build.rs b/embassy-hal-common/build.rs index 6fe82b44f..6fe82b44f 100644 --- a/embassy-cortex-m/build.rs +++ b/embassy-hal-common/build.rs | |||
diff --git a/embassy-cortex-m/src/interrupt.rs b/embassy-hal-common/src/interrupt.rs index 0e790eaaf..b970aa2cd 100644 --- a/embassy-cortex-m/src/interrupt.rs +++ b/embassy-hal-common/src/interrupt.rs | |||
| @@ -2,120 +2,208 @@ | |||
| 2 | use core::mem; | 2 | use core::mem; |
| 3 | use core::sync::atomic::{compiler_fence, Ordering}; | 3 | use core::sync::atomic::{compiler_fence, Ordering}; |
| 4 | 4 | ||
| 5 | use cortex_m::interrupt::InterruptNumber; | ||
| 5 | use cortex_m::peripheral::NVIC; | 6 | use cortex_m::peripheral::NVIC; |
| 6 | 7 | ||
| 7 | /// Do not use. Used for macros and HALs only. Not covered by semver guarantees. | 8 | /// Generate a standard `mod interrupt` for a HAL. |
| 8 | #[doc(hidden)] | 9 | #[macro_export] |
| 9 | pub mod _export { | 10 | macro_rules! interrupt_mod { |
| 10 | pub use atomic_polyfill as atomic; | 11 | ($($irqs:ident),* $(,)?) => { |
| 11 | pub use embassy_macros::{cortex_m_interrupt as interrupt, cortex_m_interrupt_declare as declare}; | 12 | #[cfg(feature = "rt")] |
| 12 | } | 13 | pub use cortex_m_rt::interrupt; |
| 13 | 14 | ||
| 14 | /// Interrupt handler trait. | 15 | /// Interrupt definitions. |
| 15 | /// | 16 | pub mod interrupt { |
| 16 | /// Drivers that need to handle interrupts implement this trait. | 17 | pub use $crate::interrupt::{InterruptExt, Priority}; |
| 17 | /// The user must ensure `on_interrupt()` is called every time the interrupt fires. | 18 | pub use crate::pac::Interrupt::*; |
| 18 | /// Drivers must use use [`Binding`] to assert at compile time that the user has done so. | 19 | pub use crate::pac::Interrupt; |
| 19 | pub trait Handler<I: Interrupt> { | ||
| 20 | /// Interrupt handler function. | ||
| 21 | /// | ||
| 22 | /// Must be called every time the `I` interrupt fires, synchronously from | ||
| 23 | /// the interrupt handler context. | ||
| 24 | /// | ||
| 25 | /// # Safety | ||
| 26 | /// | ||
| 27 | /// This function must ONLY be called from the interrupt handler for `I`. | ||
| 28 | unsafe fn on_interrupt(); | ||
| 29 | } | ||
| 30 | 20 | ||
| 31 | /// Compile-time assertion that an interrupt has been bound to a handler. | 21 | /// Type-level interrupt infrastructure. |
| 32 | /// | 22 | /// |
| 33 | /// For the vast majority of cases, you should use the `bind_interrupts!` | 23 | /// This module contains one *type* per interrupt. This is used for checking at compile time that |
| 34 | /// macro instead of writing `unsafe impl`s of this trait. | 24 | /// the interrupts are correctly bound to HAL drivers. |
| 35 | /// | 25 | /// |
| 36 | /// # Safety | 26 | /// As an end user, you shouldn't need to use this module directly. Use the [`crate::bind_interrupts!`] macro |
| 37 | /// | 27 | /// to bind interrupts, and the [`crate::interrupt`] module to manually register interrupt handlers and manipulate |
| 38 | /// By implementing this trait, you are asserting that you have arranged for `H::on_interrupt()` | 28 | /// interrupts directly (pending/unpending, enabling/disabling, setting the priority, etc...) |
| 39 | /// to be called every time the `I` interrupt fires. | 29 | pub mod typelevel { |
| 40 | /// | 30 | use super::InterruptExt; |
| 41 | /// This allows drivers to check bindings at compile-time. | 31 | |
| 42 | pub unsafe trait Binding<I: Interrupt, H: Handler<I>> {} | 32 | mod sealed { |
| 43 | 33 | pub trait Interrupt {} | |
| 44 | #[derive(Clone, Copy)] | 34 | } |
| 45 | pub(crate) struct NrWrap(pub(crate) u16); | 35 | |
| 46 | unsafe impl cortex_m::interrupt::InterruptNumber for NrWrap { | 36 | /// Type-level interrupt. |
| 47 | fn number(self) -> u16 { | 37 | /// |
| 48 | self.0 | 38 | /// This trait is implemented for all typelevel interrupt types in this module. |
| 49 | } | 39 | pub trait Interrupt: sealed::Interrupt { |
| 40 | |||
| 41 | /// Interrupt enum variant. | ||
| 42 | /// | ||
| 43 | /// This allows going from typelevel interrupts (one type per interrupt) to | ||
| 44 | /// non-typelevel interrupts (a single `Interrupt` enum type, with one variant per interrupt). | ||
| 45 | const IRQ: super::Interrupt; | ||
| 46 | |||
| 47 | /// Enable the interrupt. | ||
| 48 | #[inline] | ||
| 49 | unsafe fn enable() { | ||
| 50 | Self::IRQ.enable() | ||
| 51 | } | ||
| 52 | |||
| 53 | /// Disable the interrupt. | ||
| 54 | #[inline] | ||
| 55 | fn disable() { | ||
| 56 | Self::IRQ.disable() | ||
| 57 | } | ||
| 58 | |||
| 59 | /// Check if interrupt is enabled. | ||
| 60 | #[inline] | ||
| 61 | fn is_enabled() -> bool { | ||
| 62 | Self::IRQ.is_enabled() | ||
| 63 | } | ||
| 64 | |||
| 65 | /// Check if interrupt is pending. | ||
| 66 | #[inline] | ||
| 67 | fn is_pending() -> bool { | ||
| 68 | Self::IRQ.is_pending() | ||
| 69 | } | ||
| 70 | |||
| 71 | /// Set interrupt pending. | ||
| 72 | #[inline] | ||
| 73 | fn pend() { | ||
| 74 | Self::IRQ.pend() | ||
| 75 | } | ||
| 76 | |||
| 77 | /// Unset interrupt pending. | ||
| 78 | #[inline] | ||
| 79 | fn unpend() { | ||
| 80 | Self::IRQ.unpend() | ||
| 81 | } | ||
| 82 | |||
| 83 | /// Get the priority of the interrupt. | ||
| 84 | #[inline] | ||
| 85 | fn get_priority() -> crate::interrupt::Priority { | ||
| 86 | Self::IRQ.get_priority() | ||
| 87 | } | ||
| 88 | |||
| 89 | /// Set the interrupt priority. | ||
| 90 | #[inline] | ||
| 91 | fn set_priority(prio: crate::interrupt::Priority) { | ||
| 92 | Self::IRQ.set_priority(prio) | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 96 | $( | ||
| 97 | #[allow(non_camel_case_types)] | ||
| 98 | #[doc=stringify!($irqs)] | ||
| 99 | #[doc=" typelevel interrupt."] | ||
| 100 | pub enum $irqs {} | ||
| 101 | impl sealed::Interrupt for $irqs{} | ||
| 102 | impl Interrupt for $irqs { | ||
| 103 | const IRQ: super::Interrupt = super::Interrupt::$irqs; | ||
| 104 | } | ||
| 105 | )* | ||
| 106 | |||
| 107 | /// Interrupt handler trait. | ||
| 108 | /// | ||
| 109 | /// Drivers that need to handle interrupts implement this trait. | ||
| 110 | /// The user must ensure `on_interrupt()` is called every time the interrupt fires. | ||
| 111 | /// Drivers must use use [`Binding`] to assert at compile time that the user has done so. | ||
| 112 | pub trait Handler<I: Interrupt> { | ||
| 113 | /// Interrupt handler function. | ||
| 114 | /// | ||
| 115 | /// Must be called every time the `I` interrupt fires, synchronously from | ||
| 116 | /// the interrupt handler context. | ||
| 117 | /// | ||
| 118 | /// # Safety | ||
| 119 | /// | ||
| 120 | /// This function must ONLY be called from the interrupt handler for `I`. | ||
| 121 | unsafe fn on_interrupt(); | ||
| 122 | } | ||
| 123 | |||
| 124 | /// Compile-time assertion that an interrupt has been bound to a handler. | ||
| 125 | /// | ||
| 126 | /// For the vast majority of cases, you should use the `bind_interrupts!` | ||
| 127 | /// macro instead of writing `unsafe impl`s of this trait. | ||
| 128 | /// | ||
| 129 | /// # Safety | ||
| 130 | /// | ||
| 131 | /// By implementing this trait, you are asserting that you have arranged for `H::on_interrupt()` | ||
| 132 | /// to be called every time the `I` interrupt fires. | ||
| 133 | /// | ||
| 134 | /// This allows drivers to check bindings at compile-time. | ||
| 135 | pub unsafe trait Binding<I: Interrupt, H: Handler<I>> {} | ||
| 136 | } | ||
| 137 | } | ||
| 138 | }; | ||
| 50 | } | 139 | } |
| 51 | 140 | ||
| 52 | /// Represents an interrupt type that can be configured by embassy to handle | 141 | /// Represents an interrupt type that can be configured by embassy to handle |
| 53 | /// interrupts. | 142 | /// interrupts. |
| 54 | pub unsafe trait Interrupt { | 143 | pub unsafe trait InterruptExt: InterruptNumber + Copy { |
| 55 | /// Return the NVIC interrupt number for this interrupt. | ||
| 56 | fn number() -> u16; | ||
| 57 | |||
| 58 | /// Enable the interrupt. | 144 | /// Enable the interrupt. |
| 59 | #[inline] | 145 | #[inline] |
| 60 | unsafe fn enable() { | 146 | unsafe fn enable(self) { |
| 61 | compiler_fence(Ordering::SeqCst); | 147 | compiler_fence(Ordering::SeqCst); |
| 62 | NVIC::unmask(NrWrap(Self::number())) | 148 | NVIC::unmask(self) |
| 63 | } | 149 | } |
| 64 | 150 | ||
| 65 | /// Disable the interrupt. | 151 | /// Disable the interrupt. |
| 66 | #[inline] | 152 | #[inline] |
| 67 | fn disable() { | 153 | fn disable(self) { |
| 68 | NVIC::mask(NrWrap(Self::number())); | 154 | NVIC::mask(self); |
| 69 | compiler_fence(Ordering::SeqCst); | 155 | compiler_fence(Ordering::SeqCst); |
| 70 | } | 156 | } |
| 71 | 157 | ||
| 72 | /// Check if interrupt is being handled. | 158 | /// Check if interrupt is being handled. |
| 73 | #[inline] | 159 | #[inline] |
| 74 | #[cfg(not(armv6m))] | 160 | #[cfg(not(armv6m))] |
| 75 | fn is_active() -> bool { | 161 | fn is_active(self) -> bool { |
| 76 | NVIC::is_active(NrWrap(Self::number())) | 162 | NVIC::is_active(self) |
| 77 | } | 163 | } |
| 78 | 164 | ||
| 79 | /// Check if interrupt is enabled. | 165 | /// Check if interrupt is enabled. |
| 80 | #[inline] | 166 | #[inline] |
| 81 | fn is_enabled() -> bool { | 167 | fn is_enabled(self) -> bool { |
| 82 | NVIC::is_enabled(NrWrap(Self::number())) | 168 | NVIC::is_enabled(self) |
| 83 | } | 169 | } |
| 84 | 170 | ||
| 85 | /// Check if interrupt is pending. | 171 | /// Check if interrupt is pending. |
| 86 | #[inline] | 172 | #[inline] |
| 87 | fn is_pending() -> bool { | 173 | fn is_pending(self) -> bool { |
| 88 | NVIC::is_pending(NrWrap(Self::number())) | 174 | NVIC::is_pending(self) |
| 89 | } | 175 | } |
| 90 | 176 | ||
| 91 | /// Set interrupt pending. | 177 | /// Set interrupt pending. |
| 92 | #[inline] | 178 | #[inline] |
| 93 | fn pend() { | 179 | fn pend(self) { |
| 94 | NVIC::pend(NrWrap(Self::number())) | 180 | NVIC::pend(self) |
| 95 | } | 181 | } |
| 96 | 182 | ||
| 97 | /// Unset interrupt pending. | 183 | /// Unset interrupt pending. |
| 98 | #[inline] | 184 | #[inline] |
| 99 | fn unpend() { | 185 | fn unpend(self) { |
| 100 | NVIC::unpend(NrWrap(Self::number())) | 186 | NVIC::unpend(self) |
| 101 | } | 187 | } |
| 102 | 188 | ||
| 103 | /// Get the priority of the interrupt. | 189 | /// Get the priority of the interrupt. |
| 104 | #[inline] | 190 | #[inline] |
| 105 | fn get_priority() -> Priority { | 191 | fn get_priority(self) -> Priority { |
| 106 | Priority::from(NVIC::get_priority(NrWrap(Self::number()))) | 192 | Priority::from(NVIC::get_priority(self)) |
| 107 | } | 193 | } |
| 108 | 194 | ||
| 109 | /// Set the interrupt priority. | 195 | /// Set the interrupt priority. |
| 110 | #[inline] | 196 | #[inline] |
| 111 | fn set_priority(prio: Priority) { | 197 | fn set_priority(self, prio: Priority) { |
| 112 | critical_section::with(|_| unsafe { | 198 | critical_section::with(|_| unsafe { |
| 113 | let mut nvic: cortex_m::peripheral::NVIC = mem::transmute(()); | 199 | let mut nvic: cortex_m::peripheral::NVIC = mem::transmute(()); |
| 114 | nvic.set_priority(NrWrap(Self::number()), prio.into()) | 200 | nvic.set_priority(self, prio.into()) |
| 115 | }) | 201 | }) |
| 116 | } | 202 | } |
| 117 | } | 203 | } |
| 118 | 204 | ||
| 205 | unsafe impl<T: InterruptNumber + Copy> InterruptExt for T {} | ||
| 206 | |||
| 119 | impl From<u8> for Priority { | 207 | impl From<u8> for Priority { |
| 120 | fn from(priority: u8) -> Self { | 208 | fn from(priority: u8) -> Self { |
| 121 | unsafe { mem::transmute(priority & PRIO_MASK) } | 209 | unsafe { mem::transmute(priority & PRIO_MASK) } |
diff --git a/embassy-hal-common/src/lib.rs b/embassy-hal-common/src/lib.rs index b2a35cd35..235964aa4 100644 --- a/embassy-hal-common/src/lib.rs +++ b/embassy-hal-common/src/lib.rs | |||
| @@ -11,3 +11,6 @@ mod peripheral; | |||
| 11 | pub mod ratio; | 11 | pub mod ratio; |
| 12 | pub mod ring_buffer; | 12 | pub mod ring_buffer; |
| 13 | pub use peripheral::{Peripheral, PeripheralRef}; | 13 | pub use peripheral::{Peripheral, PeripheralRef}; |
| 14 | |||
| 15 | #[cfg(feature = "cortex-m")] | ||
| 16 | pub mod interrupt; | ||
diff --git a/embassy-lora/src/iv.rs b/embassy-lora/src/iv.rs index 8d521040f..2e0b68d1a 100644 --- a/embassy-lora/src/iv.rs +++ b/embassy-lora/src/iv.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #[cfg(feature = "stm32wl")] | 1 | #[cfg(feature = "stm32wl")] |
| 2 | use embassy_stm32::interrupt; | 2 | use embassy_stm32::interrupt; |
| 3 | #[cfg(feature = "stm32wl")] | 3 | #[cfg(feature = "stm32wl")] |
| 4 | use embassy_stm32::interrupt::*; | 4 | use embassy_stm32::interrupt::InterruptExt; |
| 5 | #[cfg(feature = "stm32wl")] | 5 | #[cfg(feature = "stm32wl")] |
| 6 | use embassy_stm32::pac; | 6 | use embassy_stm32::pac; |
| 7 | #[cfg(feature = "stm32wl")] | 7 | #[cfg(feature = "stm32wl")] |
| @@ -20,9 +20,9 @@ use lora_phy::mod_traits::InterfaceVariant; | |||
| 20 | pub struct InterruptHandler {} | 20 | pub struct InterruptHandler {} |
| 21 | 21 | ||
| 22 | #[cfg(feature = "stm32wl")] | 22 | #[cfg(feature = "stm32wl")] |
| 23 | impl interrupt::Handler<interrupt::SUBGHZ_RADIO> for InterruptHandler { | 23 | impl interrupt::typelevel::Handler<interrupt::typelevel::SUBGHZ_RADIO> for InterruptHandler { |
| 24 | unsafe fn on_interrupt() { | 24 | unsafe fn on_interrupt() { |
| 25 | interrupt::SUBGHZ_RADIO::disable(); | 25 | interrupt::SUBGHZ_RADIO.disable(); |
| 26 | IRQ_SIGNAL.signal(()); | 26 | IRQ_SIGNAL.signal(()); |
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| @@ -45,11 +45,11 @@ where | |||
| 45 | { | 45 | { |
| 46 | /// Create an InterfaceVariant instance for an stm32wl/sx1262 combination | 46 | /// Create an InterfaceVariant instance for an stm32wl/sx1262 combination |
| 47 | pub fn new( | 47 | pub fn new( |
| 48 | _irq: impl interrupt::Binding<interrupt::SUBGHZ_RADIO, InterruptHandler>, | 48 | _irq: impl interrupt::typelevel::Binding<interrupt::typelevel::SUBGHZ_RADIO, InterruptHandler>, |
| 49 | rf_switch_rx: Option<CTRL>, | 49 | rf_switch_rx: Option<CTRL>, |
| 50 | rf_switch_tx: Option<CTRL>, | 50 | rf_switch_tx: Option<CTRL>, |
| 51 | ) -> Result<Self, RadioError> { | 51 | ) -> Result<Self, RadioError> { |
| 52 | interrupt::SUBGHZ_RADIO::disable(); | 52 | interrupt::SUBGHZ_RADIO.disable(); |
| 53 | Ok(Self { | 53 | Ok(Self { |
| 54 | board_type: BoardType::Stm32wlSx1262, // updated when associated with a specific LoRa board | 54 | board_type: BoardType::Stm32wlSx1262, // updated when associated with a specific LoRa board |
| 55 | rf_switch_rx, | 55 | rf_switch_rx, |
| @@ -95,7 +95,7 @@ where | |||
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | async fn await_irq(&mut self) -> Result<(), RadioError> { | 97 | async fn await_irq(&mut self) -> Result<(), RadioError> { |
| 98 | unsafe { interrupt::SUBGHZ_RADIO::enable() }; | 98 | unsafe { interrupt::SUBGHZ_RADIO.enable() }; |
| 99 | IRQ_SIGNAL.wait().await; | 99 | IRQ_SIGNAL.wait().await; |
| 100 | Ok(()) | 100 | Ok(()) |
| 101 | } | 101 | } |
diff --git a/embassy-macros/src/lib.rs b/embassy-macros/src/lib.rs index d7ca1f69c..ba4f13b77 100644 --- a/embassy-macros/src/lib.rs +++ b/embassy-macros/src/lib.rs | |||
| @@ -156,16 +156,3 @@ pub fn main_wasm(args: TokenStream, item: TokenStream) -> TokenStream { | |||
| 156 | let f = syn::parse_macro_input!(item as syn::ItemFn); | 156 | let f = syn::parse_macro_input!(item as syn::ItemFn); |
| 157 | main::run(args, f, main::wasm()).unwrap_or_else(|x| x).into() | 157 | main::run(args, f, main::wasm()).unwrap_or_else(|x| x).into() |
| 158 | } | 158 | } |
| 159 | |||
| 160 | #[proc_macro_attribute] | ||
| 161 | pub fn cortex_m_interrupt(args: TokenStream, item: TokenStream) -> TokenStream { | ||
| 162 | let args = syn::parse_macro_input!(args as syn::AttributeArgs); | ||
| 163 | let f = syn::parse_macro_input!(item as syn::ItemFn); | ||
| 164 | cortex_m_interrupt::run(args, f).unwrap_or_else(|x| x).into() | ||
| 165 | } | ||
| 166 | |||
| 167 | #[proc_macro] | ||
| 168 | pub fn cortex_m_interrupt_declare(item: TokenStream) -> TokenStream { | ||
| 169 | let name = syn::parse_macro_input!(item as syn::Ident); | ||
| 170 | cortex_m_interrupt_declare::run(name).unwrap_or_else(|x| x).into() | ||
| 171 | } | ||
diff --git a/embassy-macros/src/macros/cortex_m_interrupt.rs b/embassy-macros/src/macros/cortex_m_interrupt.rs deleted file mode 100644 index 13af8ca07..000000000 --- a/embassy-macros/src/macros/cortex_m_interrupt.rs +++ /dev/null | |||
| @@ -1,66 +0,0 @@ | |||
| 1 | use std::iter; | ||
| 2 | |||
| 3 | use darling::FromMeta; | ||
| 4 | use proc_macro2::TokenStream; | ||
| 5 | use quote::quote; | ||
| 6 | use syn::{ReturnType, Type, Visibility}; | ||
| 7 | |||
| 8 | use crate::util::ctxt::Ctxt; | ||
| 9 | |||
| 10 | #[derive(Debug, FromMeta)] | ||
| 11 | struct Args {} | ||
| 12 | |||
| 13 | pub fn run(args: syn::AttributeArgs, mut f: syn::ItemFn) -> Result<TokenStream, TokenStream> { | ||
| 14 | let _args = Args::from_list(&args).map_err(|e| e.write_errors())?; | ||
| 15 | |||
| 16 | let ident = f.sig.ident.clone(); | ||
| 17 | let ident_s = ident.to_string(); | ||
| 18 | |||
| 19 | // XXX should we blacklist other attributes? | ||
| 20 | |||
| 21 | let valid_signature = f.sig.constness.is_none() | ||
| 22 | && f.vis == Visibility::Inherited | ||
| 23 | && f.sig.abi.is_none() | ||
| 24 | && f.sig.inputs.is_empty() | ||
| 25 | && f.sig.generics.params.is_empty() | ||
| 26 | && f.sig.generics.where_clause.is_none() | ||
| 27 | && f.sig.variadic.is_none() | ||
| 28 | && match f.sig.output { | ||
| 29 | ReturnType::Default => true, | ||
| 30 | ReturnType::Type(_, ref ty) => match **ty { | ||
| 31 | Type::Tuple(ref tuple) => tuple.elems.is_empty(), | ||
| 32 | Type::Never(..) => true, | ||
| 33 | _ => false, | ||
| 34 | }, | ||
| 35 | }; | ||
| 36 | |||
| 37 | let ctxt = Ctxt::new(); | ||
| 38 | |||
| 39 | if !valid_signature { | ||
| 40 | ctxt.error_spanned_by( | ||
| 41 | &f.sig, | ||
| 42 | "`#[interrupt]` handlers must have signature `[unsafe] fn() [-> !]`", | ||
| 43 | ); | ||
| 44 | } | ||
| 45 | |||
| 46 | ctxt.check()?; | ||
| 47 | |||
| 48 | f.block.stmts = iter::once( | ||
| 49 | syn::parse2(quote! {{ | ||
| 50 | // Check that this interrupt actually exists | ||
| 51 | let __irq_exists_check: interrupt::#ident; | ||
| 52 | }}) | ||
| 53 | .unwrap(), | ||
| 54 | ) | ||
| 55 | .chain(f.block.stmts) | ||
| 56 | .collect(); | ||
| 57 | |||
| 58 | let result = quote!( | ||
| 59 | #[doc(hidden)] | ||
| 60 | #[export_name = #ident_s] | ||
| 61 | #[allow(non_snake_case)] | ||
| 62 | #f | ||
| 63 | ); | ||
| 64 | |||
| 65 | Ok(result) | ||
| 66 | } | ||
diff --git a/embassy-macros/src/macros/cortex_m_interrupt_declare.rs b/embassy-macros/src/macros/cortex_m_interrupt_declare.rs deleted file mode 100644 index b317482f5..000000000 --- a/embassy-macros/src/macros/cortex_m_interrupt_declare.rs +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | use proc_macro2::TokenStream; | ||
| 2 | use quote::{format_ident, quote}; | ||
| 3 | |||
| 4 | pub fn run(name: syn::Ident) -> Result<TokenStream, TokenStream> { | ||
| 5 | let name = format_ident!("{}", name); | ||
| 6 | let doc = format!("{} interrupt.", name); | ||
| 7 | |||
| 8 | let result = quote! { | ||
| 9 | #[doc = #doc] | ||
| 10 | #[allow(non_camel_case_types)] | ||
| 11 | pub enum #name{} | ||
| 12 | unsafe impl ::embassy_cortex_m::interrupt::Interrupt for #name { | ||
| 13 | fn number() -> u16 { | ||
| 14 | use cortex_m::interrupt::InterruptNumber; | ||
| 15 | let irq = InterruptEnum::#name; | ||
| 16 | irq.number() as u16 | ||
| 17 | } | ||
| 18 | } | ||
| 19 | }; | ||
| 20 | Ok(result) | ||
| 21 | } | ||
diff --git a/embassy-macros/src/macros/mod.rs b/embassy-macros/src/macros/mod.rs index a5e7a50e6..572094ca6 100644 --- a/embassy-macros/src/macros/mod.rs +++ b/embassy-macros/src/macros/mod.rs | |||
| @@ -1,4 +1,2 @@ | |||
| 1 | pub mod cortex_m_interrupt; | ||
| 2 | pub mod cortex_m_interrupt_declare; | ||
| 3 | pub mod main; | 1 | pub mod main; |
| 4 | pub mod task; | 2 | pub mod task; |
diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index 0a47c5d94..4ac572577 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml | |||
| @@ -26,7 +26,8 @@ unstable-traits = [] | |||
| 26 | udp = ["smoltcp/socket-udp"] | 26 | udp = ["smoltcp/socket-udp"] |
| 27 | tcp = ["smoltcp/socket-tcp"] | 27 | tcp = ["smoltcp/socket-tcp"] |
| 28 | dns = ["smoltcp/socket-dns", "smoltcp/proto-dns"] | 28 | dns = ["smoltcp/socket-dns", "smoltcp/proto-dns"] |
| 29 | dhcpv4 = ["medium-ethernet", "smoltcp/socket-dhcpv4"] | 29 | dhcpv4 = ["proto-ipv4", "medium-ethernet", "smoltcp/socket-dhcpv4"] |
| 30 | proto-ipv4 = ["smoltcp/proto-ipv4"] | ||
| 30 | proto-ipv6 = ["smoltcp/proto-ipv6"] | 31 | proto-ipv6 = ["smoltcp/proto-ipv6"] |
| 31 | medium-ethernet = ["smoltcp/medium-ethernet"] | 32 | medium-ethernet = ["smoltcp/medium-ethernet"] |
| 32 | medium-ip = ["smoltcp/medium-ip"] | 33 | medium-ip = ["smoltcp/medium-ip"] |
| @@ -38,7 +39,6 @@ defmt = { version = "0.3", optional = true } | |||
| 38 | log = { version = "0.4.14", optional = true } | 39 | log = { version = "0.4.14", optional = true } |
| 39 | 40 | ||
| 40 | smoltcp = { version = "0.9.0", default-features = false, features = [ | 41 | smoltcp = { version = "0.9.0", default-features = false, features = [ |
| 41 | "proto-ipv4", | ||
| 42 | "socket", | 42 | "socket", |
| 43 | "async", | 43 | "async", |
| 44 | ]} | 44 | ]} |
diff --git a/embassy-net/src/device.rs b/embassy-net/src/device.rs index 5daa00544..583cdc87f 100644 --- a/embassy-net/src/device.rs +++ b/embassy-net/src/device.rs | |||
| @@ -59,7 +59,10 @@ where | |||
| 59 | smolcaps.checksum.ipv4 = convert(caps.checksum.ipv4); | 59 | smolcaps.checksum.ipv4 = convert(caps.checksum.ipv4); |
| 60 | smolcaps.checksum.tcp = convert(caps.checksum.tcp); | 60 | smolcaps.checksum.tcp = convert(caps.checksum.tcp); |
| 61 | smolcaps.checksum.udp = convert(caps.checksum.udp); | 61 | smolcaps.checksum.udp = convert(caps.checksum.udp); |
| 62 | smolcaps.checksum.icmpv4 = convert(caps.checksum.icmpv4); | 62 | #[cfg(feature = "proto-ipv4")] |
| 63 | { | ||
| 64 | smolcaps.checksum.icmpv4 = convert(caps.checksum.icmpv4); | ||
| 65 | } | ||
| 63 | #[cfg(feature = "proto-ipv6")] | 66 | #[cfg(feature = "proto-ipv6")] |
| 64 | { | 67 | { |
| 65 | smolcaps.checksum.icmpv6 = convert(caps.checksum.icmpv6); | 68 | smolcaps.checksum.icmpv6 = convert(caps.checksum.icmpv6); |
diff --git a/embassy-net/src/dns.rs b/embassy-net/src/dns.rs index 3fd235b2c..94f75f108 100644 --- a/embassy-net/src/dns.rs +++ b/embassy-net/src/dns.rs | |||
| @@ -88,6 +88,7 @@ where | |||
| 88 | let addrs = self.query(host, qtype).await?; | 88 | let addrs = self.query(host, qtype).await?; |
| 89 | if let Some(first) = addrs.get(0) { | 89 | if let Some(first) = addrs.get(0) { |
| 90 | Ok(match first { | 90 | Ok(match first { |
| 91 | #[cfg(feature = "proto-ipv4")] | ||
| 91 | IpAddress::Ipv4(addr) => IpAddr::V4(addr.0.into()), | 92 | IpAddress::Ipv4(addr) => IpAddr::V4(addr.0.into()), |
| 92 | #[cfg(feature = "proto-ipv6")] | 93 | #[cfg(feature = "proto-ipv6")] |
| 93 | IpAddress::Ipv6(addr) => IpAddr::V6(addr.0.into()), | 94 | IpAddress::Ipv6(addr) => IpAddr::V6(addr.0.into()), |
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs index bccbad521..7e8f765f9 100644 --- a/embassy-net/src/lib.rs +++ b/embassy-net/src/lib.rs | |||
| @@ -34,7 +34,9 @@ use smoltcp::socket::dhcpv4::{self, RetryConfig}; | |||
| 34 | pub use smoltcp::wire::IpListenEndpoint; | 34 | pub use smoltcp::wire::IpListenEndpoint; |
| 35 | #[cfg(feature = "medium-ethernet")] | 35 | #[cfg(feature = "medium-ethernet")] |
| 36 | pub use smoltcp::wire::{EthernetAddress, HardwareAddress}; | 36 | pub use smoltcp::wire::{EthernetAddress, HardwareAddress}; |
| 37 | pub use smoltcp::wire::{IpAddress, IpCidr, Ipv4Address, Ipv4Cidr}; | 37 | pub use smoltcp::wire::{IpAddress, IpCidr}; |
| 38 | #[cfg(feature = "proto-ipv4")] | ||
| 39 | pub use smoltcp::wire::{Ipv4Address, Ipv4Cidr}; | ||
| 38 | #[cfg(feature = "proto-ipv6")] | 40 | #[cfg(feature = "proto-ipv6")] |
| 39 | pub use smoltcp::wire::{Ipv6Address, Ipv6Cidr}; | 41 | pub use smoltcp::wire::{Ipv6Address, Ipv6Cidr}; |
| 40 | 42 | ||
| @@ -67,8 +69,9 @@ impl<const SOCK: usize> StackResources<SOCK> { | |||
| 67 | } | 69 | } |
| 68 | 70 | ||
| 69 | /// Static IP address configuration. | 71 | /// Static IP address configuration. |
| 72 | #[cfg(feature = "proto-ipv4")] | ||
| 70 | #[derive(Debug, Clone, PartialEq, Eq)] | 73 | #[derive(Debug, Clone, PartialEq, Eq)] |
| 71 | pub struct StaticConfig { | 74 | pub struct StaticConfigV4 { |
| 72 | /// IP address and subnet mask. | 75 | /// IP address and subnet mask. |
| 73 | pub address: Ipv4Cidr, | 76 | pub address: Ipv4Cidr, |
| 74 | /// Default gateway. | 77 | /// Default gateway. |
| @@ -77,6 +80,18 @@ pub struct StaticConfig { | |||
| 77 | pub dns_servers: Vec<Ipv4Address, 3>, | 80 | pub dns_servers: Vec<Ipv4Address, 3>, |
| 78 | } | 81 | } |
| 79 | 82 | ||
| 83 | /// Static IPv6 address configuration | ||
| 84 | #[cfg(feature = "proto-ipv6")] | ||
| 85 | #[derive(Debug, Clone, PartialEq, Eq)] | ||
| 86 | pub struct StaticConfigV6 { | ||
| 87 | /// IP address and subnet mask. | ||
| 88 | pub address: Ipv6Cidr, | ||
| 89 | /// Default gateway. | ||
| 90 | pub gateway: Option<Ipv6Address>, | ||
| 91 | /// DNS servers. | ||
| 92 | pub dns_servers: Vec<Ipv6Address, 3>, | ||
| 93 | } | ||
| 94 | |||
| 80 | /// DHCP configuration. | 95 | /// DHCP configuration. |
| 81 | #[cfg(feature = "dhcpv4")] | 96 | #[cfg(feature = "dhcpv4")] |
| 82 | #[derive(Debug, Clone, PartialEq, Eq)] | 97 | #[derive(Debug, Clone, PartialEq, Eq)] |
| @@ -112,12 +127,71 @@ impl Default for DhcpConfig { | |||
| 112 | } | 127 | } |
| 113 | 128 | ||
| 114 | /// Network stack configuration. | 129 | /// Network stack configuration. |
| 115 | pub enum Config { | 130 | pub struct Config { |
| 116 | /// Use a static IP address configuration. | 131 | /// IPv4 configuration |
| 117 | Static(StaticConfig), | 132 | #[cfg(feature = "proto-ipv4")] |
| 133 | pub ipv4: ConfigV4, | ||
| 134 | /// IPv6 configuration | ||
| 135 | #[cfg(feature = "proto-ipv6")] | ||
| 136 | pub ipv6: ConfigV6, | ||
| 137 | } | ||
| 138 | |||
| 139 | impl Config { | ||
| 140 | /// IPv4 configuration with static addressing. | ||
| 141 | #[cfg(feature = "proto-ipv4")] | ||
| 142 | pub fn ipv4_static(config: StaticConfigV4) -> Self { | ||
| 143 | Self { | ||
| 144 | ipv4: ConfigV4::Static(config), | ||
| 145 | #[cfg(feature = "proto-ipv6")] | ||
| 146 | ipv6: ConfigV6::None, | ||
| 147 | } | ||
| 148 | } | ||
| 149 | |||
| 150 | /// IPv6 configuration with static addressing. | ||
| 151 | #[cfg(feature = "proto-ipv6")] | ||
| 152 | pub fn ipv6_static(config: StaticConfigV6) -> Self { | ||
| 153 | Self { | ||
| 154 | #[cfg(feature = "proto-ipv4")] | ||
| 155 | ipv4: ConfigV4::None, | ||
| 156 | ipv6: ConfigV6::Static(config), | ||
| 157 | } | ||
| 158 | } | ||
| 159 | |||
| 160 | /// IPv6 configuration with dynamic addressing. | ||
| 161 | /// | ||
| 162 | /// # Example | ||
| 163 | /// ```rust | ||
| 164 | /// let _cfg = Config::dhcpv4(Default::default()); | ||
| 165 | /// ``` | ||
| 166 | #[cfg(feature = "dhcpv4")] | ||
| 167 | pub fn dhcpv4(config: DhcpConfig) -> Self { | ||
| 168 | Self { | ||
| 169 | ipv4: ConfigV4::Dhcp(config), | ||
| 170 | #[cfg(feature = "proto-ipv6")] | ||
| 171 | ipv6: ConfigV6::None, | ||
| 172 | } | ||
| 173 | } | ||
| 174 | } | ||
| 175 | |||
| 176 | /// Network stack IPv4 configuration. | ||
| 177 | #[cfg(feature = "proto-ipv4")] | ||
| 178 | pub enum ConfigV4 { | ||
| 179 | /// Use a static IPv4 address configuration. | ||
| 180 | Static(StaticConfigV4), | ||
| 118 | /// Use DHCP to obtain an IP address configuration. | 181 | /// Use DHCP to obtain an IP address configuration. |
| 119 | #[cfg(feature = "dhcpv4")] | 182 | #[cfg(feature = "dhcpv4")] |
| 120 | Dhcp(DhcpConfig), | 183 | Dhcp(DhcpConfig), |
| 184 | /// Do not configure IPv6. | ||
| 185 | None, | ||
| 186 | } | ||
| 187 | |||
| 188 | /// Network stack IPv6 configuration. | ||
| 189 | #[cfg(feature = "proto-ipv6")] | ||
| 190 | pub enum ConfigV6 { | ||
| 191 | /// Use a static IPv6 address configuration. | ||
| 192 | Static(StaticConfigV6), | ||
| 193 | /// Do not configure IPv6. | ||
| 194 | None, | ||
| 121 | } | 195 | } |
| 122 | 196 | ||
| 123 | /// A network stack. | 197 | /// A network stack. |
| @@ -131,7 +205,10 @@ pub struct Stack<D: Driver> { | |||
| 131 | struct Inner<D: Driver> { | 205 | struct Inner<D: Driver> { |
| 132 | device: D, | 206 | device: D, |
| 133 | link_up: bool, | 207 | link_up: bool, |
| 134 | config: Option<StaticConfig>, | 208 | #[cfg(feature = "proto-ipv4")] |
| 209 | static_v4: Option<StaticConfigV4>, | ||
| 210 | #[cfg(feature = "proto-ipv6")] | ||
| 211 | static_v6: Option<StaticConfigV6>, | ||
| 135 | #[cfg(feature = "dhcpv4")] | 212 | #[cfg(feature = "dhcpv4")] |
| 136 | dhcp_socket: Option<SocketHandle>, | 213 | dhcp_socket: Option<SocketHandle>, |
| 137 | #[cfg(feature = "dns")] | 214 | #[cfg(feature = "dns")] |
| @@ -187,7 +264,10 @@ impl<D: Driver + 'static> Stack<D> { | |||
| 187 | let mut inner = Inner { | 264 | let mut inner = Inner { |
| 188 | device, | 265 | device, |
| 189 | link_up: false, | 266 | link_up: false, |
| 190 | config: None, | 267 | #[cfg(feature = "proto-ipv4")] |
| 268 | static_v4: None, | ||
| 269 | #[cfg(feature = "proto-ipv6")] | ||
| 270 | static_v6: None, | ||
| 191 | #[cfg(feature = "dhcpv4")] | 271 | #[cfg(feature = "dhcpv4")] |
| 192 | dhcp_socket: None, | 272 | dhcp_socket: None, |
| 193 | #[cfg(feature = "dns")] | 273 | #[cfg(feature = "dns")] |
| @@ -199,17 +279,26 @@ impl<D: Driver + 'static> Stack<D> { | |||
| 199 | dns_waker: WakerRegistration::new(), | 279 | dns_waker: WakerRegistration::new(), |
| 200 | }; | 280 | }; |
| 201 | 281 | ||
| 202 | match config { | 282 | #[cfg(feature = "proto-ipv4")] |
| 203 | Config::Static(config) => { | 283 | match config.ipv4 { |
| 204 | inner.apply_config(&mut socket, config); | 284 | ConfigV4::Static(config) => { |
| 285 | inner.apply_config_v4(&mut socket, config); | ||
| 205 | } | 286 | } |
| 206 | #[cfg(feature = "dhcpv4")] | 287 | #[cfg(feature = "dhcpv4")] |
| 207 | Config::Dhcp(config) => { | 288 | ConfigV4::Dhcp(config) => { |
| 208 | let mut dhcp_socket = smoltcp::socket::dhcpv4::Socket::new(); | 289 | let mut dhcp_socket = smoltcp::socket::dhcpv4::Socket::new(); |
| 209 | inner.apply_dhcp_config(&mut dhcp_socket, config); | 290 | inner.apply_dhcp_config(&mut dhcp_socket, config); |
| 210 | let handle = socket.sockets.add(dhcp_socket); | 291 | let handle = socket.sockets.add(dhcp_socket); |
| 211 | inner.dhcp_socket = Some(handle); | 292 | inner.dhcp_socket = Some(handle); |
| 212 | } | 293 | } |
| 294 | ConfigV4::None => {} | ||
| 295 | } | ||
| 296 | #[cfg(feature = "proto-ipv6")] | ||
| 297 | match config.ipv6 { | ||
| 298 | ConfigV6::Static(config) => { | ||
| 299 | inner.apply_config_v6(&mut socket, config); | ||
| 300 | } | ||
| 301 | ConfigV6::None => {} | ||
| 213 | } | 302 | } |
| 214 | 303 | ||
| 215 | Self { | 304 | Self { |
| @@ -239,12 +328,40 @@ impl<D: Driver + 'static> Stack<D> { | |||
| 239 | /// Get whether the network stack has a valid IP configuration. | 328 | /// Get whether the network stack has a valid IP configuration. |
| 240 | /// This is true if the network stack has a static IP configuration or if DHCP has completed | 329 | /// This is true if the network stack has a static IP configuration or if DHCP has completed |
| 241 | pub fn is_config_up(&self) -> bool { | 330 | pub fn is_config_up(&self) -> bool { |
| 242 | self.with(|_s, i| i.config.is_some()) | 331 | let v4_up; |
| 332 | let v6_up; | ||
| 333 | |||
| 334 | #[cfg(feature = "proto-ipv4")] | ||
| 335 | { | ||
| 336 | v4_up = self.config_v4().is_some(); | ||
| 337 | } | ||
| 338 | #[cfg(not(feature = "proto-ipv4"))] | ||
| 339 | { | ||
| 340 | v4_up = false; | ||
| 341 | } | ||
| 342 | |||
| 343 | #[cfg(feature = "proto-ipv6")] | ||
| 344 | { | ||
| 345 | v6_up = self.config_v6().is_some(); | ||
| 346 | } | ||
| 347 | #[cfg(not(feature = "proto-ipv6"))] | ||
| 348 | { | ||
| 349 | v6_up = false; | ||
| 350 | } | ||
| 351 | |||
| 352 | v4_up || v6_up | ||
| 243 | } | 353 | } |
| 244 | 354 | ||
| 245 | /// Get the current IP configuration. | 355 | /// Get the current IPv4 configuration. |
| 246 | pub fn config(&self) -> Option<StaticConfig> { | 356 | #[cfg(feature = "proto-ipv4")] |
| 247 | self.with(|_s, i| i.config.clone()) | 357 | pub fn config_v4(&self) -> Option<StaticConfigV4> { |
| 358 | self.with(|_s, i| i.static_v4.clone()) | ||
| 359 | } | ||
| 360 | |||
| 361 | /// Get the current IPv6 configuration. | ||
| 362 | #[cfg(feature = "proto-ipv6")] | ||
| 363 | pub fn config_v6(&self) -> Option<StaticConfigV6> { | ||
| 364 | self.with(|_s, i| i.static_v6.clone()) | ||
| 248 | } | 365 | } |
| 249 | 366 | ||
| 250 | /// Run the network stack. | 367 | /// Run the network stack. |
| @@ -264,6 +381,7 @@ impl<D: Driver + 'static> Stack<D> { | |||
| 264 | pub async fn dns_query(&self, name: &str, qtype: dns::DnsQueryType) -> Result<Vec<IpAddress, 1>, dns::Error> { | 381 | pub async fn dns_query(&self, name: &str, qtype: dns::DnsQueryType) -> Result<Vec<IpAddress, 1>, dns::Error> { |
| 265 | // For A and AAAA queries we try detect whether `name` is just an IP address | 382 | // For A and AAAA queries we try detect whether `name` is just an IP address |
| 266 | match qtype { | 383 | match qtype { |
| 384 | #[cfg(feature = "proto-ipv4")] | ||
| 267 | dns::DnsQueryType::A => { | 385 | dns::DnsQueryType::A => { |
| 268 | if let Ok(ip) = name.parse().map(IpAddress::Ipv4) { | 386 | if let Ok(ip) = name.parse().map(IpAddress::Ipv4) { |
| 269 | return Ok([ip].into_iter().collect()); | 387 | return Ok([ip].into_iter().collect()); |
| @@ -374,7 +492,8 @@ impl SocketStack { | |||
| 374 | } | 492 | } |
| 375 | 493 | ||
| 376 | impl<D: Driver + 'static> Inner<D> { | 494 | impl<D: Driver + 'static> Inner<D> { |
| 377 | fn apply_config(&mut self, s: &mut SocketStack, config: StaticConfig) { | 495 | #[cfg(feature = "proto-ipv4")] |
| 496 | fn apply_config_v4(&mut self, s: &mut SocketStack, config: StaticConfigV4) { | ||
| 378 | #[cfg(feature = "medium-ethernet")] | 497 | #[cfg(feature = "medium-ethernet")] |
| 379 | let medium = self.device.capabilities().medium; | 498 | let medium = self.device.capabilities().medium; |
| 380 | 499 | ||
| @@ -403,14 +522,86 @@ impl<D: Driver + 'static> Inner<D> { | |||
| 403 | debug!(" DNS server {}: {}", i, s); | 522 | debug!(" DNS server {}: {}", i, s); |
| 404 | } | 523 | } |
| 405 | 524 | ||
| 525 | self.static_v4 = Some(config); | ||
| 526 | |||
| 406 | #[cfg(feature = "dns")] | 527 | #[cfg(feature = "dns")] |
| 407 | { | 528 | { |
| 408 | let socket = s.sockets.get_mut::<smoltcp::socket::dns::Socket>(self.dns_socket); | 529 | self.update_dns_servers(s) |
| 409 | let servers: Vec<IpAddress, 3> = config.dns_servers.iter().map(|c| IpAddress::Ipv4(*c)).collect(); | 530 | } |
| 410 | socket.update_servers(&servers[..]); | 531 | } |
| 532 | |||
| 533 | /// Replaces the current IPv6 static configuration with a newly supplied config. | ||
| 534 | #[cfg(feature = "proto-ipv6")] | ||
| 535 | fn apply_config_v6(&mut self, s: &mut SocketStack, config: StaticConfigV6) { | ||
| 536 | #[cfg(feature = "medium-ethernet")] | ||
| 537 | let medium = self.device.capabilities().medium; | ||
| 538 | |||
| 539 | debug!("Acquired IPv6 configuration:"); | ||
| 540 | |||
| 541 | debug!(" IP address: {}", config.address); | ||
| 542 | s.iface.update_ip_addrs(|addrs| { | ||
| 543 | if addrs.is_empty() { | ||
| 544 | addrs.push(IpCidr::Ipv6(config.address)).unwrap(); | ||
| 545 | } else { | ||
| 546 | addrs[0] = IpCidr::Ipv6(config.address); | ||
| 547 | } | ||
| 548 | }); | ||
| 549 | |||
| 550 | #[cfg(feature = "medium-ethernet")] | ||
| 551 | if Medium::Ethernet == medium { | ||
| 552 | if let Some(gateway) = config.gateway { | ||
| 553 | debug!(" Default gateway: {}", gateway); | ||
| 554 | s.iface.routes_mut().add_default_ipv6_route(gateway).unwrap(); | ||
| 555 | } else { | ||
| 556 | debug!(" Default gateway: None"); | ||
| 557 | s.iface.routes_mut().remove_default_ipv6_route(); | ||
| 558 | } | ||
| 559 | } | ||
| 560 | for (i, s) in config.dns_servers.iter().enumerate() { | ||
| 561 | debug!(" DNS server {}: {}", i, s); | ||
| 411 | } | 562 | } |
| 412 | 563 | ||
| 413 | self.config = Some(config) | 564 | self.static_v6 = Some(config); |
| 565 | |||
| 566 | #[cfg(feature = "dns")] | ||
| 567 | { | ||
| 568 | self.update_dns_servers(s) | ||
| 569 | } | ||
| 570 | } | ||
| 571 | |||
| 572 | #[cfg(feature = "dns")] | ||
| 573 | fn update_dns_servers(&mut self, s: &mut SocketStack) { | ||
| 574 | let socket = s.sockets.get_mut::<smoltcp::socket::dns::Socket>(self.dns_socket); | ||
| 575 | |||
| 576 | let servers_v4; | ||
| 577 | #[cfg(feature = "proto-ipv4")] | ||
| 578 | { | ||
| 579 | servers_v4 = self | ||
| 580 | .static_v4 | ||
| 581 | .iter() | ||
| 582 | .flat_map(|cfg| cfg.dns_servers.iter().map(|c| IpAddress::Ipv4(*c))); | ||
| 583 | }; | ||
| 584 | #[cfg(not(feature = "proto-ipv4"))] | ||
| 585 | { | ||
| 586 | servers_v4 = core::iter::empty(); | ||
| 587 | } | ||
| 588 | |||
| 589 | let servers_v6; | ||
| 590 | #[cfg(feature = "proto-ipv6")] | ||
| 591 | { | ||
| 592 | servers_v6 = self | ||
| 593 | .static_v6 | ||
| 594 | .iter() | ||
| 595 | .flat_map(|cfg| cfg.dns_servers.iter().map(|c| IpAddress::Ipv6(*c))); | ||
| 596 | } | ||
| 597 | #[cfg(not(feature = "proto-ipv6"))] | ||
| 598 | { | ||
| 599 | servers_v6 = core::iter::empty(); | ||
| 600 | } | ||
| 601 | |||
| 602 | // Prefer the v6 DNS servers over the v4 servers | ||
| 603 | let servers: Vec<IpAddress, 6> = servers_v6.chain(servers_v4).collect(); | ||
| 604 | socket.update_servers(&servers[..]); | ||
| 414 | } | 605 | } |
| 415 | 606 | ||
| 416 | #[cfg(feature = "dhcpv4")] | 607 | #[cfg(feature = "dhcpv4")] |
| @@ -430,9 +621,15 @@ impl<D: Driver + 'static> Inner<D> { | |||
| 430 | s.iface.update_ip_addrs(|ip_addrs| ip_addrs.clear()); | 621 | s.iface.update_ip_addrs(|ip_addrs| ip_addrs.clear()); |
| 431 | #[cfg(feature = "medium-ethernet")] | 622 | #[cfg(feature = "medium-ethernet")] |
| 432 | if medium == Medium::Ethernet { | 623 | if medium == Medium::Ethernet { |
| 433 | s.iface.routes_mut().remove_default_ipv4_route(); | 624 | #[cfg(feature = "proto-ipv4")] |
| 625 | { | ||
| 626 | s.iface.routes_mut().remove_default_ipv4_route(); | ||
| 627 | } | ||
| 628 | } | ||
| 629 | #[cfg(feature = "proto-ipv4")] | ||
| 630 | { | ||
| 631 | self.static_v4 = None | ||
| 434 | } | 632 | } |
| 435 | self.config = None | ||
| 436 | } | 633 | } |
| 437 | 634 | ||
| 438 | fn poll(&mut self, cx: &mut Context<'_>, s: &mut SocketStack) { | 635 | fn poll(&mut self, cx: &mut Context<'_>, s: &mut SocketStack) { |
| @@ -470,12 +667,12 @@ impl<D: Driver + 'static> Inner<D> { | |||
| 470 | None => {} | 667 | None => {} |
| 471 | Some(dhcpv4::Event::Deconfigured) => self.unapply_config(s), | 668 | Some(dhcpv4::Event::Deconfigured) => self.unapply_config(s), |
| 472 | Some(dhcpv4::Event::Configured(config)) => { | 669 | Some(dhcpv4::Event::Configured(config)) => { |
| 473 | let config = StaticConfig { | 670 | let config = StaticConfigV4 { |
| 474 | address: config.address, | 671 | address: config.address, |
| 475 | gateway: config.router, | 672 | gateway: config.router, |
| 476 | dns_servers: config.dns_servers, | 673 | dns_servers: config.dns_servers, |
| 477 | }; | 674 | }; |
| 478 | self.apply_config(s, config) | 675 | self.apply_config_v4(s, config) |
| 479 | } | 676 | } |
| 480 | } | 677 | } |
| 481 | } else if old_link_up { | 678 | } else if old_link_up { |
diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index 515bbc5be..367675b13 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs | |||
| @@ -480,7 +480,10 @@ pub mod client { | |||
| 480 | Self: 'a, | 480 | Self: 'a, |
| 481 | { | 481 | { |
| 482 | let addr: crate::IpAddress = match remote.ip() { | 482 | let addr: crate::IpAddress = match remote.ip() { |
| 483 | #[cfg(feature = "proto-ipv4")] | ||
| 483 | IpAddr::V4(addr) => crate::IpAddress::Ipv4(crate::Ipv4Address::from_bytes(&addr.octets())), | 484 | IpAddr::V4(addr) => crate::IpAddress::Ipv4(crate::Ipv4Address::from_bytes(&addr.octets())), |
| 485 | #[cfg(not(feature = "proto-ipv4"))] | ||
| 486 | IpAddr::V4(_) => panic!("ipv4 support not enabled"), | ||
| 484 | #[cfg(feature = "proto-ipv6")] | 487 | #[cfg(feature = "proto-ipv6")] |
| 485 | IpAddr::V6(addr) => crate::IpAddress::Ipv6(crate::Ipv6Address::from_bytes(&addr.octets())), | 488 | IpAddr::V6(addr) => crate::IpAddress::Ipv6(crate::Ipv6Address::from_bytes(&addr.octets())), |
| 486 | #[cfg(not(feature = "proto-ipv6"))] | 489 | #[cfg(not(feature = "proto-ipv6"))] |
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 83900d4d0..3e858f854 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml | |||
| @@ -16,7 +16,8 @@ flavors = [ | |||
| 16 | ] | 16 | ] |
| 17 | 17 | ||
| 18 | [features] | 18 | [features] |
| 19 | default = [ | 19 | default = ["rt"] |
| 20 | rt = [ | ||
| 20 | "nrf52805-pac?/rt", | 21 | "nrf52805-pac?/rt", |
| 21 | "nrf52810-pac?/rt", | 22 | "nrf52810-pac?/rt", |
| 22 | "nrf52811-pac?/rt", | 23 | "nrf52811-pac?/rt", |
| @@ -31,7 +32,7 @@ default = [ | |||
| 31 | 32 | ||
| 32 | time = ["dep:embassy-time"] | 33 | time = ["dep:embassy-time"] |
| 33 | 34 | ||
| 34 | defmt = ["dep:defmt", "embassy-executor/defmt", "embassy-sync/defmt", "embassy-usb-driver?/defmt", "embedded-io?/defmt", "embassy-embedded-hal/defmt"] | 35 | defmt = ["dep:defmt", "embassy-sync/defmt", "embassy-usb-driver?/defmt", "embedded-io?/defmt", "embassy-embedded-hal/defmt"] |
| 35 | 36 | ||
| 36 | # Enable nightly-only features | 37 | # Enable nightly-only features |
| 37 | nightly = ["embedded-hal-1", "embedded-hal-async", "dep:embassy-usb-driver", "embedded-storage-async", "dep:embedded-io", "embassy-embedded-hal/nightly"] | 38 | nightly = ["embedded-hal-1", "embedded-hal-async", "dep:embassy-usb-driver", "embedded-storage-async", "dep:embedded-io", "embassy-embedded-hal/nightly"] |
| @@ -90,11 +91,9 @@ _dppi = [] | |||
| 90 | _gpio-p1 = [] | 91 | _gpio-p1 = [] |
| 91 | 92 | ||
| 92 | [dependencies] | 93 | [dependencies] |
| 93 | embassy-executor = { version = "0.2.0", path = "../embassy-executor", optional = true } | ||
| 94 | embassy-time = { version = "0.1.0", path = "../embassy-time", optional = true } | 94 | embassy-time = { version = "0.1.0", path = "../embassy-time", optional = true } |
| 95 | embassy-sync = { version = "0.2.0", path = "../embassy-sync" } | 95 | embassy-sync = { version = "0.2.0", path = "../embassy-sync" } |
| 96 | embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]} | 96 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common", features = ["cortex-m", "prio-bits-3"] } |
| 97 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } | ||
| 98 | embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } | 97 | embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } |
| 99 | embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional=true } | 98 | embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional=true } |
| 100 | 99 | ||
diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index b4fe2d874..9bc1c1e7a 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs | |||
| @@ -15,7 +15,6 @@ use core::slice; | |||
| 15 | use core::sync::atomic::{compiler_fence, AtomicU8, AtomicUsize, Ordering}; | 15 | use core::sync::atomic::{compiler_fence, AtomicU8, AtomicUsize, Ordering}; |
| 16 | use core::task::Poll; | 16 | use core::task::Poll; |
| 17 | 17 | ||
| 18 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 19 | use embassy_hal_common::atomic_ring_buffer::RingBuffer; | 18 | use embassy_hal_common::atomic_ring_buffer::RingBuffer; |
| 20 | use embassy_hal_common::{into_ref, PeripheralRef}; | 19 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 21 | use embassy_sync::waitqueue::AtomicWaker; | 20 | use embassy_sync::waitqueue::AtomicWaker; |
| @@ -24,13 +23,13 @@ pub use pac::uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Pari | |||
| 24 | 23 | ||
| 25 | use crate::gpio::sealed::Pin; | 24 | use crate::gpio::sealed::Pin; |
| 26 | use crate::gpio::{self, AnyPin, Pin as GpioPin, PselBits}; | 25 | use crate::gpio::{self, AnyPin, Pin as GpioPin, PselBits}; |
| 27 | use crate::interrupt::{self}; | 26 | use crate::interrupt::typelevel::Interrupt; |
| 28 | use crate::ppi::{ | 27 | use crate::ppi::{ |
| 29 | self, AnyConfigurableChannel, AnyGroup, Channel, ConfigurableChannel, Event, Group, Ppi, PpiGroup, Task, | 28 | self, AnyConfigurableChannel, AnyGroup, Channel, ConfigurableChannel, Event, Group, Ppi, PpiGroup, Task, |
| 30 | }; | 29 | }; |
| 31 | use crate::timer::{Instance as TimerInstance, Timer}; | 30 | use crate::timer::{Instance as TimerInstance, Timer}; |
| 32 | use crate::uarte::{apply_workaround_for_enable_anomaly, Config, Instance as UarteInstance}; | 31 | use crate::uarte::{apply_workaround_for_enable_anomaly, Config, Instance as UarteInstance}; |
| 33 | use crate::{pac, Peripheral}; | 32 | use crate::{interrupt, pac, Peripheral}; |
| 34 | 33 | ||
| 35 | mod sealed { | 34 | mod sealed { |
| 36 | use super::*; | 35 | use super::*; |
| @@ -77,7 +76,7 @@ pub struct InterruptHandler<U: UarteInstance> { | |||
| 77 | _phantom: PhantomData<U>, | 76 | _phantom: PhantomData<U>, |
| 78 | } | 77 | } |
| 79 | 78 | ||
| 80 | impl<U: UarteInstance> interrupt::Handler<U::Interrupt> for InterruptHandler<U> { | 79 | impl<U: UarteInstance> interrupt::typelevel::Handler<U::Interrupt> for InterruptHandler<U> { |
| 81 | unsafe fn on_interrupt() { | 80 | unsafe fn on_interrupt() { |
| 82 | //trace!("irq: start"); | 81 | //trace!("irq: start"); |
| 83 | let r = U::regs(); | 82 | let r = U::regs(); |
| @@ -202,7 +201,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { | |||
| 202 | ppi_ch1: impl Peripheral<P = impl ConfigurableChannel> + 'd, | 201 | ppi_ch1: impl Peripheral<P = impl ConfigurableChannel> + 'd, |
| 203 | ppi_ch2: impl Peripheral<P = impl ConfigurableChannel> + 'd, | 202 | ppi_ch2: impl Peripheral<P = impl ConfigurableChannel> + 'd, |
| 204 | ppi_group: impl Peripheral<P = impl Group> + 'd, | 203 | ppi_group: impl Peripheral<P = impl Group> + 'd, |
| 205 | _irq: impl interrupt::Binding<U::Interrupt, InterruptHandler<U>> + 'd, | 204 | _irq: impl interrupt::typelevel::Binding<U::Interrupt, InterruptHandler<U>> + 'd, |
| 206 | rxd: impl Peripheral<P = impl GpioPin> + 'd, | 205 | rxd: impl Peripheral<P = impl GpioPin> + 'd, |
| 207 | txd: impl Peripheral<P = impl GpioPin> + 'd, | 206 | txd: impl Peripheral<P = impl GpioPin> + 'd, |
| 208 | config: Config, | 207 | config: Config, |
| @@ -237,7 +236,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { | |||
| 237 | ppi_ch1: impl Peripheral<P = impl ConfigurableChannel> + 'd, | 236 | ppi_ch1: impl Peripheral<P = impl ConfigurableChannel> + 'd, |
| 238 | ppi_ch2: impl Peripheral<P = impl ConfigurableChannel> + 'd, | 237 | ppi_ch2: impl Peripheral<P = impl ConfigurableChannel> + 'd, |
| 239 | ppi_group: impl Peripheral<P = impl Group> + 'd, | 238 | ppi_group: impl Peripheral<P = impl Group> + 'd, |
| 240 | _irq: impl interrupt::Binding<U::Interrupt, InterruptHandler<U>> + 'd, | 239 | _irq: impl interrupt::typelevel::Binding<U::Interrupt, InterruptHandler<U>> + 'd, |
| 241 | rxd: impl Peripheral<P = impl GpioPin> + 'd, | 240 | rxd: impl Peripheral<P = impl GpioPin> + 'd, |
| 242 | txd: impl Peripheral<P = impl GpioPin> + 'd, | 241 | txd: impl Peripheral<P = impl GpioPin> + 'd, |
| 243 | cts: impl Peripheral<P = impl GpioPin> + 'd, | 242 | cts: impl Peripheral<P = impl GpioPin> + 'd, |
diff --git a/embassy-nrf/src/chips/nrf52805.rs b/embassy-nrf/src/chips/nrf52805.rs index e406c081b..8776000c8 100644 --- a/embassy-nrf/src/chips/nrf52805.rs +++ b/embassy-nrf/src/chips/nrf52805.rs | |||
| @@ -208,33 +208,29 @@ impl_ppi_channel!(PPI_CH31, 31 => static); | |||
| 208 | impl_saadc_input!(P0_04, ANALOG_INPUT2); | 208 | impl_saadc_input!(P0_04, ANALOG_INPUT2); |
| 209 | impl_saadc_input!(P0_05, ANALOG_INPUT3); | 209 | impl_saadc_input!(P0_05, ANALOG_INPUT3); |
| 210 | 210 | ||
| 211 | pub mod irqs { | 211 | embassy_hal_common::interrupt_mod!( |
| 212 | use embassy_cortex_m::interrupt::_export::declare; | 212 | POWER_CLOCK, |
| 213 | 213 | RADIO, | |
| 214 | use crate::pac::Interrupt as InterruptEnum; | 214 | UARTE0_UART0, |
| 215 | 215 | TWIM0_TWIS0_TWI0, | |
| 216 | declare!(POWER_CLOCK); | 216 | SPIM0_SPIS0_SPI0, |
| 217 | declare!(RADIO); | 217 | GPIOTE, |
| 218 | declare!(UARTE0_UART0); | 218 | SAADC, |
| 219 | declare!(TWIM0_TWIS0_TWI0); | 219 | TIMER0, |
| 220 | declare!(SPIM0_SPIS0_SPI0); | 220 | TIMER1, |
| 221 | declare!(GPIOTE); | 221 | TIMER2, |
| 222 | declare!(SAADC); | 222 | RTC0, |
| 223 | declare!(TIMER0); | 223 | TEMP, |
| 224 | declare!(TIMER1); | 224 | RNG, |
| 225 | declare!(TIMER2); | 225 | ECB, |
| 226 | declare!(RTC0); | 226 | CCM_AAR, |
| 227 | declare!(TEMP); | 227 | WDT, |
| 228 | declare!(RNG); | 228 | RTC1, |
| 229 | declare!(ECB); | 229 | QDEC, |
| 230 | declare!(CCM_AAR); | 230 | SWI0_EGU0, |
| 231 | declare!(WDT); | 231 | SWI1_EGU1, |
| 232 | declare!(RTC1); | 232 | SWI2, |
| 233 | declare!(QDEC); | 233 | SWI3, |
| 234 | declare!(SWI0_EGU0); | 234 | SWI4, |
| 235 | declare!(SWI1_EGU1); | 235 | SWI5, |
| 236 | declare!(SWI2); | 236 | ); |
| 237 | declare!(SWI3); | ||
| 238 | declare!(SWI4); | ||
| 239 | declare!(SWI5); | ||
| 240 | } | ||
diff --git a/embassy-nrf/src/chips/nrf52810.rs b/embassy-nrf/src/chips/nrf52810.rs index 153795e54..5519e8953 100644 --- a/embassy-nrf/src/chips/nrf52810.rs +++ b/embassy-nrf/src/chips/nrf52810.rs | |||
| @@ -234,36 +234,32 @@ impl_saadc_input!(P0_29, ANALOG_INPUT5); | |||
| 234 | impl_saadc_input!(P0_30, ANALOG_INPUT6); | 234 | impl_saadc_input!(P0_30, ANALOG_INPUT6); |
| 235 | impl_saadc_input!(P0_31, ANALOG_INPUT7); | 235 | impl_saadc_input!(P0_31, ANALOG_INPUT7); |
| 236 | 236 | ||
| 237 | pub mod irqs { | 237 | embassy_hal_common::interrupt_mod!( |
| 238 | use embassy_cortex_m::interrupt::_export::declare; | 238 | POWER_CLOCK, |
| 239 | 239 | RADIO, | |
| 240 | use crate::pac::Interrupt as InterruptEnum; | 240 | UARTE0_UART0, |
| 241 | 241 | TWIM0_TWIS0_TWI0, | |
| 242 | declare!(POWER_CLOCK); | 242 | SPIM0_SPIS0_SPI0, |
| 243 | declare!(RADIO); | 243 | GPIOTE, |
| 244 | declare!(UARTE0_UART0); | 244 | SAADC, |
| 245 | declare!(TWIM0_TWIS0_TWI0); | 245 | TIMER0, |
| 246 | declare!(SPIM0_SPIS0_SPI0); | 246 | TIMER1, |
| 247 | declare!(GPIOTE); | 247 | TIMER2, |
| 248 | declare!(SAADC); | 248 | RTC0, |
| 249 | declare!(TIMER0); | 249 | TEMP, |
| 250 | declare!(TIMER1); | 250 | RNG, |
| 251 | declare!(TIMER2); | 251 | ECB, |
| 252 | declare!(RTC0); | 252 | CCM_AAR, |
| 253 | declare!(TEMP); | 253 | WDT, |
| 254 | declare!(RNG); | 254 | RTC1, |
| 255 | declare!(ECB); | 255 | QDEC, |
| 256 | declare!(CCM_AAR); | 256 | COMP, |
| 257 | declare!(WDT); | 257 | SWI0_EGU0, |
| 258 | declare!(RTC1); | 258 | SWI1_EGU1, |
| 259 | declare!(QDEC); | 259 | SWI2, |
| 260 | declare!(COMP); | 260 | SWI3, |
| 261 | declare!(SWI0_EGU0); | 261 | SWI4, |
| 262 | declare!(SWI1_EGU1); | 262 | SWI5, |
| 263 | declare!(SWI2); | 263 | PWM0, |
| 264 | declare!(SWI3); | 264 | PDM, |
| 265 | declare!(SWI4); | 265 | ); |
| 266 | declare!(SWI5); | ||
| 267 | declare!(PWM0); | ||
| 268 | declare!(PDM); | ||
| 269 | } | ||
diff --git a/embassy-nrf/src/chips/nrf52811.rs b/embassy-nrf/src/chips/nrf52811.rs index a7a7cf58c..d5367c59a 100644 --- a/embassy-nrf/src/chips/nrf52811.rs +++ b/embassy-nrf/src/chips/nrf52811.rs | |||
| @@ -236,36 +236,32 @@ impl_saadc_input!(P0_29, ANALOG_INPUT5); | |||
| 236 | impl_saadc_input!(P0_30, ANALOG_INPUT6); | 236 | impl_saadc_input!(P0_30, ANALOG_INPUT6); |
| 237 | impl_saadc_input!(P0_31, ANALOG_INPUT7); | 237 | impl_saadc_input!(P0_31, ANALOG_INPUT7); |
| 238 | 238 | ||
| 239 | pub mod irqs { | 239 | embassy_hal_common::interrupt_mod!( |
| 240 | use embassy_cortex_m::interrupt::_export::declare; | 240 | POWER_CLOCK, |
| 241 | 241 | RADIO, | |
| 242 | use crate::pac::Interrupt as InterruptEnum; | 242 | UARTE0_UART0, |
| 243 | 243 | TWIM0_TWIS0_TWI0_SPIM0_SPIS0_SPI0, | |
| 244 | declare!(POWER_CLOCK); | 244 | SPIM1_SPIS1_SPI1, |
| 245 | declare!(RADIO); | 245 | GPIOTE, |
| 246 | declare!(UARTE0_UART0); | 246 | SAADC, |
| 247 | declare!(TWIM0_TWIS0_TWI0_SPIM0_SPIS0_SPI0); | 247 | TIMER0, |
| 248 | declare!(SPIM1_SPIS1_SPI1); | 248 | TIMER1, |
| 249 | declare!(GPIOTE); | 249 | TIMER2, |
| 250 | declare!(SAADC); | 250 | RTC0, |
| 251 | declare!(TIMER0); | 251 | TEMP, |
| 252 | declare!(TIMER1); | 252 | RNG, |
| 253 | declare!(TIMER2); | 253 | ECB, |
| 254 | declare!(RTC0); | 254 | CCM_AAR, |
| 255 | declare!(TEMP); | 255 | WDT, |
| 256 | declare!(RNG); | 256 | RTC1, |
| 257 | declare!(ECB); | 257 | QDEC, |
| 258 | declare!(CCM_AAR); | 258 | COMP, |
| 259 | declare!(WDT); | 259 | SWI0_EGU0, |
| 260 | declare!(RTC1); | 260 | SWI1_EGU1, |
| 261 | declare!(QDEC); | 261 | SWI2, |
| 262 | declare!(COMP); | 262 | SWI3, |
| 263 | declare!(SWI0_EGU0); | 263 | SWI4, |
| 264 | declare!(SWI1_EGU1); | 264 | SWI5, |
| 265 | declare!(SWI2); | 265 | PWM0, |
| 266 | declare!(SWI3); | 266 | PDM, |
| 267 | declare!(SWI4); | 267 | ); |
| 268 | declare!(SWI5); | ||
| 269 | declare!(PWM0); | ||
| 270 | declare!(PDM); | ||
| 271 | } | ||
diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs index 14a1b8cc9..785170447 100644 --- a/embassy-nrf/src/chips/nrf52820.rs +++ b/embassy-nrf/src/chips/nrf52820.rs | |||
| @@ -224,35 +224,31 @@ impl_ppi_channel!(PPI_CH29, 29 => static); | |||
| 224 | impl_ppi_channel!(PPI_CH30, 30 => static); | 224 | impl_ppi_channel!(PPI_CH30, 30 => static); |
| 225 | impl_ppi_channel!(PPI_CH31, 31 => static); | 225 | impl_ppi_channel!(PPI_CH31, 31 => static); |
| 226 | 226 | ||
| 227 | pub mod irqs { | 227 | embassy_hal_common::interrupt_mod!( |
| 228 | use embassy_cortex_m::interrupt::_export::declare; | 228 | POWER_CLOCK, |
| 229 | 229 | RADIO, | |
| 230 | use crate::pac::Interrupt as InterruptEnum; | 230 | UARTE0_UART0, |
| 231 | 231 | SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0, | |
| 232 | declare!(POWER_CLOCK); | 232 | SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1, |
| 233 | declare!(RADIO); | 233 | GPIOTE, |
| 234 | declare!(UARTE0_UART0); | 234 | TIMER0, |
| 235 | declare!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); | 235 | TIMER1, |
| 236 | declare!(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1); | 236 | TIMER2, |
| 237 | declare!(GPIOTE); | 237 | RTC0, |
| 238 | declare!(TIMER0); | 238 | TEMP, |
| 239 | declare!(TIMER1); | 239 | RNG, |
| 240 | declare!(TIMER2); | 240 | ECB, |
| 241 | declare!(RTC0); | 241 | CCM_AAR, |
| 242 | declare!(TEMP); | 242 | WDT, |
| 243 | declare!(RNG); | 243 | RTC1, |
| 244 | declare!(ECB); | 244 | QDEC, |
| 245 | declare!(CCM_AAR); | 245 | COMP, |
| 246 | declare!(WDT); | 246 | SWI0_EGU0, |
| 247 | declare!(RTC1); | 247 | SWI1_EGU1, |
| 248 | declare!(QDEC); | 248 | SWI2_EGU2, |
| 249 | declare!(COMP); | 249 | SWI3_EGU3, |
| 250 | declare!(SWI0_EGU0); | 250 | SWI4_EGU4, |
| 251 | declare!(SWI1_EGU1); | 251 | SWI5_EGU5, |
| 252 | declare!(SWI2_EGU2); | 252 | TIMER3, |
| 253 | declare!(SWI3_EGU3); | 253 | USBD, |
| 254 | declare!(SWI4_EGU4); | 254 | ); |
| 255 | declare!(SWI5_EGU5); | ||
| 256 | declare!(TIMER3); | ||
| 257 | declare!(USBD); | ||
| 258 | } | ||
diff --git a/embassy-nrf/src/chips/nrf52832.rs b/embassy-nrf/src/chips/nrf52832.rs index 83ecd0deb..b77564a5c 100644 --- a/embassy-nrf/src/chips/nrf52832.rs +++ b/embassy-nrf/src/chips/nrf52832.rs | |||
| @@ -263,46 +263,42 @@ impl_saadc_input!(P0_31, ANALOG_INPUT7); | |||
| 263 | 263 | ||
| 264 | impl_i2s!(I2S, I2S, I2S); | 264 | impl_i2s!(I2S, I2S, I2S); |
| 265 | 265 | ||
| 266 | pub mod irqs { | 266 | embassy_hal_common::interrupt_mod!( |
| 267 | use embassy_cortex_m::interrupt::_export::declare; | 267 | POWER_CLOCK, |
| 268 | 268 | RADIO, | |
| 269 | use crate::pac::Interrupt as InterruptEnum; | 269 | UARTE0_UART0, |
| 270 | 270 | SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0, | |
| 271 | declare!(POWER_CLOCK); | 271 | SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1, |
| 272 | declare!(RADIO); | 272 | NFCT, |
| 273 | declare!(UARTE0_UART0); | 273 | GPIOTE, |
| 274 | declare!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); | 274 | SAADC, |
| 275 | declare!(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1); | 275 | TIMER0, |
| 276 | declare!(NFCT); | 276 | TIMER1, |
| 277 | declare!(GPIOTE); | 277 | TIMER2, |
| 278 | declare!(SAADC); | 278 | RTC0, |
| 279 | declare!(TIMER0); | 279 | TEMP, |
| 280 | declare!(TIMER1); | 280 | RNG, |
| 281 | declare!(TIMER2); | 281 | ECB, |
| 282 | declare!(RTC0); | 282 | CCM_AAR, |
| 283 | declare!(TEMP); | 283 | WDT, |
| 284 | declare!(RNG); | 284 | RTC1, |
| 285 | declare!(ECB); | 285 | QDEC, |
| 286 | declare!(CCM_AAR); | 286 | COMP_LPCOMP, |
| 287 | declare!(WDT); | 287 | SWI0_EGU0, |
| 288 | declare!(RTC1); | 288 | SWI1_EGU1, |
| 289 | declare!(QDEC); | 289 | SWI2_EGU2, |
| 290 | declare!(COMP_LPCOMP); | 290 | SWI3_EGU3, |
| 291 | declare!(SWI0_EGU0); | 291 | SWI4_EGU4, |
| 292 | declare!(SWI1_EGU1); | 292 | SWI5_EGU5, |
| 293 | declare!(SWI2_EGU2); | 293 | TIMER3, |
| 294 | declare!(SWI3_EGU3); | 294 | TIMER4, |
| 295 | declare!(SWI4_EGU4); | 295 | PWM0, |
| 296 | declare!(SWI5_EGU5); | 296 | PDM, |
| 297 | declare!(TIMER3); | 297 | MWU, |
| 298 | declare!(TIMER4); | 298 | PWM1, |
| 299 | declare!(PWM0); | 299 | PWM2, |
| 300 | declare!(PDM); | 300 | SPIM2_SPIS2_SPI2, |
| 301 | declare!(MWU); | 301 | RTC2, |
| 302 | declare!(PWM1); | 302 | FPU, |
| 303 | declare!(PWM2); | 303 | I2S, |
| 304 | declare!(SPIM2_SPIS2_SPI2); | 304 | ); |
| 305 | declare!(RTC2); | ||
| 306 | declare!(FPU); | ||
| 307 | declare!(I2S); | ||
| 308 | } | ||
diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs index 5e5db04de..bff7f4ebb 100644 --- a/embassy-nrf/src/chips/nrf52833.rs +++ b/embassy-nrf/src/chips/nrf52833.rs | |||
| @@ -306,50 +306,46 @@ impl_saadc_input!(P0_31, ANALOG_INPUT7); | |||
| 306 | 306 | ||
| 307 | impl_i2s!(I2S, I2S, I2S); | 307 | impl_i2s!(I2S, I2S, I2S); |
| 308 | 308 | ||
| 309 | pub mod irqs { | 309 | embassy_hal_common::interrupt_mod!( |
| 310 | use embassy_cortex_m::interrupt::_export::declare; | 310 | POWER_CLOCK, |
| 311 | 311 | RADIO, | |
| 312 | use crate::pac::Interrupt as InterruptEnum; | 312 | UARTE0_UART0, |
| 313 | 313 | SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0, | |
| 314 | declare!(POWER_CLOCK); | 314 | SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1, |
| 315 | declare!(RADIO); | 315 | NFCT, |
| 316 | declare!(UARTE0_UART0); | 316 | GPIOTE, |
| 317 | declare!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); | 317 | SAADC, |
| 318 | declare!(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1); | 318 | TIMER0, |
| 319 | declare!(NFCT); | 319 | TIMER1, |
| 320 | declare!(GPIOTE); | 320 | TIMER2, |
| 321 | declare!(SAADC); | 321 | RTC0, |
| 322 | declare!(TIMER0); | 322 | TEMP, |
| 323 | declare!(TIMER1); | 323 | RNG, |
| 324 | declare!(TIMER2); | 324 | ECB, |
| 325 | declare!(RTC0); | 325 | CCM_AAR, |
| 326 | declare!(TEMP); | 326 | WDT, |
| 327 | declare!(RNG); | 327 | RTC1, |
| 328 | declare!(ECB); | 328 | QDEC, |
| 329 | declare!(CCM_AAR); | 329 | COMP_LPCOMP, |
| 330 | declare!(WDT); | 330 | SWI0_EGU0, |
| 331 | declare!(RTC1); | 331 | SWI1_EGU1, |
| 332 | declare!(QDEC); | 332 | SWI2_EGU2, |
| 333 | declare!(COMP_LPCOMP); | 333 | SWI3_EGU3, |
| 334 | declare!(SWI0_EGU0); | 334 | SWI4_EGU4, |
| 335 | declare!(SWI1_EGU1); | 335 | SWI5_EGU5, |
| 336 | declare!(SWI2_EGU2); | 336 | TIMER3, |
| 337 | declare!(SWI3_EGU3); | 337 | TIMER4, |
| 338 | declare!(SWI4_EGU4); | 338 | PWM0, |
| 339 | declare!(SWI5_EGU5); | 339 | PDM, |
| 340 | declare!(TIMER3); | 340 | MWU, |
| 341 | declare!(TIMER4); | 341 | PWM1, |
| 342 | declare!(PWM0); | 342 | PWM2, |
| 343 | declare!(PDM); | 343 | SPIM2_SPIS2_SPI2, |
| 344 | declare!(MWU); | 344 | RTC2, |
| 345 | declare!(PWM1); | 345 | FPU, |
| 346 | declare!(PWM2); | 346 | USBD, |
| 347 | declare!(SPIM2_SPIS2_SPI2); | 347 | UARTE1, |
| 348 | declare!(RTC2); | 348 | PWM3, |
| 349 | declare!(FPU); | 349 | SPIM3, |
| 350 | declare!(USBD); | 350 | I2S, |
| 351 | declare!(UARTE1); | 351 | ); |
| 352 | declare!(PWM3); | ||
| 353 | declare!(SPIM3); | ||
| 354 | declare!(I2S); | ||
| 355 | } | ||
diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs index f6d33f85c..9b0050823 100644 --- a/embassy-nrf/src/chips/nrf52840.rs +++ b/embassy-nrf/src/chips/nrf52840.rs | |||
| @@ -311,52 +311,48 @@ impl_saadc_input!(P0_31, ANALOG_INPUT7); | |||
| 311 | 311 | ||
| 312 | impl_i2s!(I2S, I2S, I2S); | 312 | impl_i2s!(I2S, I2S, I2S); |
| 313 | 313 | ||
| 314 | pub mod irqs { | 314 | embassy_hal_common::interrupt_mod!( |
| 315 | use embassy_cortex_m::interrupt::_export::declare; | 315 | POWER_CLOCK, |
| 316 | 316 | RADIO, | |
| 317 | use crate::pac::Interrupt as InterruptEnum; | 317 | UARTE0_UART0, |
| 318 | 318 | SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0, | |
| 319 | declare!(POWER_CLOCK); | 319 | SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1, |
| 320 | declare!(RADIO); | 320 | NFCT, |
| 321 | declare!(UARTE0_UART0); | 321 | GPIOTE, |
| 322 | declare!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); | 322 | SAADC, |
| 323 | declare!(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1); | 323 | TIMER0, |
| 324 | declare!(NFCT); | 324 | TIMER1, |
| 325 | declare!(GPIOTE); | 325 | TIMER2, |
| 326 | declare!(SAADC); | 326 | RTC0, |
| 327 | declare!(TIMER0); | 327 | TEMP, |
| 328 | declare!(TIMER1); | 328 | RNG, |
| 329 | declare!(TIMER2); | 329 | ECB, |
| 330 | declare!(RTC0); | 330 | CCM_AAR, |
| 331 | declare!(TEMP); | 331 | WDT, |
| 332 | declare!(RNG); | 332 | RTC1, |
| 333 | declare!(ECB); | 333 | QDEC, |
| 334 | declare!(CCM_AAR); | 334 | COMP_LPCOMP, |
| 335 | declare!(WDT); | 335 | SWI0_EGU0, |
| 336 | declare!(RTC1); | 336 | SWI1_EGU1, |
| 337 | declare!(QDEC); | 337 | SWI2_EGU2, |
| 338 | declare!(COMP_LPCOMP); | 338 | SWI3_EGU3, |
| 339 | declare!(SWI0_EGU0); | 339 | SWI4_EGU4, |
| 340 | declare!(SWI1_EGU1); | 340 | SWI5_EGU5, |
| 341 | declare!(SWI2_EGU2); | 341 | TIMER3, |
| 342 | declare!(SWI3_EGU3); | 342 | TIMER4, |
| 343 | declare!(SWI4_EGU4); | 343 | PWM0, |
| 344 | declare!(SWI5_EGU5); | 344 | PDM, |
| 345 | declare!(TIMER3); | 345 | MWU, |
| 346 | declare!(TIMER4); | 346 | PWM1, |
| 347 | declare!(PWM0); | 347 | PWM2, |
| 348 | declare!(PDM); | 348 | SPIM2_SPIS2_SPI2, |
| 349 | declare!(MWU); | 349 | RTC2, |
| 350 | declare!(PWM1); | 350 | FPU, |
| 351 | declare!(PWM2); | 351 | USBD, |
| 352 | declare!(SPIM2_SPIS2_SPI2); | 352 | UARTE1, |
| 353 | declare!(RTC2); | 353 | QSPI, |
| 354 | declare!(FPU); | 354 | CRYPTOCELL, |
| 355 | declare!(USBD); | 355 | PWM3, |
| 356 | declare!(UARTE1); | 356 | SPIM3, |
| 357 | declare!(QSPI); | 357 | I2S, |
| 358 | declare!(CRYPTOCELL); | 358 | ); |
| 359 | declare!(PWM3); | ||
| 360 | declare!(SPIM3); | ||
| 361 | declare!(I2S); | ||
| 362 | } | ||
diff --git a/embassy-nrf/src/chips/nrf5340_app.rs b/embassy-nrf/src/chips/nrf5340_app.rs index 34f96800f..410ae921c 100644 --- a/embassy-nrf/src/chips/nrf5340_app.rs +++ b/embassy-nrf/src/chips/nrf5340_app.rs | |||
| @@ -5,6 +5,8 @@ pub mod pac { | |||
| 5 | // The nRF5340 has a secure and non-secure (NS) mode. | 5 | // The nRF5340 has a secure and non-secure (NS) mode. |
| 6 | // To avoid cfg spam, we remove _ns or _s suffixes here. | 6 | // To avoid cfg spam, we remove _ns or _s suffixes here. |
| 7 | 7 | ||
| 8 | pub use nrf5340_app_pac::NVIC_PRIO_BITS; | ||
| 9 | |||
| 8 | #[doc(no_inline)] | 10 | #[doc(no_inline)] |
| 9 | pub use nrf5340_app_pac::{ | 11 | pub use nrf5340_app_pac::{ |
| 10 | interrupt, | 12 | interrupt, |
| @@ -504,50 +506,46 @@ impl_saadc_input!(P0_18, ANALOG_INPUT5); | |||
| 504 | impl_saadc_input!(P0_19, ANALOG_INPUT6); | 506 | impl_saadc_input!(P0_19, ANALOG_INPUT6); |
| 505 | impl_saadc_input!(P0_20, ANALOG_INPUT7); | 507 | impl_saadc_input!(P0_20, ANALOG_INPUT7); |
| 506 | 508 | ||
| 507 | pub mod irqs { | 509 | embassy_hal_common::interrupt_mod!( |
| 508 | use embassy_cortex_m::interrupt::_export::declare; | 510 | FPU, |
| 509 | 511 | CACHE, | |
| 510 | use crate::pac::Interrupt as InterruptEnum; | 512 | SPU, |
| 511 | 513 | CLOCK_POWER, | |
| 512 | declare!(FPU); | 514 | SERIAL0, |
| 513 | declare!(CACHE); | 515 | SERIAL1, |
| 514 | declare!(SPU); | 516 | SPIM4, |
| 515 | declare!(CLOCK_POWER); | 517 | SERIAL2, |
| 516 | declare!(SERIAL0); | 518 | SERIAL3, |
| 517 | declare!(SERIAL1); | 519 | GPIOTE0, |
| 518 | declare!(SPIM4); | 520 | SAADC, |
| 519 | declare!(SERIAL2); | 521 | TIMER0, |
| 520 | declare!(SERIAL3); | 522 | TIMER1, |
| 521 | declare!(GPIOTE0); | 523 | TIMER2, |
| 522 | declare!(SAADC); | 524 | RTC0, |
| 523 | declare!(TIMER0); | 525 | RTC1, |
| 524 | declare!(TIMER1); | 526 | WDT0, |
| 525 | declare!(TIMER2); | 527 | WDT1, |
| 526 | declare!(RTC0); | 528 | COMP_LPCOMP, |
| 527 | declare!(RTC1); | 529 | EGU0, |
| 528 | declare!(WDT0); | 530 | EGU1, |
| 529 | declare!(WDT1); | 531 | EGU2, |
| 530 | declare!(COMP_LPCOMP); | 532 | EGU3, |
| 531 | declare!(EGU0); | 533 | EGU4, |
| 532 | declare!(EGU1); | 534 | EGU5, |
| 533 | declare!(EGU2); | 535 | PWM0, |
| 534 | declare!(EGU3); | 536 | PWM1, |
| 535 | declare!(EGU4); | 537 | PWM2, |
| 536 | declare!(EGU5); | 538 | PWM3, |
| 537 | declare!(PWM0); | 539 | PDM0, |
| 538 | declare!(PWM1); | 540 | I2S0, |
| 539 | declare!(PWM2); | 541 | IPC, |
| 540 | declare!(PWM3); | 542 | QSPI, |
| 541 | declare!(PDM0); | 543 | NFCT, |
| 542 | declare!(I2S0); | 544 | GPIOTE1, |
| 543 | declare!(IPC); | 545 | QDEC0, |
| 544 | declare!(QSPI); | 546 | QDEC1, |
| 545 | declare!(NFCT); | 547 | USBD, |
| 546 | declare!(GPIOTE1); | 548 | USBREGULATOR, |
| 547 | declare!(QDEC0); | 549 | KMU, |
| 548 | declare!(QDEC1); | 550 | CRYPTOCELL, |
| 549 | declare!(USBD); | 551 | ); |
| 550 | declare!(USBREGULATOR); | ||
| 551 | declare!(KMU); | ||
| 552 | declare!(CRYPTOCELL); | ||
| 553 | } | ||
diff --git a/embassy-nrf/src/chips/nrf5340_net.rs b/embassy-nrf/src/chips/nrf5340_net.rs index 1e59528cb..6ac783085 100644 --- a/embassy-nrf/src/chips/nrf5340_net.rs +++ b/embassy-nrf/src/chips/nrf5340_net.rs | |||
| @@ -5,6 +5,8 @@ pub mod pac { | |||
| 5 | // The nRF5340 has a secure and non-secure (NS) mode. | 5 | // The nRF5340 has a secure and non-secure (NS) mode. |
| 6 | // To avoid cfg spam, we remove _ns or _s suffixes here. | 6 | // To avoid cfg spam, we remove _ns or _s suffixes here. |
| 7 | 7 | ||
| 8 | pub use nrf5340_net_pac::NVIC_PRIO_BITS; | ||
| 9 | |||
| 8 | #[doc(no_inline)] | 10 | #[doc(no_inline)] |
| 9 | pub use nrf5340_net_pac::{ | 11 | pub use nrf5340_net_pac::{ |
| 10 | interrupt, | 12 | interrupt, |
| @@ -340,29 +342,25 @@ impl_ppi_channel!(PPI_CH29, 29 => configurable); | |||
| 340 | impl_ppi_channel!(PPI_CH30, 30 => configurable); | 342 | impl_ppi_channel!(PPI_CH30, 30 => configurable); |
| 341 | impl_ppi_channel!(PPI_CH31, 31 => configurable); | 343 | impl_ppi_channel!(PPI_CH31, 31 => configurable); |
| 342 | 344 | ||
| 343 | pub mod irqs { | 345 | embassy_hal_common::interrupt_mod!( |
| 344 | use embassy_cortex_m::interrupt::_export::declare; | 346 | CLOCK_POWER, |
| 345 | 347 | RADIO, | |
| 346 | use crate::pac::Interrupt as InterruptEnum; | 348 | RNG, |
| 347 | 349 | GPIOTE, | |
| 348 | declare!(CLOCK_POWER); | 350 | WDT, |
| 349 | declare!(RADIO); | 351 | TIMER0, |
| 350 | declare!(RNG); | 352 | ECB, |
| 351 | declare!(GPIOTE); | 353 | AAR_CCM, |
| 352 | declare!(WDT); | 354 | TEMP, |
| 353 | declare!(TIMER0); | 355 | RTC0, |
| 354 | declare!(ECB); | 356 | IPC, |
| 355 | declare!(AAR_CCM); | 357 | SERIAL0, |
| 356 | declare!(TEMP); | 358 | EGU0, |
| 357 | declare!(RTC0); | 359 | RTC1, |
| 358 | declare!(IPC); | 360 | TIMER1, |
| 359 | declare!(SERIAL0); | 361 | TIMER2, |
| 360 | declare!(EGU0); | 362 | SWI0, |
| 361 | declare!(RTC1); | 363 | SWI1, |
| 362 | declare!(TIMER1); | 364 | SWI2, |
| 363 | declare!(TIMER2); | 365 | SWI3, |
| 364 | declare!(SWI0); | 366 | ); |
| 365 | declare!(SWI1); | ||
| 366 | declare!(SWI2); | ||
| 367 | declare!(SWI3); | ||
| 368 | } | ||
diff --git a/embassy-nrf/src/chips/nrf9160.rs b/embassy-nrf/src/chips/nrf9160.rs index d2b45114f..67ea032ff 100644 --- a/embassy-nrf/src/chips/nrf9160.rs +++ b/embassy-nrf/src/chips/nrf9160.rs | |||
| @@ -5,6 +5,8 @@ pub mod pac { | |||
| 5 | // The nRF9160 has a secure and non-secure (NS) mode. | 5 | // The nRF9160 has a secure and non-secure (NS) mode. |
| 6 | // To avoid cfg spam, we remove _ns or _s suffixes here. | 6 | // To avoid cfg spam, we remove _ns or _s suffixes here. |
| 7 | 7 | ||
| 8 | pub use nrf9160_pac::NVIC_PRIO_BITS; | ||
| 9 | |||
| 8 | #[doc(no_inline)] | 10 | #[doc(no_inline)] |
| 9 | pub use nrf9160_pac::{ | 11 | pub use nrf9160_pac::{ |
| 10 | interrupt, | 12 | interrupt, |
| @@ -366,40 +368,36 @@ impl_saadc_input!(P0_18, ANALOG_INPUT5); | |||
| 366 | impl_saadc_input!(P0_19, ANALOG_INPUT6); | 368 | impl_saadc_input!(P0_19, ANALOG_INPUT6); |
| 367 | impl_saadc_input!(P0_20, ANALOG_INPUT7); | 369 | impl_saadc_input!(P0_20, ANALOG_INPUT7); |
| 368 | 370 | ||
| 369 | pub mod irqs { | 371 | embassy_hal_common::interrupt_mod!( |
| 370 | use embassy_cortex_m::interrupt::_export::declare; | 372 | SPU, |
| 371 | 373 | CLOCK_POWER, | |
| 372 | use crate::pac::Interrupt as InterruptEnum; | 374 | UARTE0_SPIM0_SPIS0_TWIM0_TWIS0, |
| 373 | 375 | UARTE1_SPIM1_SPIS1_TWIM1_TWIS1, | |
| 374 | declare!(SPU); | 376 | UARTE2_SPIM2_SPIS2_TWIM2_TWIS2, |
| 375 | declare!(CLOCK_POWER); | 377 | UARTE3_SPIM3_SPIS3_TWIM3_TWIS3, |
| 376 | declare!(UARTE0_SPIM0_SPIS0_TWIM0_TWIS0); | 378 | GPIOTE0, |
| 377 | declare!(UARTE1_SPIM1_SPIS1_TWIM1_TWIS1); | 379 | SAADC, |
| 378 | declare!(UARTE2_SPIM2_SPIS2_TWIM2_TWIS2); | 380 | TIMER0, |
| 379 | declare!(UARTE3_SPIM3_SPIS3_TWIM3_TWIS3); | 381 | TIMER1, |
| 380 | declare!(GPIOTE0); | 382 | TIMER2, |
| 381 | declare!(SAADC); | 383 | RTC0, |
| 382 | declare!(TIMER0); | 384 | RTC1, |
| 383 | declare!(TIMER1); | 385 | WDT, |
| 384 | declare!(TIMER2); | 386 | EGU0, |
| 385 | declare!(RTC0); | 387 | EGU1, |
| 386 | declare!(RTC1); | 388 | EGU2, |
| 387 | declare!(WDT); | 389 | EGU3, |
| 388 | declare!(EGU0); | 390 | EGU4, |
| 389 | declare!(EGU1); | 391 | EGU5, |
| 390 | declare!(EGU2); | 392 | PWM0, |
| 391 | declare!(EGU3); | 393 | PWM1, |
| 392 | declare!(EGU4); | 394 | PWM2, |
| 393 | declare!(EGU5); | 395 | PDM, |
| 394 | declare!(PWM0); | 396 | PWM3, |
| 395 | declare!(PWM1); | 397 | I2S, |
| 396 | declare!(PWM2); | 398 | IPC, |
| 397 | declare!(PDM); | 399 | FPU, |
| 398 | declare!(PWM3); | 400 | GPIOTE1, |
| 399 | declare!(I2S); | 401 | KMU, |
| 400 | declare!(IPC); | 402 | CRYPTOCELL, |
| 401 | declare!(FPU); | 403 | ); |
| 402 | declare!(GPIOTE1); | ||
| 403 | declare!(KMU); | ||
| 404 | declare!(CRYPTOCELL); | ||
| 405 | } | ||
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 2ec5220a7..21d0d9564 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -9,7 +9,7 @@ use embassy_sync::waitqueue::AtomicWaker; | |||
| 9 | 9 | ||
| 10 | use crate::gpio::sealed::Pin as _; | 10 | use crate::gpio::sealed::Pin as _; |
| 11 | use crate::gpio::{AnyPin, Flex, Input, Output, Pin as GpioPin}; | 11 | use crate::gpio::{AnyPin, Flex, Input, Output, Pin as GpioPin}; |
| 12 | use crate::interrupt::Interrupt; | 12 | use crate::interrupt::InterruptExt; |
| 13 | use crate::ppi::{Event, Task}; | 13 | use crate::ppi::{Event, Task}; |
| 14 | use crate::{interrupt, pac, peripherals}; | 14 | use crate::{interrupt, pac, peripherals}; |
| 15 | 15 | ||
| @@ -75,15 +75,15 @@ pub(crate) fn init(irq_prio: crate::interrupt::Priority) { | |||
| 75 | 75 | ||
| 76 | // Enable interrupts | 76 | // Enable interrupts |
| 77 | #[cfg(any(feature = "nrf5340-app-s", feature = "nrf9160-s"))] | 77 | #[cfg(any(feature = "nrf5340-app-s", feature = "nrf9160-s"))] |
| 78 | type Irq = interrupt::GPIOTE0; | 78 | let irq = interrupt::GPIOTE0; |
| 79 | #[cfg(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns"))] | 79 | #[cfg(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns"))] |
| 80 | type Irq = interrupt::GPIOTE1; | 80 | let irq = interrupt::GPIOTE1; |
| 81 | #[cfg(any(feature = "_nrf52", feature = "nrf5340-net"))] | 81 | #[cfg(any(feature = "_nrf52", feature = "nrf5340-net"))] |
| 82 | type Irq = interrupt::GPIOTE; | 82 | let irq = interrupt::GPIOTE; |
| 83 | 83 | ||
| 84 | Irq::unpend(); | 84 | irq.unpend(); |
| 85 | Irq::set_priority(irq_prio); | 85 | irq.set_priority(irq_prio); |
| 86 | unsafe { Irq::enable() }; | 86 | unsafe { irq.enable() }; |
| 87 | 87 | ||
| 88 | let g = regs(); | 88 | let g = regs(); |
| 89 | g.events_port.write(|w| w); | 89 | g.events_port.write(|w| w); |
| @@ -91,18 +91,21 @@ pub(crate) fn init(irq_prio: crate::interrupt::Priority) { | |||
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | #[cfg(any(feature = "nrf5340-app-s", feature = "nrf9160-s"))] | 93 | #[cfg(any(feature = "nrf5340-app-s", feature = "nrf9160-s"))] |
| 94 | #[cfg(feature = "rt")] | ||
| 94 | #[interrupt] | 95 | #[interrupt] |
| 95 | fn GPIOTE0() { | 96 | fn GPIOTE0() { |
| 96 | unsafe { handle_gpiote_interrupt() }; | 97 | unsafe { handle_gpiote_interrupt() }; |
| 97 | } | 98 | } |
| 98 | 99 | ||
| 99 | #[cfg(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns"))] | 100 | #[cfg(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns"))] |
| 101 | #[cfg(feature = "rt")] | ||
| 100 | #[interrupt] | 102 | #[interrupt] |
| 101 | fn GPIOTE1() { | 103 | fn GPIOTE1() { |
| 102 | unsafe { handle_gpiote_interrupt() }; | 104 | unsafe { handle_gpiote_interrupt() }; |
| 103 | } | 105 | } |
| 104 | 106 | ||
| 105 | #[cfg(any(feature = "_nrf52", feature = "nrf5340-net"))] | 107 | #[cfg(any(feature = "_nrf52", feature = "nrf5340-net"))] |
| 108 | #[cfg(feature = "rt")] | ||
| 106 | #[interrupt] | 109 | #[interrupt] |
| 107 | fn GPIOTE() { | 110 | fn GPIOTE() { |
| 108 | unsafe { handle_gpiote_interrupt() }; | 111 | unsafe { handle_gpiote_interrupt() }; |
diff --git a/embassy-nrf/src/i2s.rs b/embassy-nrf/src/i2s.rs index 13db77d3b..fea38c4c0 100644 --- a/embassy-nrf/src/i2s.rs +++ b/embassy-nrf/src/i2s.rs | |||
| @@ -13,10 +13,10 @@ use embassy_hal_common::drop::OnDrop; | |||
| 13 | use embassy_hal_common::{into_ref, PeripheralRef}; | 13 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 14 | 14 | ||
| 15 | use crate::gpio::{AnyPin, Pin as GpioPin}; | 15 | use crate::gpio::{AnyPin, Pin as GpioPin}; |
| 16 | use crate::interrupt::{self, Interrupt}; | 16 | use crate::interrupt::typelevel::Interrupt; |
| 17 | use crate::pac::i2s::RegisterBlock; | 17 | use crate::pac::i2s::RegisterBlock; |
| 18 | use crate::util::{slice_in_ram_or, slice_ptr_parts}; | 18 | use crate::util::{slice_in_ram_or, slice_ptr_parts}; |
| 19 | use crate::{Peripheral, EASY_DMA_SIZE}; | 19 | use crate::{interrupt, Peripheral, EASY_DMA_SIZE}; |
| 20 | 20 | ||
| 21 | /// Type alias for `MultiBuffering` with 2 buffers. | 21 | /// Type alias for `MultiBuffering` with 2 buffers. |
| 22 | pub type DoubleBuffering<S, const NS: usize> = MultiBuffering<S, 2, NS>; | 22 | pub type DoubleBuffering<S, const NS: usize> = MultiBuffering<S, 2, NS>; |
| @@ -367,7 +367,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 367 | _phantom: PhantomData<T>, | 367 | _phantom: PhantomData<T>, |
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 370 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 371 | unsafe fn on_interrupt() { | 371 | unsafe fn on_interrupt() { |
| 372 | let device = Device::<T>::new(); | 372 | let device = Device::<T>::new(); |
| 373 | let s = T::state(); | 373 | let s = T::state(); |
| @@ -408,7 +408,7 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 408 | /// Create a new I2S in master mode | 408 | /// Create a new I2S in master mode |
| 409 | pub fn new_master( | 409 | pub fn new_master( |
| 410 | i2s: impl Peripheral<P = T> + 'd, | 410 | i2s: impl Peripheral<P = T> + 'd, |
| 411 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 411 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 412 | mck: impl Peripheral<P = impl GpioPin> + 'd, | 412 | mck: impl Peripheral<P = impl GpioPin> + 'd, |
| 413 | sck: impl Peripheral<P = impl GpioPin> + 'd, | 413 | sck: impl Peripheral<P = impl GpioPin> + 'd, |
| 414 | lrck: impl Peripheral<P = impl GpioPin> + 'd, | 414 | lrck: impl Peripheral<P = impl GpioPin> + 'd, |
| @@ -431,7 +431,7 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 431 | /// Create a new I2S in slave mode | 431 | /// Create a new I2S in slave mode |
| 432 | pub fn new_slave( | 432 | pub fn new_slave( |
| 433 | i2s: impl Peripheral<P = T> + 'd, | 433 | i2s: impl Peripheral<P = T> + 'd, |
| 434 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 434 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 435 | sck: impl Peripheral<P = impl GpioPin> + 'd, | 435 | sck: impl Peripheral<P = impl GpioPin> + 'd, |
| 436 | lrck: impl Peripheral<P = impl GpioPin> + 'd, | 436 | lrck: impl Peripheral<P = impl GpioPin> + 'd, |
| 437 | config: Config, | 437 | config: Config, |
| @@ -1173,7 +1173,7 @@ pub(crate) mod sealed { | |||
| 1173 | /// I2S peripheral instance. | 1173 | /// I2S peripheral instance. |
| 1174 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { | 1174 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { |
| 1175 | /// Interrupt for this peripheral. | 1175 | /// Interrupt for this peripheral. |
| 1176 | type Interrupt: Interrupt; | 1176 | type Interrupt: interrupt::typelevel::Interrupt; |
| 1177 | } | 1177 | } |
| 1178 | 1178 | ||
| 1179 | macro_rules! impl_i2s { | 1179 | macro_rules! impl_i2s { |
| @@ -1188,7 +1188,7 @@ macro_rules! impl_i2s { | |||
| 1188 | } | 1188 | } |
| 1189 | } | 1189 | } |
| 1190 | impl crate::i2s::Instance for peripherals::$type { | 1190 | impl crate::i2s::Instance for peripherals::$type { |
| 1191 | type Interrupt = crate::interrupt::$irq; | 1191 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 1192 | } | 1192 | } |
| 1193 | }; | 1193 | }; |
| 1194 | } | 1194 | } |
diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index 6b57c2545..691545662 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs | |||
| @@ -93,21 +93,14 @@ pub mod wdt; | |||
| 93 | #[cfg_attr(feature = "_nrf9160", path = "chips/nrf9160.rs")] | 93 | #[cfg_attr(feature = "_nrf9160", path = "chips/nrf9160.rs")] |
| 94 | mod chip; | 94 | mod chip; |
| 95 | 95 | ||
| 96 | pub mod interrupt { | 96 | /// Macro to bind interrupts to handlers. |
| 97 | //! Interrupt definitions and macros to bind them. | 97 | /// |
| 98 | pub use cortex_m::interrupt::{CriticalSection, Mutex}; | 98 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) |
| 99 | pub use embassy_cortex_m::interrupt::{Binding, Handler, Interrupt, Priority}; | 99 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to |
| 100 | 100 | /// prove at compile-time that the right interrupts have been bound. | |
| 101 | pub use crate::chip::irqs::*; | 101 | // developer note: this macro can't be in `embassy-hal-common` due to the use of `$crate`. |
| 102 | 102 | #[macro_export] | |
| 103 | /// Macro to bind interrupts to handlers. | 103 | macro_rules! bind_interrupts { |
| 104 | /// | ||
| 105 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) | ||
| 106 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to | ||
| 107 | /// prove at compile-time that the right interrupts have been bound. | ||
| 108 | // developer note: this macro can't be in `embassy-cortex-m` due to the use of `$crate`. | ||
| 109 | #[macro_export] | ||
| 110 | macro_rules! bind_interrupts { | ||
| 111 | ($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => { | 104 | ($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => { |
| 112 | $vis struct $name; | 105 | $vis struct $name; |
| 113 | 106 | ||
| @@ -116,17 +109,16 @@ pub mod interrupt { | |||
| 116 | #[no_mangle] | 109 | #[no_mangle] |
| 117 | unsafe extern "C" fn $irq() { | 110 | unsafe extern "C" fn $irq() { |
| 118 | $( | 111 | $( |
| 119 | <$handler as $crate::interrupt::Handler<$crate::interrupt::$irq>>::on_interrupt(); | 112 | <$handler as $crate::interrupt::typelevel::Handler<$crate::interrupt::typelevel::$irq>>::on_interrupt(); |
| 120 | )* | 113 | )* |
| 121 | } | 114 | } |
| 122 | 115 | ||
| 123 | $( | 116 | $( |
| 124 | unsafe impl $crate::interrupt::Binding<$crate::interrupt::$irq, $handler> for $name {} | 117 | unsafe impl $crate::interrupt::typelevel::Binding<$crate::interrupt::typelevel::$irq, $handler> for $name {} |
| 125 | )* | 118 | )* |
| 126 | )* | 119 | )* |
| 127 | }; | 120 | }; |
| 128 | } | 121 | } |
| 129 | } | ||
| 130 | 122 | ||
| 131 | // Reexports | 123 | // Reexports |
| 132 | 124 | ||
| @@ -135,10 +127,11 @@ pub use chip::pac; | |||
| 135 | #[cfg(not(feature = "unstable-pac"))] | 127 | #[cfg(not(feature = "unstable-pac"))] |
| 136 | pub(crate) use chip::pac; | 128 | pub(crate) use chip::pac; |
| 137 | pub use chip::{peripherals, Peripherals, EASY_DMA_SIZE}; | 129 | pub use chip::{peripherals, Peripherals, EASY_DMA_SIZE}; |
| 138 | pub use embassy_cortex_m::executor; | ||
| 139 | pub use embassy_cortex_m::interrupt::_export::interrupt; | ||
| 140 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 130 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 141 | 131 | ||
| 132 | pub use crate::chip::interrupt; | ||
| 133 | pub use crate::pac::NVIC_PRIO_BITS; | ||
| 134 | |||
| 142 | pub mod config { | 135 | pub mod config { |
| 143 | //! Configuration options used when initializing the HAL. | 136 | //! Configuration options used when initializing the HAL. |
| 144 | 137 | ||
diff --git a/embassy-nrf/src/pdm.rs b/embassy-nrf/src/pdm.rs index 9df685a26..0e30f7002 100644 --- a/embassy-nrf/src/pdm.rs +++ b/embassy-nrf/src/pdm.rs | |||
| @@ -6,7 +6,6 @@ use core::marker::PhantomData; | |||
| 6 | use core::sync::atomic::{compiler_fence, Ordering}; | 6 | use core::sync::atomic::{compiler_fence, Ordering}; |
| 7 | use core::task::Poll; | 7 | use core::task::Poll; |
| 8 | 8 | ||
| 9 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 10 | use embassy_hal_common::drop::OnDrop; | 9 | use embassy_hal_common::drop::OnDrop; |
| 11 | use embassy_hal_common::{into_ref, PeripheralRef}; | 10 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 12 | use futures::future::poll_fn; | 11 | use futures::future::poll_fn; |
| @@ -14,15 +13,15 @@ use futures::future::poll_fn; | |||
| 14 | use crate::chip::EASY_DMA_SIZE; | 13 | use crate::chip::EASY_DMA_SIZE; |
| 15 | use crate::gpio::sealed::Pin; | 14 | use crate::gpio::sealed::Pin; |
| 16 | use crate::gpio::{AnyPin, Pin as GpioPin}; | 15 | use crate::gpio::{AnyPin, Pin as GpioPin}; |
| 17 | use crate::interrupt::{self}; | 16 | use crate::interrupt::typelevel::Interrupt; |
| 18 | use crate::Peripheral; | 17 | use crate::{interrupt, Peripheral}; |
| 19 | 18 | ||
| 20 | /// Interrupt handler. | 19 | /// Interrupt handler. |
| 21 | pub struct InterruptHandler<T: Instance> { | 20 | pub struct InterruptHandler<T: Instance> { |
| 22 | _phantom: PhantomData<T>, | 21 | _phantom: PhantomData<T>, |
| 23 | } | 22 | } |
| 24 | 23 | ||
| 25 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 24 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 26 | unsafe fn on_interrupt() { | 25 | unsafe fn on_interrupt() { |
| 27 | T::regs().intenclr.write(|w| w.end().clear()); | 26 | T::regs().intenclr.write(|w| w.end().clear()); |
| 28 | T::state().waker.wake(); | 27 | T::state().waker.wake(); |
| @@ -53,7 +52,7 @@ impl<'d, T: Instance> Pdm<'d, T> { | |||
| 53 | /// Create PDM driver | 52 | /// Create PDM driver |
| 54 | pub fn new( | 53 | pub fn new( |
| 55 | pdm: impl Peripheral<P = T> + 'd, | 54 | pdm: impl Peripheral<P = T> + 'd, |
| 56 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 55 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 57 | clk: impl Peripheral<P = impl GpioPin> + 'd, | 56 | clk: impl Peripheral<P = impl GpioPin> + 'd, |
| 58 | din: impl Peripheral<P = impl GpioPin> + 'd, | 57 | din: impl Peripheral<P = impl GpioPin> + 'd, |
| 59 | config: Config, | 58 | config: Config, |
| @@ -274,7 +273,7 @@ pub(crate) mod sealed { | |||
| 274 | /// PDM peripheral instance. | 273 | /// PDM peripheral instance. |
| 275 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { | 274 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { |
| 276 | /// Interrupt for this peripheral. | 275 | /// Interrupt for this peripheral. |
| 277 | type Interrupt: Interrupt; | 276 | type Interrupt: interrupt::typelevel::Interrupt; |
| 278 | } | 277 | } |
| 279 | 278 | ||
| 280 | macro_rules! impl_pdm { | 279 | macro_rules! impl_pdm { |
| @@ -289,7 +288,7 @@ macro_rules! impl_pdm { | |||
| 289 | } | 288 | } |
| 290 | } | 289 | } |
| 291 | impl crate::pdm::Instance for peripherals::$type { | 290 | impl crate::pdm::Instance for peripherals::$type { |
| 292 | type Interrupt = crate::interrupt::$irq; | 291 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 293 | } | 292 | } |
| 294 | }; | 293 | }; |
| 295 | } | 294 | } |
diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs index 708f23104..363a255d5 100644 --- a/embassy-nrf/src/pwm.rs +++ b/embassy-nrf/src/pwm.rs | |||
| @@ -8,10 +8,9 @@ use embassy_hal_common::{into_ref, PeripheralRef}; | |||
| 8 | 8 | ||
| 9 | use crate::gpio::sealed::Pin as _; | 9 | use crate::gpio::sealed::Pin as _; |
| 10 | use crate::gpio::{AnyPin, Pin as GpioPin, PselBits}; | 10 | use crate::gpio::{AnyPin, Pin as GpioPin, PselBits}; |
| 11 | use crate::interrupt::Interrupt; | ||
| 12 | use crate::ppi::{Event, Task}; | 11 | use crate::ppi::{Event, Task}; |
| 13 | use crate::util::slice_in_ram_or; | 12 | use crate::util::slice_in_ram_or; |
| 14 | use crate::{pac, Peripheral}; | 13 | use crate::{interrupt, pac, Peripheral}; |
| 15 | 14 | ||
| 16 | /// SimplePwm is the traditional pwm interface you're probably used to, allowing | 15 | /// SimplePwm is the traditional pwm interface you're probably used to, allowing |
| 17 | /// to simply set a duty cycle across up to four channels. | 16 | /// to simply set a duty cycle across up to four channels. |
| @@ -843,7 +842,7 @@ pub(crate) mod sealed { | |||
| 843 | /// PWM peripheral instance. | 842 | /// PWM peripheral instance. |
| 844 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static { | 843 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static { |
| 845 | /// Interrupt for this peripheral. | 844 | /// Interrupt for this peripheral. |
| 846 | type Interrupt: Interrupt; | 845 | type Interrupt: interrupt::typelevel::Interrupt; |
| 847 | } | 846 | } |
| 848 | 847 | ||
| 849 | macro_rules! impl_pwm { | 848 | macro_rules! impl_pwm { |
| @@ -854,7 +853,7 @@ macro_rules! impl_pwm { | |||
| 854 | } | 853 | } |
| 855 | } | 854 | } |
| 856 | impl crate::pwm::Instance for peripherals::$type { | 855 | impl crate::pwm::Instance for peripherals::$type { |
| 857 | type Interrupt = crate::interrupt::$irq; | 856 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 858 | } | 857 | } |
| 859 | }; | 858 | }; |
| 860 | } | 859 | } |
diff --git a/embassy-nrf/src/qdec.rs b/embassy-nrf/src/qdec.rs index 5761d04e1..8bac87d37 100644 --- a/embassy-nrf/src/qdec.rs +++ b/embassy-nrf/src/qdec.rs | |||
| @@ -10,7 +10,7 @@ use embassy_hal_common::{into_ref, PeripheralRef}; | |||
| 10 | 10 | ||
| 11 | use crate::gpio::sealed::Pin as _; | 11 | use crate::gpio::sealed::Pin as _; |
| 12 | use crate::gpio::{AnyPin, Pin as GpioPin}; | 12 | use crate::gpio::{AnyPin, Pin as GpioPin}; |
| 13 | use crate::interrupt::Interrupt; | 13 | use crate::interrupt::typelevel::Interrupt; |
| 14 | use crate::{interrupt, Peripheral}; | 14 | use crate::{interrupt, Peripheral}; |
| 15 | 15 | ||
| 16 | /// Quadrature decoder driver. | 16 | /// Quadrature decoder driver. |
| @@ -50,7 +50,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 50 | _phantom: PhantomData<T>, | 50 | _phantom: PhantomData<T>, |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 53 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 54 | unsafe fn on_interrupt() { | 54 | unsafe fn on_interrupt() { |
| 55 | T::regs().intenclr.write(|w| w.reportrdy().clear()); | 55 | T::regs().intenclr.write(|w| w.reportrdy().clear()); |
| 56 | T::state().waker.wake(); | 56 | T::state().waker.wake(); |
| @@ -61,7 +61,7 @@ impl<'d, T: Instance> Qdec<'d, T> { | |||
| 61 | /// Create a new QDEC. | 61 | /// Create a new QDEC. |
| 62 | pub fn new( | 62 | pub fn new( |
| 63 | qdec: impl Peripheral<P = T> + 'd, | 63 | qdec: impl Peripheral<P = T> + 'd, |
| 64 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 64 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 65 | a: impl Peripheral<P = impl GpioPin> + 'd, | 65 | a: impl Peripheral<P = impl GpioPin> + 'd, |
| 66 | b: impl Peripheral<P = impl GpioPin> + 'd, | 66 | b: impl Peripheral<P = impl GpioPin> + 'd, |
| 67 | config: Config, | 67 | config: Config, |
| @@ -73,7 +73,7 @@ impl<'d, T: Instance> Qdec<'d, T> { | |||
| 73 | /// Create a new QDEC, with a pin for LED output. | 73 | /// Create a new QDEC, with a pin for LED output. |
| 74 | pub fn new_with_led( | 74 | pub fn new_with_led( |
| 75 | qdec: impl Peripheral<P = T> + 'd, | 75 | qdec: impl Peripheral<P = T> + 'd, |
| 76 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 76 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 77 | a: impl Peripheral<P = impl GpioPin> + 'd, | 77 | a: impl Peripheral<P = impl GpioPin> + 'd, |
| 78 | b: impl Peripheral<P = impl GpioPin> + 'd, | 78 | b: impl Peripheral<P = impl GpioPin> + 'd, |
| 79 | led: impl Peripheral<P = impl GpioPin> + 'd, | 79 | led: impl Peripheral<P = impl GpioPin> + 'd, |
| @@ -271,7 +271,7 @@ pub(crate) mod sealed { | |||
| 271 | /// qdec peripheral instance. | 271 | /// qdec peripheral instance. |
| 272 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { | 272 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { |
| 273 | /// Interrupt for this peripheral. | 273 | /// Interrupt for this peripheral. |
| 274 | type Interrupt: Interrupt; | 274 | type Interrupt: interrupt::typelevel::Interrupt; |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | macro_rules! impl_qdec { | 277 | macro_rules! impl_qdec { |
| @@ -286,7 +286,7 @@ macro_rules! impl_qdec { | |||
| 286 | } | 286 | } |
| 287 | } | 287 | } |
| 288 | impl crate::qdec::Instance for peripherals::$type { | 288 | impl crate::qdec::Instance for peripherals::$type { |
| 289 | type Interrupt = crate::interrupt::$irq; | 289 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 290 | } | 290 | } |
| 291 | }; | 291 | }; |
| 292 | } | 292 | } |
diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs index 3f48568b3..baefc7967 100644 --- a/embassy-nrf/src/qspi.rs +++ b/embassy-nrf/src/qspi.rs | |||
| @@ -12,12 +12,12 @@ use embassy_hal_common::{into_ref, PeripheralRef}; | |||
| 12 | use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash}; | 12 | use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash}; |
| 13 | 13 | ||
| 14 | use crate::gpio::{self, Pin as GpioPin}; | 14 | use crate::gpio::{self, Pin as GpioPin}; |
| 15 | use crate::interrupt::{self, Interrupt}; | 15 | use crate::interrupt::typelevel::Interrupt; |
| 16 | pub use crate::pac::qspi::ifconfig0::{ | 16 | pub use crate::pac::qspi::ifconfig0::{ |
| 17 | ADDRMODE_A as AddressMode, PPSIZE_A as WritePageSize, READOC_A as ReadOpcode, WRITEOC_A as WriteOpcode, | 17 | ADDRMODE_A as AddressMode, PPSIZE_A as WritePageSize, READOC_A as ReadOpcode, WRITEOC_A as WriteOpcode, |
| 18 | }; | 18 | }; |
| 19 | pub use crate::pac::qspi::ifconfig1::SPIMODE_A as SpiMode; | 19 | pub use crate::pac::qspi::ifconfig1::SPIMODE_A as SpiMode; |
| 20 | use crate::Peripheral; | 20 | use crate::{interrupt, Peripheral}; |
| 21 | 21 | ||
| 22 | /// Deep power-down config. | 22 | /// Deep power-down config. |
| 23 | pub struct DeepPowerDownConfig { | 23 | pub struct DeepPowerDownConfig { |
| @@ -120,7 +120,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 120 | _phantom: PhantomData<T>, | 120 | _phantom: PhantomData<T>, |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 123 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 124 | unsafe fn on_interrupt() { | 124 | unsafe fn on_interrupt() { |
| 125 | let r = T::regs(); | 125 | let r = T::regs(); |
| 126 | let s = T::state(); | 126 | let s = T::state(); |
| @@ -143,7 +143,7 @@ impl<'d, T: Instance> Qspi<'d, T> { | |||
| 143 | /// Create a new QSPI driver. | 143 | /// Create a new QSPI driver. |
| 144 | pub fn new( | 144 | pub fn new( |
| 145 | qspi: impl Peripheral<P = T> + 'd, | 145 | qspi: impl Peripheral<P = T> + 'd, |
| 146 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 146 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 147 | sck: impl Peripheral<P = impl GpioPin> + 'd, | 147 | sck: impl Peripheral<P = impl GpioPin> + 'd, |
| 148 | csn: impl Peripheral<P = impl GpioPin> + 'd, | 148 | csn: impl Peripheral<P = impl GpioPin> + 'd, |
| 149 | io0: impl Peripheral<P = impl GpioPin> + 'd, | 149 | io0: impl Peripheral<P = impl GpioPin> + 'd, |
| @@ -644,7 +644,7 @@ pub(crate) mod sealed { | |||
| 644 | /// QSPI peripheral instance. | 644 | /// QSPI peripheral instance. |
| 645 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { | 645 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { |
| 646 | /// Interrupt for this peripheral. | 646 | /// Interrupt for this peripheral. |
| 647 | type Interrupt: Interrupt; | 647 | type Interrupt: interrupt::typelevel::Interrupt; |
| 648 | } | 648 | } |
| 649 | 649 | ||
| 650 | macro_rules! impl_qspi { | 650 | macro_rules! impl_qspi { |
| @@ -659,7 +659,7 @@ macro_rules! impl_qspi { | |||
| 659 | } | 659 | } |
| 660 | } | 660 | } |
| 661 | impl crate::qspi::Instance for peripherals::$type { | 661 | impl crate::qspi::Instance for peripherals::$type { |
| 662 | type Interrupt = crate::interrupt::$irq; | 662 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 663 | } | 663 | } |
| 664 | }; | 664 | }; |
| 665 | } | 665 | } |
diff --git a/embassy-nrf/src/rng.rs b/embassy-nrf/src/rng.rs index 7e9b35481..923b8b467 100644 --- a/embassy-nrf/src/rng.rs +++ b/embassy-nrf/src/rng.rs | |||
| @@ -12,7 +12,7 @@ use embassy_hal_common::drop::OnDrop; | |||
| 12 | use embassy_hal_common::{into_ref, PeripheralRef}; | 12 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 13 | use embassy_sync::waitqueue::AtomicWaker; | 13 | use embassy_sync::waitqueue::AtomicWaker; |
| 14 | 14 | ||
| 15 | use crate::interrupt::Interrupt; | 15 | use crate::interrupt::typelevel::Interrupt; |
| 16 | use crate::{interrupt, Peripheral}; | 16 | use crate::{interrupt, Peripheral}; |
| 17 | 17 | ||
| 18 | /// Interrupt handler. | 18 | /// Interrupt handler. |
| @@ -20,7 +20,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 20 | _phantom: PhantomData<T>, | 20 | _phantom: PhantomData<T>, |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 23 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 24 | unsafe fn on_interrupt() { | 24 | unsafe fn on_interrupt() { |
| 25 | let s = T::state(); | 25 | let s = T::state(); |
| 26 | let r = T::regs(); | 26 | let r = T::regs(); |
| @@ -89,7 +89,7 @@ impl<'d, T: Instance> Rng<'d, T> { | |||
| 89 | /// The synchronous API is safe. | 89 | /// The synchronous API is safe. |
| 90 | pub fn new( | 90 | pub fn new( |
| 91 | rng: impl Peripheral<P = T> + 'd, | 91 | rng: impl Peripheral<P = T> + 'd, |
| 92 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 92 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 93 | ) -> Self { | 93 | ) -> Self { |
| 94 | into_ref!(rng); | 94 | into_ref!(rng); |
| 95 | 95 | ||
| @@ -255,7 +255,7 @@ pub(crate) mod sealed { | |||
| 255 | /// RNG peripheral instance. | 255 | /// RNG peripheral instance. |
| 256 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { | 256 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { |
| 257 | /// Interrupt for this peripheral. | 257 | /// Interrupt for this peripheral. |
| 258 | type Interrupt: Interrupt; | 258 | type Interrupt: interrupt::typelevel::Interrupt; |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | macro_rules! impl_rng { | 261 | macro_rules! impl_rng { |
| @@ -270,7 +270,7 @@ macro_rules! impl_rng { | |||
| 270 | } | 270 | } |
| 271 | } | 271 | } |
| 272 | impl crate::rng::Instance for peripherals::$type { | 272 | impl crate::rng::Instance for peripherals::$type { |
| 273 | type Interrupt = crate::interrupt::$irq; | 273 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 274 | } | 274 | } |
| 275 | }; | 275 | }; |
| 276 | } | 276 | } |
diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs index 39764e380..cf3fb9993 100644 --- a/embassy-nrf/src/saadc.rs +++ b/embassy-nrf/src/saadc.rs | |||
| @@ -6,7 +6,6 @@ use core::future::poll_fn; | |||
| 6 | use core::sync::atomic::{compiler_fence, Ordering}; | 6 | use core::sync::atomic::{compiler_fence, Ordering}; |
| 7 | use core::task::Poll; | 7 | use core::task::Poll; |
| 8 | 8 | ||
| 9 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 10 | use embassy_hal_common::drop::OnDrop; | 9 | use embassy_hal_common::drop::OnDrop; |
| 11 | use embassy_hal_common::{impl_peripheral, into_ref, PeripheralRef}; | 10 | use embassy_hal_common::{impl_peripheral, into_ref, PeripheralRef}; |
| 12 | use embassy_sync::waitqueue::AtomicWaker; | 11 | use embassy_sync::waitqueue::AtomicWaker; |
| @@ -18,6 +17,7 @@ use saadc::oversample::OVERSAMPLE_A; | |||
| 18 | use saadc::resolution::VAL_A; | 17 | use saadc::resolution::VAL_A; |
| 19 | 18 | ||
| 20 | use self::sealed::Input as _; | 19 | use self::sealed::Input as _; |
| 20 | use crate::interrupt::InterruptExt; | ||
| 21 | use crate::ppi::{ConfigurableChannel, Event, Ppi, Task}; | 21 | use crate::ppi::{ConfigurableChannel, Event, Ppi, Task}; |
| 22 | use crate::timer::{Frequency, Instance as TimerInstance, Timer}; | 22 | use crate::timer::{Frequency, Instance as TimerInstance, Timer}; |
| 23 | use crate::{interrupt, pac, peripherals, Peripheral}; | 23 | use crate::{interrupt, pac, peripherals, Peripheral}; |
| @@ -33,7 +33,7 @@ pub struct InterruptHandler { | |||
| 33 | _private: (), | 33 | _private: (), |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | impl interrupt::Handler<interrupt::SAADC> for InterruptHandler { | 36 | impl interrupt::typelevel::Handler<interrupt::typelevel::SAADC> for InterruptHandler { |
| 37 | unsafe fn on_interrupt() { | 37 | unsafe fn on_interrupt() { |
| 38 | let r = unsafe { &*SAADC::ptr() }; | 38 | let r = unsafe { &*SAADC::ptr() }; |
| 39 | 39 | ||
| @@ -144,7 +144,7 @@ impl<'d, const N: usize> Saadc<'d, N> { | |||
| 144 | /// Create a new SAADC driver. | 144 | /// Create a new SAADC driver. |
| 145 | pub fn new( | 145 | pub fn new( |
| 146 | saadc: impl Peripheral<P = peripherals::SAADC> + 'd, | 146 | saadc: impl Peripheral<P = peripherals::SAADC> + 'd, |
| 147 | _irq: impl interrupt::Binding<interrupt::SAADC, InterruptHandler> + 'd, | 147 | _irq: impl interrupt::typelevel::Binding<interrupt::typelevel::SAADC, InterruptHandler> + 'd, |
| 148 | config: Config, | 148 | config: Config, |
| 149 | channel_configs: [ChannelConfig; N], | 149 | channel_configs: [ChannelConfig; N], |
| 150 | ) -> Self { | 150 | ) -> Self { |
| @@ -189,8 +189,8 @@ impl<'d, const N: usize> Saadc<'d, N> { | |||
| 189 | // Disable all events interrupts | 189 | // Disable all events interrupts |
| 190 | r.intenclr.write(|w| unsafe { w.bits(0x003F_FFFF) }); | 190 | r.intenclr.write(|w| unsafe { w.bits(0x003F_FFFF) }); |
| 191 | 191 | ||
| 192 | interrupt::SAADC::unpend(); | 192 | interrupt::SAADC.unpend(); |
| 193 | unsafe { interrupt::SAADC::enable() }; | 193 | unsafe { interrupt::SAADC.enable() }; |
| 194 | 194 | ||
| 195 | Self { _p: saadc } | 195 | Self { _p: saadc } |
| 196 | } | 196 | } |
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index bb9cda323..66bbd1a8f 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs | |||
| @@ -15,9 +15,9 @@ pub use pac::spim0::frequency::FREQUENCY_A as Frequency; | |||
| 15 | use crate::chip::FORCE_COPY_BUFFER_SIZE; | 15 | use crate::chip::FORCE_COPY_BUFFER_SIZE; |
| 16 | use crate::gpio::sealed::Pin as _; | 16 | use crate::gpio::sealed::Pin as _; |
| 17 | use crate::gpio::{self, AnyPin, Pin as GpioPin, PselBits}; | 17 | use crate::gpio::{self, AnyPin, Pin as GpioPin, PselBits}; |
| 18 | use crate::interrupt::{self, Interrupt}; | 18 | use crate::interrupt::typelevel::Interrupt; |
| 19 | use crate::util::{slice_in_ram_or, slice_ptr_parts, slice_ptr_parts_mut}; | 19 | use crate::util::{slice_in_ram_or, slice_ptr_parts, slice_ptr_parts_mut}; |
| 20 | use crate::{pac, Peripheral}; | 20 | use crate::{interrupt, pac, Peripheral}; |
| 21 | 21 | ||
| 22 | /// SPIM error | 22 | /// SPIM error |
| 23 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 23 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| @@ -63,7 +63,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 63 | _phantom: PhantomData<T>, | 63 | _phantom: PhantomData<T>, |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 66 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 67 | unsafe fn on_interrupt() { | 67 | unsafe fn on_interrupt() { |
| 68 | let r = T::regs(); | 68 | let r = T::regs(); |
| 69 | let s = T::state(); | 69 | let s = T::state(); |
| @@ -84,7 +84,7 @@ impl<'d, T: Instance> Spim<'d, T> { | |||
| 84 | /// Create a new SPIM driver. | 84 | /// Create a new SPIM driver. |
| 85 | pub fn new( | 85 | pub fn new( |
| 86 | spim: impl Peripheral<P = T> + 'd, | 86 | spim: impl Peripheral<P = T> + 'd, |
| 87 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 87 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 88 | sck: impl Peripheral<P = impl GpioPin> + 'd, | 88 | sck: impl Peripheral<P = impl GpioPin> + 'd, |
| 89 | miso: impl Peripheral<P = impl GpioPin> + 'd, | 89 | miso: impl Peripheral<P = impl GpioPin> + 'd, |
| 90 | mosi: impl Peripheral<P = impl GpioPin> + 'd, | 90 | mosi: impl Peripheral<P = impl GpioPin> + 'd, |
| @@ -103,7 +103,7 @@ impl<'d, T: Instance> Spim<'d, T> { | |||
| 103 | /// Create a new SPIM driver, capable of TX only (MOSI only). | 103 | /// Create a new SPIM driver, capable of TX only (MOSI only). |
| 104 | pub fn new_txonly( | 104 | pub fn new_txonly( |
| 105 | spim: impl Peripheral<P = T> + 'd, | 105 | spim: impl Peripheral<P = T> + 'd, |
| 106 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 106 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 107 | sck: impl Peripheral<P = impl GpioPin> + 'd, | 107 | sck: impl Peripheral<P = impl GpioPin> + 'd, |
| 108 | mosi: impl Peripheral<P = impl GpioPin> + 'd, | 108 | mosi: impl Peripheral<P = impl GpioPin> + 'd, |
| 109 | config: Config, | 109 | config: Config, |
| @@ -115,7 +115,7 @@ impl<'d, T: Instance> Spim<'d, T> { | |||
| 115 | /// Create a new SPIM driver, capable of RX only (MISO only). | 115 | /// Create a new SPIM driver, capable of RX only (MISO only). |
| 116 | pub fn new_rxonly( | 116 | pub fn new_rxonly( |
| 117 | spim: impl Peripheral<P = T> + 'd, | 117 | spim: impl Peripheral<P = T> + 'd, |
| 118 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 118 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 119 | sck: impl Peripheral<P = impl GpioPin> + 'd, | 119 | sck: impl Peripheral<P = impl GpioPin> + 'd, |
| 120 | miso: impl Peripheral<P = impl GpioPin> + 'd, | 120 | miso: impl Peripheral<P = impl GpioPin> + 'd, |
| 121 | config: Config, | 121 | config: Config, |
| @@ -408,7 +408,7 @@ pub(crate) mod sealed { | |||
| 408 | /// SPIM peripheral instance | 408 | /// SPIM peripheral instance |
| 409 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static { | 409 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static { |
| 410 | /// Interrupt for this peripheral. | 410 | /// Interrupt for this peripheral. |
| 411 | type Interrupt: Interrupt; | 411 | type Interrupt: interrupt::typelevel::Interrupt; |
| 412 | } | 412 | } |
| 413 | 413 | ||
| 414 | macro_rules! impl_spim { | 414 | macro_rules! impl_spim { |
| @@ -423,7 +423,7 @@ macro_rules! impl_spim { | |||
| 423 | } | 423 | } |
| 424 | } | 424 | } |
| 425 | impl crate::spim::Instance for peripherals::$type { | 425 | impl crate::spim::Instance for peripherals::$type { |
| 426 | type Interrupt = crate::interrupt::$irq; | 426 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 427 | } | 427 | } |
| 428 | }; | 428 | }; |
| 429 | } | 429 | } |
diff --git a/embassy-nrf/src/spis.rs b/embassy-nrf/src/spis.rs index a1d6803ed..aa438415a 100644 --- a/embassy-nrf/src/spis.rs +++ b/embassy-nrf/src/spis.rs | |||
| @@ -13,9 +13,9 @@ pub use embedded_hal_02::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MO | |||
| 13 | use crate::chip::FORCE_COPY_BUFFER_SIZE; | 13 | use crate::chip::FORCE_COPY_BUFFER_SIZE; |
| 14 | use crate::gpio::sealed::Pin as _; | 14 | use crate::gpio::sealed::Pin as _; |
| 15 | use crate::gpio::{self, AnyPin, Pin as GpioPin}; | 15 | use crate::gpio::{self, AnyPin, Pin as GpioPin}; |
| 16 | use crate::interrupt::{self, Interrupt}; | 16 | use crate::interrupt::typelevel::Interrupt; |
| 17 | use crate::util::{slice_in_ram_or, slice_ptr_parts, slice_ptr_parts_mut}; | 17 | use crate::util::{slice_in_ram_or, slice_ptr_parts, slice_ptr_parts_mut}; |
| 18 | use crate::{pac, Peripheral}; | 18 | use crate::{interrupt, pac, Peripheral}; |
| 19 | 19 | ||
| 20 | /// SPIS error | 20 | /// SPIS error |
| 21 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 21 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| @@ -68,7 +68,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 68 | _phantom: PhantomData<T>, | 68 | _phantom: PhantomData<T>, |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 71 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 72 | unsafe fn on_interrupt() { | 72 | unsafe fn on_interrupt() { |
| 73 | let r = T::regs(); | 73 | let r = T::regs(); |
| 74 | let s = T::state(); | 74 | let s = T::state(); |
| @@ -94,7 +94,7 @@ impl<'d, T: Instance> Spis<'d, T> { | |||
| 94 | /// Create a new SPIS driver. | 94 | /// Create a new SPIS driver. |
| 95 | pub fn new( | 95 | pub fn new( |
| 96 | spis: impl Peripheral<P = T> + 'd, | 96 | spis: impl Peripheral<P = T> + 'd, |
| 97 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 97 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 98 | cs: impl Peripheral<P = impl GpioPin> + 'd, | 98 | cs: impl Peripheral<P = impl GpioPin> + 'd, |
| 99 | sck: impl Peripheral<P = impl GpioPin> + 'd, | 99 | sck: impl Peripheral<P = impl GpioPin> + 'd, |
| 100 | miso: impl Peripheral<P = impl GpioPin> + 'd, | 100 | miso: impl Peripheral<P = impl GpioPin> + 'd, |
| @@ -115,7 +115,7 @@ impl<'d, T: Instance> Spis<'d, T> { | |||
| 115 | /// Create a new SPIS driver, capable of TX only (MISO only). | 115 | /// Create a new SPIS driver, capable of TX only (MISO only). |
| 116 | pub fn new_txonly( | 116 | pub fn new_txonly( |
| 117 | spis: impl Peripheral<P = T> + 'd, | 117 | spis: impl Peripheral<P = T> + 'd, |
| 118 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 118 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 119 | cs: impl Peripheral<P = impl GpioPin> + 'd, | 119 | cs: impl Peripheral<P = impl GpioPin> + 'd, |
| 120 | sck: impl Peripheral<P = impl GpioPin> + 'd, | 120 | sck: impl Peripheral<P = impl GpioPin> + 'd, |
| 121 | miso: impl Peripheral<P = impl GpioPin> + 'd, | 121 | miso: impl Peripheral<P = impl GpioPin> + 'd, |
| @@ -128,7 +128,7 @@ impl<'d, T: Instance> Spis<'d, T> { | |||
| 128 | /// Create a new SPIS driver, capable of RX only (MOSI only). | 128 | /// Create a new SPIS driver, capable of RX only (MOSI only). |
| 129 | pub fn new_rxonly( | 129 | pub fn new_rxonly( |
| 130 | spis: impl Peripheral<P = T> + 'd, | 130 | spis: impl Peripheral<P = T> + 'd, |
| 131 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 131 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 132 | cs: impl Peripheral<P = impl GpioPin> + 'd, | 132 | cs: impl Peripheral<P = impl GpioPin> + 'd, |
| 133 | sck: impl Peripheral<P = impl GpioPin> + 'd, | 133 | sck: impl Peripheral<P = impl GpioPin> + 'd, |
| 134 | mosi: impl Peripheral<P = impl GpioPin> + 'd, | 134 | mosi: impl Peripheral<P = impl GpioPin> + 'd, |
| @@ -480,7 +480,7 @@ pub(crate) mod sealed { | |||
| 480 | /// SPIS peripheral instance | 480 | /// SPIS peripheral instance |
| 481 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static { | 481 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static { |
| 482 | /// Interrupt for this peripheral. | 482 | /// Interrupt for this peripheral. |
| 483 | type Interrupt: Interrupt; | 483 | type Interrupt: interrupt::typelevel::Interrupt; |
| 484 | } | 484 | } |
| 485 | 485 | ||
| 486 | macro_rules! impl_spis { | 486 | macro_rules! impl_spis { |
| @@ -495,7 +495,7 @@ macro_rules! impl_spis { | |||
| 495 | } | 495 | } |
| 496 | } | 496 | } |
| 497 | impl crate::spis::Instance for peripherals::$type { | 497 | impl crate::spis::Instance for peripherals::$type { |
| 498 | type Interrupt = crate::interrupt::$irq; | 498 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 499 | } | 499 | } |
| 500 | }; | 500 | }; |
| 501 | } | 501 | } |
diff --git a/embassy-nrf/src/temp.rs b/embassy-nrf/src/temp.rs index 8a127efc5..491e92c04 100644 --- a/embassy-nrf/src/temp.rs +++ b/embassy-nrf/src/temp.rs | |||
| @@ -8,7 +8,7 @@ use embassy_hal_common::{into_ref, PeripheralRef}; | |||
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 8 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | use fixed::types::I30F2; | 9 | use fixed::types::I30F2; |
| 10 | 10 | ||
| 11 | use crate::interrupt::Interrupt; | 11 | use crate::interrupt::InterruptExt; |
| 12 | use crate::peripherals::TEMP; | 12 | use crate::peripherals::TEMP; |
| 13 | use crate::{interrupt, pac, Peripheral}; | 13 | use crate::{interrupt, pac, Peripheral}; |
| 14 | 14 | ||
| @@ -17,7 +17,7 @@ pub struct InterruptHandler { | |||
| 17 | _private: (), | 17 | _private: (), |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | impl interrupt::Handler<interrupt::TEMP> for InterruptHandler { | 20 | impl interrupt::typelevel::Handler<interrupt::typelevel::TEMP> for InterruptHandler { |
| 21 | unsafe fn on_interrupt() { | 21 | unsafe fn on_interrupt() { |
| 22 | let r = unsafe { &*pac::TEMP::PTR }; | 22 | let r = unsafe { &*pac::TEMP::PTR }; |
| 23 | r.intenclr.write(|w| w.datardy().clear()); | 23 | r.intenclr.write(|w| w.datardy().clear()); |
| @@ -36,13 +36,13 @@ impl<'d> Temp<'d> { | |||
| 36 | /// Create a new temperature sensor driver. | 36 | /// Create a new temperature sensor driver. |
| 37 | pub fn new( | 37 | pub fn new( |
| 38 | _peri: impl Peripheral<P = TEMP> + 'd, | 38 | _peri: impl Peripheral<P = TEMP> + 'd, |
| 39 | _irq: impl interrupt::Binding<interrupt::TEMP, InterruptHandler> + 'd, | 39 | _irq: impl interrupt::typelevel::Binding<interrupt::typelevel::TEMP, InterruptHandler> + 'd, |
| 40 | ) -> Self { | 40 | ) -> Self { |
| 41 | into_ref!(_peri); | 41 | into_ref!(_peri); |
| 42 | 42 | ||
| 43 | // Enable interrupt that signals temperature values | 43 | // Enable interrupt that signals temperature values |
| 44 | interrupt::TEMP::unpend(); | 44 | interrupt::TEMP.unpend(); |
| 45 | unsafe { interrupt::TEMP::enable() }; | 45 | unsafe { interrupt::TEMP.enable() }; |
| 46 | 46 | ||
| 47 | Self { _peri } | 47 | Self { _peri } |
| 48 | } | 48 | } |
diff --git a/embassy-nrf/src/time_driver.rs b/embassy-nrf/src/time_driver.rs index 4feff8a75..f1ab4f8fd 100644 --- a/embassy-nrf/src/time_driver.rs +++ b/embassy-nrf/src/time_driver.rs | |||
| @@ -7,7 +7,7 @@ use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | |||
| 7 | use embassy_sync::blocking_mutex::CriticalSectionMutex as Mutex; | 7 | use embassy_sync::blocking_mutex::CriticalSectionMutex as Mutex; |
| 8 | use embassy_time::driver::{AlarmHandle, Driver}; | 8 | use embassy_time::driver::{AlarmHandle, Driver}; |
| 9 | 9 | ||
| 10 | use crate::interrupt::Interrupt; | 10 | use crate::interrupt::InterruptExt; |
| 11 | use crate::{interrupt, pac}; | 11 | use crate::{interrupt, pac}; |
| 12 | 12 | ||
| 13 | fn rtc() -> &'static pac::rtc0::RegisterBlock { | 13 | fn rtc() -> &'static pac::rtc0::RegisterBlock { |
| @@ -142,8 +142,8 @@ impl RtcDriver { | |||
| 142 | // Wait for clear | 142 | // Wait for clear |
| 143 | while r.counter.read().bits() != 0 {} | 143 | while r.counter.read().bits() != 0 {} |
| 144 | 144 | ||
| 145 | interrupt::RTC1::set_priority(irq_prio); | 145 | interrupt::RTC1.set_priority(irq_prio); |
| 146 | unsafe { interrupt::RTC1::enable() }; | 146 | unsafe { interrupt::RTC1.enable() }; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | fn on_interrupt(&self) { | 149 | fn on_interrupt(&self) { |
| @@ -295,6 +295,7 @@ impl Driver for RtcDriver { | |||
| 295 | } | 295 | } |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | #[cfg(feature = "rt")] | ||
| 298 | #[interrupt] | 299 | #[interrupt] |
| 299 | fn RTC1() { | 300 | fn RTC1() { |
| 300 | DRIVER.on_interrupt() | 301 | DRIVER.on_interrupt() |
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs index 2a0e16a50..dc3757856 100644 --- a/embassy-nrf/src/timer.rs +++ b/embassy-nrf/src/timer.rs | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | 8 | ||
| 9 | use embassy_hal_common::{into_ref, PeripheralRef}; | 9 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 10 | 10 | ||
| 11 | use crate::interrupt::Interrupt; | ||
| 12 | use crate::ppi::{Event, Task}; | 11 | use crate::ppi::{Event, Task}; |
| 13 | use crate::{pac, Peripheral}; | 12 | use crate::{pac, Peripheral}; |
| 14 | 13 | ||
| @@ -29,7 +28,7 @@ pub(crate) mod sealed { | |||
| 29 | /// Basic Timer instance. | 28 | /// Basic Timer instance. |
| 30 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { | 29 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { |
| 31 | /// Interrupt for this peripheral. | 30 | /// Interrupt for this peripheral. |
| 32 | type Interrupt: Interrupt; | 31 | type Interrupt: crate::interrupt::typelevel::Interrupt; |
| 33 | } | 32 | } |
| 34 | 33 | ||
| 35 | /// Extended timer instance. | 34 | /// Extended timer instance. |
| @@ -44,7 +43,7 @@ macro_rules! impl_timer { | |||
| 44 | } | 43 | } |
| 45 | } | 44 | } |
| 46 | impl crate::timer::Instance for peripherals::$type { | 45 | impl crate::timer::Instance for peripherals::$type { |
| 47 | type Interrupt = crate::interrupt::$irq; | 46 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 48 | } | 47 | } |
| 49 | }; | 48 | }; |
| 50 | ($type:ident, $pac_type:ident, $irq:ident) => { | 49 | ($type:ident, $pac_type:ident, $irq:ident) => { |
diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index dea398a67..2ad0d19b1 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs | |||
| @@ -16,9 +16,9 @@ use embassy_time::{Duration, Instant}; | |||
| 16 | 16 | ||
| 17 | use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; | 17 | use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; |
| 18 | use crate::gpio::Pin as GpioPin; | 18 | use crate::gpio::Pin as GpioPin; |
| 19 | use crate::interrupt::{self, Interrupt}; | 19 | use crate::interrupt::typelevel::Interrupt; |
| 20 | use crate::util::{slice_in_ram, slice_in_ram_or}; | 20 | use crate::util::{slice_in_ram, slice_in_ram_or}; |
| 21 | use crate::{gpio, pac, Peripheral}; | 21 | use crate::{gpio, interrupt, pac, Peripheral}; |
| 22 | 22 | ||
| 23 | /// TWI frequency | 23 | /// TWI frequency |
| 24 | #[derive(Clone, Copy)] | 24 | #[derive(Clone, Copy)] |
| @@ -98,7 +98,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 98 | _phantom: PhantomData<T>, | 98 | _phantom: PhantomData<T>, |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 101 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 102 | unsafe fn on_interrupt() { | 102 | unsafe fn on_interrupt() { |
| 103 | let r = T::regs(); | 103 | let r = T::regs(); |
| 104 | let s = T::state(); | 104 | let s = T::state(); |
| @@ -123,7 +123,7 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 123 | /// Create a new TWI driver. | 123 | /// Create a new TWI driver. |
| 124 | pub fn new( | 124 | pub fn new( |
| 125 | twim: impl Peripheral<P = T> + 'd, | 125 | twim: impl Peripheral<P = T> + 'd, |
| 126 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 126 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 127 | sda: impl Peripheral<P = impl GpioPin> + 'd, | 127 | sda: impl Peripheral<P = impl GpioPin> + 'd, |
| 128 | scl: impl Peripheral<P = impl GpioPin> + 'd, | 128 | scl: impl Peripheral<P = impl GpioPin> + 'd, |
| 129 | config: Config, | 129 | config: Config, |
| @@ -750,7 +750,7 @@ pub(crate) mod sealed { | |||
| 750 | /// TWIM peripheral instance. | 750 | /// TWIM peripheral instance. |
| 751 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static { | 751 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static { |
| 752 | /// Interrupt for this peripheral. | 752 | /// Interrupt for this peripheral. |
| 753 | type Interrupt: Interrupt; | 753 | type Interrupt: interrupt::typelevel::Interrupt; |
| 754 | } | 754 | } |
| 755 | 755 | ||
| 756 | macro_rules! impl_twim { | 756 | macro_rules! impl_twim { |
| @@ -765,7 +765,7 @@ macro_rules! impl_twim { | |||
| 765 | } | 765 | } |
| 766 | } | 766 | } |
| 767 | impl crate::twim::Instance for peripherals::$type { | 767 | impl crate::twim::Instance for peripherals::$type { |
| 768 | type Interrupt = crate::interrupt::$irq; | 768 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 769 | } | 769 | } |
| 770 | }; | 770 | }; |
| 771 | } | 771 | } |
diff --git a/embassy-nrf/src/twis.rs b/embassy-nrf/src/twis.rs index 752a8c046..a115d5616 100644 --- a/embassy-nrf/src/twis.rs +++ b/embassy-nrf/src/twis.rs | |||
| @@ -15,9 +15,9 @@ use embassy_time::{Duration, Instant}; | |||
| 15 | 15 | ||
| 16 | use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; | 16 | use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; |
| 17 | use crate::gpio::Pin as GpioPin; | 17 | use crate::gpio::Pin as GpioPin; |
| 18 | use crate::interrupt::{self, Interrupt}; | 18 | use crate::interrupt::typelevel::Interrupt; |
| 19 | use crate::util::slice_in_ram_or; | 19 | use crate::util::slice_in_ram_or; |
| 20 | use crate::{gpio, pac, Peripheral}; | 20 | use crate::{gpio, interrupt, pac, Peripheral}; |
| 21 | 21 | ||
| 22 | /// TWIS config. | 22 | /// TWIS config. |
| 23 | #[non_exhaustive] | 23 | #[non_exhaustive] |
| @@ -114,7 +114,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 114 | _phantom: PhantomData<T>, | 114 | _phantom: PhantomData<T>, |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 117 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 118 | unsafe fn on_interrupt() { | 118 | unsafe fn on_interrupt() { |
| 119 | let r = T::regs(); | 119 | let r = T::regs(); |
| 120 | let s = T::state(); | 120 | let s = T::state(); |
| @@ -143,7 +143,7 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 143 | /// Create a new TWIS driver. | 143 | /// Create a new TWIS driver. |
| 144 | pub fn new( | 144 | pub fn new( |
| 145 | twis: impl Peripheral<P = T> + 'd, | 145 | twis: impl Peripheral<P = T> + 'd, |
| 146 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 146 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 147 | sda: impl Peripheral<P = impl GpioPin> + 'd, | 147 | sda: impl Peripheral<P = impl GpioPin> + 'd, |
| 148 | scl: impl Peripheral<P = impl GpioPin> + 'd, | 148 | scl: impl Peripheral<P = impl GpioPin> + 'd, |
| 149 | config: Config, | 149 | config: Config, |
| @@ -778,7 +778,7 @@ pub(crate) mod sealed { | |||
| 778 | /// TWIS peripheral instance. | 778 | /// TWIS peripheral instance. |
| 779 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static { | 779 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static { |
| 780 | /// Interrupt for this peripheral. | 780 | /// Interrupt for this peripheral. |
| 781 | type Interrupt: Interrupt; | 781 | type Interrupt: interrupt::typelevel::Interrupt; |
| 782 | } | 782 | } |
| 783 | 783 | ||
| 784 | macro_rules! impl_twis { | 784 | macro_rules! impl_twis { |
| @@ -793,7 +793,7 @@ macro_rules! impl_twis { | |||
| 793 | } | 793 | } |
| 794 | } | 794 | } |
| 795 | impl crate::twis::Instance for peripherals::$type { | 795 | impl crate::twis::Instance for peripherals::$type { |
| 796 | type Interrupt = crate::interrupt::$irq; | 796 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 797 | } | 797 | } |
| 798 | }; | 798 | }; |
| 799 | } | 799 | } |
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 6c6941ee8..85a951ae0 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs | |||
| @@ -27,11 +27,11 @@ pub use pac::uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Pari | |||
| 27 | use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; | 27 | use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; |
| 28 | use crate::gpio::sealed::Pin as _; | 28 | use crate::gpio::sealed::Pin as _; |
| 29 | use crate::gpio::{self, AnyPin, Pin as GpioPin, PselBits}; | 29 | use crate::gpio::{self, AnyPin, Pin as GpioPin, PselBits}; |
| 30 | use crate::interrupt::{self, Interrupt}; | 30 | use crate::interrupt::typelevel::Interrupt; |
| 31 | use crate::ppi::{AnyConfigurableChannel, ConfigurableChannel, Event, Ppi, Task}; | 31 | use crate::ppi::{AnyConfigurableChannel, ConfigurableChannel, Event, Ppi, Task}; |
| 32 | use crate::timer::{Frequency, Instance as TimerInstance, Timer}; | 32 | use crate::timer::{Frequency, Instance as TimerInstance, Timer}; |
| 33 | use crate::util::slice_in_ram_or; | 33 | use crate::util::slice_in_ram_or; |
| 34 | use crate::{pac, Peripheral}; | 34 | use crate::{interrupt, pac, Peripheral}; |
| 35 | 35 | ||
| 36 | /// UARTE config. | 36 | /// UARTE config. |
| 37 | #[derive(Clone)] | 37 | #[derive(Clone)] |
| @@ -68,7 +68,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 68 | _phantom: PhantomData<T>, | 68 | _phantom: PhantomData<T>, |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 71 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 72 | unsafe fn on_interrupt() { | 72 | unsafe fn on_interrupt() { |
| 73 | let r = T::regs(); | 73 | let r = T::regs(); |
| 74 | let s = T::state(); | 74 | let s = T::state(); |
| @@ -108,7 +108,7 @@ impl<'d, T: Instance> Uarte<'d, T> { | |||
| 108 | /// Create a new UARTE without hardware flow control | 108 | /// Create a new UARTE without hardware flow control |
| 109 | pub fn new( | 109 | pub fn new( |
| 110 | uarte: impl Peripheral<P = T> + 'd, | 110 | uarte: impl Peripheral<P = T> + 'd, |
| 111 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 111 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 112 | rxd: impl Peripheral<P = impl GpioPin> + 'd, | 112 | rxd: impl Peripheral<P = impl GpioPin> + 'd, |
| 113 | txd: impl Peripheral<P = impl GpioPin> + 'd, | 113 | txd: impl Peripheral<P = impl GpioPin> + 'd, |
| 114 | config: Config, | 114 | config: Config, |
| @@ -120,7 +120,7 @@ impl<'d, T: Instance> Uarte<'d, T> { | |||
| 120 | /// Create a new UARTE with hardware flow control (RTS/CTS) | 120 | /// Create a new UARTE with hardware flow control (RTS/CTS) |
| 121 | pub fn new_with_rtscts( | 121 | pub fn new_with_rtscts( |
| 122 | uarte: impl Peripheral<P = T> + 'd, | 122 | uarte: impl Peripheral<P = T> + 'd, |
| 123 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 123 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 124 | rxd: impl Peripheral<P = impl GpioPin> + 'd, | 124 | rxd: impl Peripheral<P = impl GpioPin> + 'd, |
| 125 | txd: impl Peripheral<P = impl GpioPin> + 'd, | 125 | txd: impl Peripheral<P = impl GpioPin> + 'd, |
| 126 | cts: impl Peripheral<P = impl GpioPin> + 'd, | 126 | cts: impl Peripheral<P = impl GpioPin> + 'd, |
| @@ -313,7 +313,7 @@ impl<'d, T: Instance> UarteTx<'d, T> { | |||
| 313 | /// Create a new tx-only UARTE without hardware flow control | 313 | /// Create a new tx-only UARTE without hardware flow control |
| 314 | pub fn new( | 314 | pub fn new( |
| 315 | uarte: impl Peripheral<P = T> + 'd, | 315 | uarte: impl Peripheral<P = T> + 'd, |
| 316 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 316 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 317 | txd: impl Peripheral<P = impl GpioPin> + 'd, | 317 | txd: impl Peripheral<P = impl GpioPin> + 'd, |
| 318 | config: Config, | 318 | config: Config, |
| 319 | ) -> Self { | 319 | ) -> Self { |
| @@ -324,7 +324,7 @@ impl<'d, T: Instance> UarteTx<'d, T> { | |||
| 324 | /// Create a new tx-only UARTE with hardware flow control (RTS/CTS) | 324 | /// Create a new tx-only UARTE with hardware flow control (RTS/CTS) |
| 325 | pub fn new_with_rtscts( | 325 | pub fn new_with_rtscts( |
| 326 | uarte: impl Peripheral<P = T> + 'd, | 326 | uarte: impl Peripheral<P = T> + 'd, |
| 327 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 327 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 328 | txd: impl Peripheral<P = impl GpioPin> + 'd, | 328 | txd: impl Peripheral<P = impl GpioPin> + 'd, |
| 329 | cts: impl Peripheral<P = impl GpioPin> + 'd, | 329 | cts: impl Peripheral<P = impl GpioPin> + 'd, |
| 330 | config: Config, | 330 | config: Config, |
| @@ -509,7 +509,7 @@ impl<'d, T: Instance> UarteRx<'d, T> { | |||
| 509 | /// Create a new rx-only UARTE without hardware flow control | 509 | /// Create a new rx-only UARTE without hardware flow control |
| 510 | pub fn new( | 510 | pub fn new( |
| 511 | uarte: impl Peripheral<P = T> + 'd, | 511 | uarte: impl Peripheral<P = T> + 'd, |
| 512 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 512 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 513 | rxd: impl Peripheral<P = impl GpioPin> + 'd, | 513 | rxd: impl Peripheral<P = impl GpioPin> + 'd, |
| 514 | config: Config, | 514 | config: Config, |
| 515 | ) -> Self { | 515 | ) -> Self { |
| @@ -520,7 +520,7 @@ impl<'d, T: Instance> UarteRx<'d, T> { | |||
| 520 | /// Create a new rx-only UARTE with hardware flow control (RTS/CTS) | 520 | /// Create a new rx-only UARTE with hardware flow control (RTS/CTS) |
| 521 | pub fn new_with_rtscts( | 521 | pub fn new_with_rtscts( |
| 522 | uarte: impl Peripheral<P = T> + 'd, | 522 | uarte: impl Peripheral<P = T> + 'd, |
| 523 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 523 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 524 | rxd: impl Peripheral<P = impl GpioPin> + 'd, | 524 | rxd: impl Peripheral<P = impl GpioPin> + 'd, |
| 525 | rts: impl Peripheral<P = impl GpioPin> + 'd, | 525 | rts: impl Peripheral<P = impl GpioPin> + 'd, |
| 526 | config: Config, | 526 | config: Config, |
| @@ -889,7 +889,7 @@ pub(crate) mod sealed { | |||
| 889 | /// UARTE peripheral instance. | 889 | /// UARTE peripheral instance. |
| 890 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { | 890 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { |
| 891 | /// Interrupt for this peripheral. | 891 | /// Interrupt for this peripheral. |
| 892 | type Interrupt: Interrupt; | 892 | type Interrupt: interrupt::typelevel::Interrupt; |
| 893 | } | 893 | } |
| 894 | 894 | ||
| 895 | macro_rules! impl_uarte { | 895 | macro_rules! impl_uarte { |
| @@ -908,7 +908,7 @@ macro_rules! impl_uarte { | |||
| 908 | } | 908 | } |
| 909 | } | 909 | } |
| 910 | impl crate::uarte::Instance for peripherals::$type { | 910 | impl crate::uarte::Instance for peripherals::$type { |
| 911 | type Interrupt = crate::interrupt::$irq; | 911 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 912 | } | 912 | } |
| 913 | }; | 913 | }; |
| 914 | } | 914 | } |
diff --git a/embassy-nrf/src/usb/mod.rs b/embassy-nrf/src/usb/mod.rs index 3c62b4452..76cf40ac7 100644 --- a/embassy-nrf/src/usb/mod.rs +++ b/embassy-nrf/src/usb/mod.rs | |||
| @@ -18,9 +18,9 @@ use embassy_usb_driver::{Direction, EndpointAddress, EndpointError, EndpointInfo | |||
| 18 | use pac::usbd::RegisterBlock; | 18 | use pac::usbd::RegisterBlock; |
| 19 | 19 | ||
| 20 | use self::vbus_detect::VbusDetect; | 20 | use self::vbus_detect::VbusDetect; |
| 21 | use crate::interrupt::{self, Interrupt}; | 21 | use crate::interrupt::typelevel::Interrupt; |
| 22 | use crate::util::slice_in_ram; | 22 | use crate::util::slice_in_ram; |
| 23 | use crate::{pac, Peripheral}; | 23 | use crate::{interrupt, pac, Peripheral}; |
| 24 | 24 | ||
| 25 | const NEW_AW: AtomicWaker = AtomicWaker::new(); | 25 | const NEW_AW: AtomicWaker = AtomicWaker::new(); |
| 26 | static BUS_WAKER: AtomicWaker = NEW_AW; | 26 | static BUS_WAKER: AtomicWaker = NEW_AW; |
| @@ -34,7 +34,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 34 | _phantom: PhantomData<T>, | 34 | _phantom: PhantomData<T>, |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 37 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 38 | unsafe fn on_interrupt() { | 38 | unsafe fn on_interrupt() { |
| 39 | let regs = T::regs(); | 39 | let regs = T::regs(); |
| 40 | 40 | ||
| @@ -98,7 +98,7 @@ impl<'d, T: Instance, V: VbusDetect> Driver<'d, T, V> { | |||
| 98 | /// Create a new USB driver. | 98 | /// Create a new USB driver. |
| 99 | pub fn new( | 99 | pub fn new( |
| 100 | usb: impl Peripheral<P = T> + 'd, | 100 | usb: impl Peripheral<P = T> + 'd, |
| 101 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 101 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 102 | vbus_detect: V, | 102 | vbus_detect: V, |
| 103 | ) -> Self { | 103 | ) -> Self { |
| 104 | into_ref!(usb); | 104 | into_ref!(usb); |
| @@ -804,7 +804,7 @@ pub(crate) mod sealed { | |||
| 804 | /// USB peripheral instance. | 804 | /// USB peripheral instance. |
| 805 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { | 805 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { |
| 806 | /// Interrupt for this peripheral. | 806 | /// Interrupt for this peripheral. |
| 807 | type Interrupt: Interrupt; | 807 | type Interrupt: interrupt::typelevel::Interrupt; |
| 808 | } | 808 | } |
| 809 | 809 | ||
| 810 | macro_rules! impl_usb { | 810 | macro_rules! impl_usb { |
| @@ -815,7 +815,7 @@ macro_rules! impl_usb { | |||
| 815 | } | 815 | } |
| 816 | } | 816 | } |
| 817 | impl crate::usb::Instance for peripherals::$type { | 817 | impl crate::usb::Instance for peripherals::$type { |
| 818 | type Interrupt = crate::interrupt::$irq; | 818 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 819 | } | 819 | } |
| 820 | }; | 820 | }; |
| 821 | } | 821 | } |
diff --git a/embassy-nrf/src/usb/vbus_detect.rs b/embassy-nrf/src/usb/vbus_detect.rs index a6a959905..a05e5aa52 100644 --- a/embassy-nrf/src/usb/vbus_detect.rs +++ b/embassy-nrf/src/usb/vbus_detect.rs | |||
| @@ -7,8 +7,8 @@ use core::task::Poll; | |||
| 7 | use embassy_sync::waitqueue::AtomicWaker; | 7 | use embassy_sync::waitqueue::AtomicWaker; |
| 8 | 8 | ||
| 9 | use super::BUS_WAKER; | 9 | use super::BUS_WAKER; |
| 10 | use crate::interrupt::{self, Interrupt}; | 10 | use crate::interrupt::typelevel::Interrupt; |
| 11 | use crate::pac; | 11 | use crate::{interrupt, pac}; |
| 12 | 12 | ||
| 13 | /// Trait for detecting USB VBUS power. | 13 | /// Trait for detecting USB VBUS power. |
| 14 | /// | 14 | /// |
| @@ -29,9 +29,9 @@ pub trait VbusDetect { | |||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | #[cfg(not(feature = "_nrf5340"))] | 31 | #[cfg(not(feature = "_nrf5340"))] |
| 32 | type UsbRegIrq = interrupt::POWER_CLOCK; | 32 | type UsbRegIrq = interrupt::typelevel::POWER_CLOCK; |
| 33 | #[cfg(feature = "_nrf5340")] | 33 | #[cfg(feature = "_nrf5340")] |
| 34 | type UsbRegIrq = interrupt::USBREGULATOR; | 34 | type UsbRegIrq = interrupt::typelevel::USBREGULATOR; |
| 35 | 35 | ||
| 36 | #[cfg(not(feature = "_nrf5340"))] | 36 | #[cfg(not(feature = "_nrf5340"))] |
| 37 | type UsbRegPeri = pac::POWER; | 37 | type UsbRegPeri = pac::POWER; |
| @@ -43,7 +43,7 @@ pub struct InterruptHandler { | |||
| 43 | _private: (), | 43 | _private: (), |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | impl interrupt::Handler<UsbRegIrq> for InterruptHandler { | 46 | impl interrupt::typelevel::Handler<UsbRegIrq> for InterruptHandler { |
| 47 | unsafe fn on_interrupt() { | 47 | unsafe fn on_interrupt() { |
| 48 | let regs = unsafe { &*UsbRegPeri::ptr() }; | 48 | let regs = unsafe { &*UsbRegPeri::ptr() }; |
| 49 | 49 | ||
| @@ -77,7 +77,7 @@ static POWER_WAKER: AtomicWaker = AtomicWaker::new(); | |||
| 77 | 77 | ||
| 78 | impl HardwareVbusDetect { | 78 | impl HardwareVbusDetect { |
| 79 | /// Create a new `VbusDetectNative`. | 79 | /// Create a new `VbusDetectNative`. |
| 80 | pub fn new(_irq: impl interrupt::Binding<UsbRegIrq, InterruptHandler> + 'static) -> Self { | 80 | pub fn new(_irq: impl interrupt::typelevel::Binding<UsbRegIrq, InterruptHandler> + 'static) -> Self { |
| 81 | let regs = unsafe { &*UsbRegPeri::ptr() }; | 81 | let regs = unsafe { &*UsbRegPeri::ptr() }; |
| 82 | 82 | ||
| 83 | UsbRegIrq::unpend(); | 83 | UsbRegIrq::unpend(); |
diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index ddada655b..b68f95385 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml | |||
| @@ -13,7 +13,8 @@ flavors = [ | |||
| 13 | ] | 13 | ] |
| 14 | 14 | ||
| 15 | [features] | 15 | [features] |
| 16 | default = [ "rp-pac/rt" ] | 16 | default = [ "rt" ] |
| 17 | rt = [ "rp-pac/rt" ] | ||
| 17 | 18 | ||
| 18 | defmt = ["dep:defmt", "embassy-usb-driver?/defmt", "embassy-hal-common/defmt"] | 19 | defmt = ["dep:defmt", "embassy-usb-driver?/defmt", "embassy-hal-common/defmt"] |
| 19 | 20 | ||
| @@ -47,7 +48,7 @@ boot2-w25x10cl = [] | |||
| 47 | run-from-ram = [] | 48 | run-from-ram = [] |
| 48 | 49 | ||
| 49 | # Enable nightly-only features | 50 | # Enable nightly-only features |
| 50 | nightly = ["embassy-executor/nightly", "embedded-hal-1", "embedded-hal-async", "embassy-embedded-hal/nightly", "dep:embassy-usb-driver", "dep:embedded-io"] | 51 | nightly = ["embedded-hal-1", "embedded-hal-async", "embassy-embedded-hal/nightly", "dep:embassy-usb-driver", "dep:embedded-io"] |
| 51 | 52 | ||
| 52 | # Implement embedded-hal 1.0 alpha traits. | 53 | # Implement embedded-hal 1.0 alpha traits. |
| 53 | # Implement embedded-hal-async traits if `nightly` is set as well. | 54 | # Implement embedded-hal-async traits if `nightly` is set as well. |
| @@ -55,11 +56,9 @@ unstable-traits = ["embedded-hal-1", "embedded-hal-nb"] | |||
| 55 | 56 | ||
| 56 | [dependencies] | 57 | [dependencies] |
| 57 | embassy-sync = { version = "0.2.0", path = "../embassy-sync" } | 58 | embassy-sync = { version = "0.2.0", path = "../embassy-sync" } |
| 58 | embassy-executor = { version = "0.2.0", path = "../embassy-executor" } | ||
| 59 | embassy-time = { version = "0.1.0", path = "../embassy-time", features = [ "tick-hz-1_000_000" ] } | 59 | embassy-time = { version = "0.1.0", path = "../embassy-time", features = [ "tick-hz-1_000_000" ] } |
| 60 | embassy-futures = { version = "0.1.0", path = "../embassy-futures" } | 60 | embassy-futures = { version = "0.1.0", path = "../embassy-futures" } |
| 61 | embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-2"]} | 61 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common", features = ["cortex-m", "prio-bits-2"] } |
| 62 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } | ||
| 63 | embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } | 62 | embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } |
| 64 | embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional = true } | 63 | embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional = true } |
| 65 | atomic-polyfill = "1.0.1" | 64 | atomic-polyfill = "1.0.1" |
| @@ -90,5 +89,5 @@ pio = {version= "0.2.1" } | |||
| 90 | rp2040-boot2 = "0.3" | 89 | rp2040-boot2 = "0.3" |
| 91 | 90 | ||
| 92 | [dev-dependencies] | 91 | [dev-dependencies] |
| 93 | embassy-executor = { version = "0.2.0", path = "../embassy-executor", features = ["arch-std", "executor-thread"] } | 92 | embassy-executor = { version = "0.2.0", path = "../embassy-executor", features = ["nightly", "arch-std", "executor-thread"] } |
| 94 | static_cell = "1.1" | 93 | static_cell = "1.1" |
diff --git a/embassy-rp/src/adc.rs b/embassy-rp/src/adc.rs index 86a353670..f29c4dfe1 100644 --- a/embassy-rp/src/adc.rs +++ b/embassy-rp/src/adc.rs | |||
| @@ -3,14 +3,14 @@ use core::marker::PhantomData; | |||
| 3 | use core::sync::atomic::{compiler_fence, Ordering}; | 3 | use core::sync::atomic::{compiler_fence, Ordering}; |
| 4 | use core::task::Poll; | 4 | use core::task::Poll; |
| 5 | 5 | ||
| 6 | use embassy_cortex_m::interrupt::{Binding, Interrupt}; | ||
| 7 | use embassy_sync::waitqueue::AtomicWaker; | 6 | use embassy_sync::waitqueue::AtomicWaker; |
| 8 | use embedded_hal_02::adc::{Channel, OneShot}; | 7 | use embedded_hal_02::adc::{Channel, OneShot}; |
| 9 | 8 | ||
| 10 | use crate::gpio::Pin; | 9 | use crate::gpio::Pin; |
| 11 | use crate::interrupt::{self, ADC_IRQ_FIFO}; | 10 | use crate::interrupt::typelevel::Binding; |
| 11 | use crate::interrupt::InterruptExt; | ||
| 12 | use crate::peripherals::ADC; | 12 | use crate::peripherals::ADC; |
| 13 | use crate::{pac, peripherals, Peripheral}; | 13 | use crate::{interrupt, pac, peripherals, Peripheral}; |
| 14 | static WAKER: AtomicWaker = AtomicWaker::new(); | 14 | static WAKER: AtomicWaker = AtomicWaker::new(); |
| 15 | 15 | ||
| 16 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 16 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| @@ -47,7 +47,7 @@ impl<'d> Adc<'d> { | |||
| 47 | 47 | ||
| 48 | pub fn new( | 48 | pub fn new( |
| 49 | _inner: impl Peripheral<P = ADC> + 'd, | 49 | _inner: impl Peripheral<P = ADC> + 'd, |
| 50 | _irq: impl Binding<ADC_IRQ_FIFO, InterruptHandler>, | 50 | _irq: impl Binding<interrupt::typelevel::ADC_IRQ_FIFO, InterruptHandler>, |
| 51 | _config: Config, | 51 | _config: Config, |
| 52 | ) -> Self { | 52 | ) -> Self { |
| 53 | unsafe { | 53 | unsafe { |
| @@ -62,10 +62,8 @@ impl<'d> Adc<'d> { | |||
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | // Setup IRQ | 64 | // Setup IRQ |
| 65 | unsafe { | 65 | interrupt::ADC_IRQ_FIFO.unpend(); |
| 66 | ADC_IRQ_FIFO::unpend(); | 66 | unsafe { interrupt::ADC_IRQ_FIFO.enable() }; |
| 67 | ADC_IRQ_FIFO::enable(); | ||
| 68 | }; | ||
| 69 | 67 | ||
| 70 | Self { phantom: PhantomData } | 68 | Self { phantom: PhantomData } |
| 71 | } | 69 | } |
| @@ -164,7 +162,7 @@ pub struct InterruptHandler { | |||
| 164 | _empty: (), | 162 | _empty: (), |
| 165 | } | 163 | } |
| 166 | 164 | ||
| 167 | impl interrupt::Handler<ADC_IRQ_FIFO> for InterruptHandler { | 165 | impl interrupt::typelevel::Handler<interrupt::typelevel::ADC_IRQ_FIFO> for InterruptHandler { |
| 168 | unsafe fn on_interrupt() { | 166 | unsafe fn on_interrupt() { |
| 169 | let r = Adc::regs(); | 167 | let r = Adc::regs(); |
| 170 | r.inte().write(|w| w.set_fifo(false)); | 168 | r.inte().write(|w| w.set_fifo(false)); |
diff --git a/embassy-rp/src/dma.rs b/embassy-rp/src/dma.rs index 1cbb4651a..25819f03e 100644 --- a/embassy-rp/src/dma.rs +++ b/embassy-rp/src/dma.rs | |||
| @@ -4,14 +4,15 @@ use core::pin::Pin; | |||
| 4 | use core::sync::atomic::{compiler_fence, Ordering}; | 4 | use core::sync::atomic::{compiler_fence, Ordering}; |
| 5 | use core::task::{Context, Poll}; | 5 | use core::task::{Context, Poll}; |
| 6 | 6 | ||
| 7 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 8 | use embassy_hal_common::{impl_peripheral, into_ref, Peripheral, PeripheralRef}; | 7 | use embassy_hal_common::{impl_peripheral, into_ref, Peripheral, PeripheralRef}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 8 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | use pac::dma::vals::DataSize; | 9 | use pac::dma::vals::DataSize; |
| 11 | 10 | ||
| 11 | use crate::interrupt::InterruptExt; | ||
| 12 | use crate::pac::dma::vals; | 12 | use crate::pac::dma::vals; |
| 13 | use crate::{interrupt, pac, peripherals}; | 13 | use crate::{interrupt, pac, peripherals}; |
| 14 | 14 | ||
| 15 | #[cfg(feature = "rt")] | ||
| 15 | #[interrupt] | 16 | #[interrupt] |
| 16 | unsafe fn DMA_IRQ_0() { | 17 | unsafe fn DMA_IRQ_0() { |
| 17 | let ints0 = pac::DMA.ints0().read().ints0(); | 18 | let ints0 = pac::DMA.ints0().read().ints0(); |
| @@ -29,12 +30,12 @@ unsafe fn DMA_IRQ_0() { | |||
| 29 | } | 30 | } |
| 30 | 31 | ||
| 31 | pub(crate) unsafe fn init() { | 32 | pub(crate) unsafe fn init() { |
| 32 | interrupt::DMA_IRQ_0::disable(); | 33 | interrupt::DMA_IRQ_0.disable(); |
| 33 | interrupt::DMA_IRQ_0::set_priority(interrupt::Priority::P3); | 34 | interrupt::DMA_IRQ_0.set_priority(interrupt::Priority::P3); |
| 34 | 35 | ||
| 35 | pac::DMA.inte0().write(|w| w.set_inte0(0xFFFF)); | 36 | pac::DMA.inte0().write(|w| w.set_inte0(0xFFFF)); |
| 36 | 37 | ||
| 37 | interrupt::DMA_IRQ_0::enable(); | 38 | interrupt::DMA_IRQ_0.enable(); |
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | pub unsafe fn read<'a, C: Channel, W: Word>( | 41 | pub unsafe fn read<'a, C: Channel, W: Word>( |
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index 91cef8609..66faa2489 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs | |||
| @@ -3,10 +3,10 @@ use core::future::Future; | |||
| 3 | use core::pin::Pin as FuturePin; | 3 | use core::pin::Pin as FuturePin; |
| 4 | use core::task::{Context, Poll}; | 4 | use core::task::{Context, Poll}; |
| 5 | 5 | ||
| 6 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 7 | use embassy_hal_common::{impl_peripheral, into_ref, PeripheralRef}; | 6 | use embassy_hal_common::{impl_peripheral, into_ref, PeripheralRef}; |
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 7 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | 8 | ||
| 9 | use crate::interrupt::InterruptExt; | ||
| 10 | use crate::pac::common::{Reg, RW}; | 10 | use crate::pac::common::{Reg, RW}; |
| 11 | use crate::pac::SIO; | 11 | use crate::pac::SIO; |
| 12 | use crate::{interrupt, pac, peripherals, Peripheral, RegExt}; | 12 | use crate::{interrupt, pac, peripherals, Peripheral, RegExt}; |
| @@ -137,11 +137,12 @@ pub enum InterruptTrigger { | |||
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | pub(crate) unsafe fn init() { | 139 | pub(crate) unsafe fn init() { |
| 140 | interrupt::IO_IRQ_BANK0::disable(); | 140 | interrupt::IO_IRQ_BANK0.disable(); |
| 141 | interrupt::IO_IRQ_BANK0::set_priority(interrupt::Priority::P3); | 141 | interrupt::IO_IRQ_BANK0.set_priority(interrupt::Priority::P3); |
| 142 | interrupt::IO_IRQ_BANK0::enable(); | 142 | interrupt::IO_IRQ_BANK0.enable(); |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | #[cfg(feature = "rt")] | ||
| 145 | #[interrupt] | 146 | #[interrupt] |
| 146 | unsafe fn IO_IRQ_BANK0() { | 147 | unsafe fn IO_IRQ_BANK0() { |
| 147 | let cpu = SIO.cpuid().read() as usize; | 148 | let cpu = SIO.cpuid().read() as usize; |
diff --git a/embassy-rp/src/i2c.rs b/embassy-rp/src/i2c.rs index 124f1c00a..ce9a082a2 100644 --- a/embassy-rp/src/i2c.rs +++ b/embassy-rp/src/i2c.rs | |||
| @@ -2,14 +2,14 @@ use core::future; | |||
| 2 | use core::marker::PhantomData; | 2 | use core::marker::PhantomData; |
| 3 | use core::task::Poll; | 3 | use core::task::Poll; |
| 4 | 4 | ||
| 5 | use embassy_cortex_m::interrupt::{self, Binding, Interrupt}; | ||
| 6 | use embassy_hal_common::{into_ref, PeripheralRef}; | 5 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 7 | use embassy_sync::waitqueue::AtomicWaker; | 6 | use embassy_sync::waitqueue::AtomicWaker; |
| 8 | use pac::i2c; | 7 | use pac::i2c; |
| 9 | 8 | ||
| 10 | use crate::gpio::sealed::Pin; | 9 | use crate::gpio::sealed::Pin; |
| 11 | use crate::gpio::AnyPin; | 10 | use crate::gpio::AnyPin; |
| 12 | use crate::{pac, peripherals, Peripheral}; | 11 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 12 | use crate::{interrupt, pac, peripherals, Peripheral}; | ||
| 13 | 13 | ||
| 14 | /// I2C error abort reason | 14 | /// I2C error abort reason |
| 15 | #[derive(Debug)] | 15 | #[derive(Debug)] |
| @@ -312,7 +312,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 312 | _uart: PhantomData<T>, | 312 | _uart: PhantomData<T>, |
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 315 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 316 | // Mask interrupts and wake any task waiting for this interrupt | 316 | // Mask interrupts and wake any task waiting for this interrupt |
| 317 | unsafe fn on_interrupt() { | 317 | unsafe fn on_interrupt() { |
| 318 | let i2c = T::regs(); | 318 | let i2c = T::regs(); |
| @@ -760,14 +760,15 @@ fn i2c_reserved_addr(addr: u16) -> bool { | |||
| 760 | } | 760 | } |
| 761 | 761 | ||
| 762 | mod sealed { | 762 | mod sealed { |
| 763 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 764 | use embassy_sync::waitqueue::AtomicWaker; | 763 | use embassy_sync::waitqueue::AtomicWaker; |
| 765 | 764 | ||
| 765 | use crate::interrupt; | ||
| 766 | |||
| 766 | pub trait Instance { | 767 | pub trait Instance { |
| 767 | const TX_DREQ: u8; | 768 | const TX_DREQ: u8; |
| 768 | const RX_DREQ: u8; | 769 | const RX_DREQ: u8; |
| 769 | 770 | ||
| 770 | type Interrupt: Interrupt; | 771 | type Interrupt: interrupt::typelevel::Interrupt; |
| 771 | 772 | ||
| 772 | fn regs() -> crate::pac::i2c::I2c; | 773 | fn regs() -> crate::pac::i2c::I2c; |
| 773 | fn reset() -> crate::pac::resets::regs::Peripherals; | 774 | fn reset() -> crate::pac::resets::regs::Peripherals; |
| @@ -803,7 +804,7 @@ macro_rules! impl_instance { | |||
| 803 | const TX_DREQ: u8 = $tx_dreq; | 804 | const TX_DREQ: u8 = $tx_dreq; |
| 804 | const RX_DREQ: u8 = $rx_dreq; | 805 | const RX_DREQ: u8 = $rx_dreq; |
| 805 | 806 | ||
| 806 | type Interrupt = crate::interrupt::$irq; | 807 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 807 | 808 | ||
| 808 | #[inline] | 809 | #[inline] |
| 809 | fn regs() -> pac::i2c::I2c { | 810 | fn regs() -> pac::i2c::I2c { |
diff --git a/embassy-rp/src/interrupt.rs b/embassy-rp/src/interrupt.rs deleted file mode 100644 index c9298644d..000000000 --- a/embassy-rp/src/interrupt.rs +++ /dev/null | |||
| @@ -1,65 +0,0 @@ | |||
| 1 | //! Interrupt definitions and macros to bind them. | ||
| 2 | pub use cortex_m::interrupt::{CriticalSection, Mutex}; | ||
| 3 | use embassy_cortex_m::interrupt::_export::declare; | ||
| 4 | pub use embassy_cortex_m::interrupt::{Binding, Handler, Interrupt, Priority}; | ||
| 5 | |||
| 6 | use crate::pac::Interrupt as InterruptEnum; | ||
| 7 | declare!(TIMER_IRQ_0); | ||
| 8 | declare!(TIMER_IRQ_1); | ||
| 9 | declare!(TIMER_IRQ_2); | ||
| 10 | declare!(TIMER_IRQ_3); | ||
| 11 | declare!(PWM_IRQ_WRAP); | ||
| 12 | declare!(USBCTRL_IRQ); | ||
| 13 | declare!(XIP_IRQ); | ||
| 14 | declare!(PIO0_IRQ_0); | ||
| 15 | declare!(PIO0_IRQ_1); | ||
| 16 | declare!(PIO1_IRQ_0); | ||
| 17 | declare!(PIO1_IRQ_1); | ||
| 18 | declare!(DMA_IRQ_0); | ||
| 19 | declare!(DMA_IRQ_1); | ||
| 20 | declare!(IO_IRQ_BANK0); | ||
| 21 | declare!(IO_IRQ_QSPI); | ||
| 22 | declare!(SIO_IRQ_PROC0); | ||
| 23 | declare!(SIO_IRQ_PROC1); | ||
| 24 | declare!(CLOCKS_IRQ); | ||
| 25 | declare!(SPI0_IRQ); | ||
| 26 | declare!(SPI1_IRQ); | ||
| 27 | declare!(UART0_IRQ); | ||
| 28 | declare!(UART1_IRQ); | ||
| 29 | declare!(ADC_IRQ_FIFO); | ||
| 30 | declare!(I2C0_IRQ); | ||
| 31 | declare!(I2C1_IRQ); | ||
| 32 | declare!(RTC_IRQ); | ||
| 33 | declare!(SWI_IRQ_0); | ||
| 34 | declare!(SWI_IRQ_1); | ||
| 35 | declare!(SWI_IRQ_2); | ||
| 36 | declare!(SWI_IRQ_3); | ||
| 37 | declare!(SWI_IRQ_4); | ||
| 38 | declare!(SWI_IRQ_5); | ||
| 39 | |||
| 40 | /// Macro to bind interrupts to handlers. | ||
| 41 | /// | ||
| 42 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) | ||
| 43 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to | ||
| 44 | /// prove at compile-time that the right interrupts have been bound. | ||
| 45 | // developer note: this macro can't be in `embassy-cortex-m` due to the use of `$crate`. | ||
| 46 | #[macro_export] | ||
| 47 | macro_rules! bind_interrupts { | ||
| 48 | ($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => { | ||
| 49 | $vis struct $name; | ||
| 50 | |||
| 51 | $( | ||
| 52 | #[allow(non_snake_case)] | ||
| 53 | #[no_mangle] | ||
| 54 | unsafe extern "C" fn $irq() { | ||
| 55 | $( | ||
| 56 | <$handler as $crate::interrupt::Handler<$crate::interrupt::$irq>>::on_interrupt(); | ||
| 57 | )* | ||
| 58 | } | ||
| 59 | |||
| 60 | $( | ||
| 61 | unsafe impl $crate::interrupt::Binding<$crate::interrupt::$irq, $handler> for $name {} | ||
| 62 | )* | ||
| 63 | )* | ||
| 64 | }; | ||
| 65 | } | ||
diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs index 4e4542d70..d6f73219f 100644 --- a/embassy-rp/src/lib.rs +++ b/embassy-rp/src/lib.rs | |||
| @@ -16,7 +16,6 @@ pub mod flash; | |||
| 16 | mod float; | 16 | mod float; |
| 17 | pub mod gpio; | 17 | pub mod gpio; |
| 18 | pub mod i2c; | 18 | pub mod i2c; |
| 19 | pub mod interrupt; | ||
| 20 | pub mod multicore; | 19 | pub mod multicore; |
| 21 | pub mod pwm; | 20 | pub mod pwm; |
| 22 | mod reset; | 21 | mod reset; |
| @@ -37,14 +36,77 @@ pub mod pio_instr_util; | |||
| 37 | pub mod relocate; | 36 | pub mod relocate; |
| 38 | 37 | ||
| 39 | // Reexports | 38 | // Reexports |
| 40 | pub use embassy_cortex_m::executor; | ||
| 41 | pub use embassy_cortex_m::interrupt::_export::interrupt; | ||
| 42 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 39 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 43 | #[cfg(feature = "unstable-pac")] | 40 | #[cfg(feature = "unstable-pac")] |
| 44 | pub use rp_pac as pac; | 41 | pub use rp_pac as pac; |
| 45 | #[cfg(not(feature = "unstable-pac"))] | 42 | #[cfg(not(feature = "unstable-pac"))] |
| 46 | pub(crate) use rp_pac as pac; | 43 | pub(crate) use rp_pac as pac; |
| 47 | 44 | ||
| 45 | #[cfg(feature = "rt")] | ||
| 46 | pub use crate::pac::NVIC_PRIO_BITS; | ||
| 47 | |||
| 48 | embassy_hal_common::interrupt_mod!( | ||
| 49 | TIMER_IRQ_0, | ||
| 50 | TIMER_IRQ_1, | ||
| 51 | TIMER_IRQ_2, | ||
| 52 | TIMER_IRQ_3, | ||
| 53 | PWM_IRQ_WRAP, | ||
| 54 | USBCTRL_IRQ, | ||
| 55 | XIP_IRQ, | ||
| 56 | PIO0_IRQ_0, | ||
| 57 | PIO0_IRQ_1, | ||
| 58 | PIO1_IRQ_0, | ||
| 59 | PIO1_IRQ_1, | ||
| 60 | DMA_IRQ_0, | ||
| 61 | DMA_IRQ_1, | ||
| 62 | IO_IRQ_BANK0, | ||
| 63 | IO_IRQ_QSPI, | ||
| 64 | SIO_IRQ_PROC0, | ||
| 65 | SIO_IRQ_PROC1, | ||
| 66 | CLOCKS_IRQ, | ||
| 67 | SPI0_IRQ, | ||
| 68 | SPI1_IRQ, | ||
| 69 | UART0_IRQ, | ||
| 70 | UART1_IRQ, | ||
| 71 | ADC_IRQ_FIFO, | ||
| 72 | I2C0_IRQ, | ||
| 73 | I2C1_IRQ, | ||
| 74 | RTC_IRQ, | ||
| 75 | SWI_IRQ_0, | ||
| 76 | SWI_IRQ_1, | ||
| 77 | SWI_IRQ_2, | ||
| 78 | SWI_IRQ_3, | ||
| 79 | SWI_IRQ_4, | ||
| 80 | SWI_IRQ_5, | ||
| 81 | ); | ||
| 82 | |||
| 83 | /// Macro to bind interrupts to handlers. | ||
| 84 | /// | ||
| 85 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) | ||
| 86 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to | ||
| 87 | /// prove at compile-time that the right interrupts have been bound. | ||
| 88 | // developer note: this macro can't be in `embassy-hal-common` due to the use of `$crate`. | ||
| 89 | #[macro_export] | ||
| 90 | macro_rules! bind_interrupts { | ||
| 91 | ($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => { | ||
| 92 | $vis struct $name; | ||
| 93 | |||
| 94 | $( | ||
| 95 | #[allow(non_snake_case)] | ||
| 96 | #[no_mangle] | ||
| 97 | unsafe extern "C" fn $irq() { | ||
| 98 | $( | ||
| 99 | <$handler as $crate::interrupt::typelevel::Handler<$crate::interrupt::typelevel::$irq>>::on_interrupt(); | ||
| 100 | )* | ||
| 101 | } | ||
| 102 | |||
| 103 | $( | ||
| 104 | unsafe impl $crate::interrupt::typelevel::Binding<$crate::interrupt::typelevel::$irq, $handler> for $name {} | ||
| 105 | )* | ||
| 106 | )* | ||
| 107 | }; | ||
| 108 | } | ||
| 109 | |||
| 48 | embassy_hal_common::peripherals! { | 110 | embassy_hal_common::peripherals! { |
| 49 | PIN_0, | 111 | PIN_0, |
| 50 | PIN_1, | 112 | PIN_1, |
diff --git a/embassy-rp/src/multicore.rs b/embassy-rp/src/multicore.rs index 807fda57b..2a7e4822a 100644 --- a/embassy-rp/src/multicore.rs +++ b/embassy-rp/src/multicore.rs | |||
| @@ -50,7 +50,7 @@ | |||
| 50 | use core::mem::ManuallyDrop; | 50 | use core::mem::ManuallyDrop; |
| 51 | use core::sync::atomic::{compiler_fence, AtomicBool, Ordering}; | 51 | use core::sync::atomic::{compiler_fence, AtomicBool, Ordering}; |
| 52 | 52 | ||
| 53 | use crate::interrupt::Interrupt; | 53 | use crate::interrupt::InterruptExt; |
| 54 | use crate::peripherals::CORE1; | 54 | use crate::peripherals::CORE1; |
| 55 | use crate::{gpio, interrupt, pac}; | 55 | use crate::{gpio, interrupt, pac}; |
| 56 | 56 | ||
| @@ -106,6 +106,7 @@ impl<const SIZE: usize> Stack<SIZE> { | |||
| 106 | } | 106 | } |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | #[cfg(feature = "rt")] | ||
| 109 | #[interrupt] | 110 | #[interrupt] |
| 110 | #[link_section = ".data.ram_func"] | 111 | #[link_section = ".data.ram_func"] |
| 111 | unsafe fn SIO_IRQ_PROC1() { | 112 | unsafe fn SIO_IRQ_PROC1() { |
| @@ -156,7 +157,7 @@ where | |||
| 156 | 157 | ||
| 157 | IS_CORE1_INIT.store(true, Ordering::Release); | 158 | IS_CORE1_INIT.store(true, Ordering::Release); |
| 158 | // Enable fifo interrupt on CORE1 for `pause` functionality. | 159 | // Enable fifo interrupt on CORE1 for `pause` functionality. |
| 159 | unsafe { interrupt::SIO_IRQ_PROC1::enable() }; | 160 | unsafe { interrupt::SIO_IRQ_PROC1.enable() }; |
| 160 | 161 | ||
| 161 | entry() | 162 | entry() |
| 162 | } | 163 | } |
| @@ -297,6 +298,7 @@ fn fifo_read() -> u32 { | |||
| 297 | 298 | ||
| 298 | // Pop a value from inter-core FIFO, `wfe` until available | 299 | // Pop a value from inter-core FIFO, `wfe` until available |
| 299 | #[inline(always)] | 300 | #[inline(always)] |
| 301 | #[allow(unused)] | ||
| 300 | fn fifo_read_wfe() -> u32 { | 302 | fn fifo_read_wfe() -> u32 { |
| 301 | unsafe { | 303 | unsafe { |
| 302 | let sio = pac::SIO; | 304 | let sio = pac::SIO; |
diff --git a/embassy-rp/src/pio.rs b/embassy-rp/src/pio.rs index 93e5bd34b..0fa3bd771 100644 --- a/embassy-rp/src/pio.rs +++ b/embassy-rp/src/pio.rs | |||
| @@ -5,7 +5,6 @@ use core::sync::atomic::{compiler_fence, Ordering}; | |||
| 5 | use core::task::{Context, Poll}; | 5 | use core::task::{Context, Poll}; |
| 6 | 6 | ||
| 7 | use atomic_polyfill::{AtomicU32, AtomicU8}; | 7 | use atomic_polyfill::{AtomicU32, AtomicU8}; |
| 8 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 9 | use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 8 | use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 10 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 11 | use fixed::types::extra::U8; | 10 | use fixed::types::extra::U8; |
| @@ -17,6 +16,7 @@ use pio::{SideSet, Wrap}; | |||
| 17 | use crate::dma::{Channel, Transfer, Word}; | 16 | use crate::dma::{Channel, Transfer, Word}; |
| 18 | use crate::gpio::sealed::Pin as SealedPin; | 17 | use crate::gpio::sealed::Pin as SealedPin; |
| 19 | use crate::gpio::{self, AnyPin, Drive, Level, Pull, SlewRate}; | 18 | use crate::gpio::{self, AnyPin, Drive, Level, Pull, SlewRate}; |
| 19 | use crate::interrupt::InterruptExt; | ||
| 20 | use crate::pac::dma::vals::TreqSel; | 20 | use crate::pac::dma::vals::TreqSel; |
| 21 | use crate::relocate::RelocatedProgram; | 21 | use crate::relocate::RelocatedProgram; |
| 22 | use crate::{interrupt, pac, peripherals, pio_instr_util, RegExt}; | 22 | use crate::{interrupt, pac, peripherals, pio_instr_util, RegExt}; |
| @@ -85,6 +85,7 @@ const RXNEMPTY_MASK: u32 = 1 << 0; | |||
| 85 | const TXNFULL_MASK: u32 = 1 << 4; | 85 | const TXNFULL_MASK: u32 = 1 << 4; |
| 86 | const SMIRQ_MASK: u32 = 1 << 8; | 86 | const SMIRQ_MASK: u32 = 1 << 8; |
| 87 | 87 | ||
| 88 | #[cfg(feature = "rt")] | ||
| 88 | #[interrupt] | 89 | #[interrupt] |
| 89 | unsafe fn PIO0_IRQ_0() { | 90 | unsafe fn PIO0_IRQ_0() { |
| 90 | use crate::pac; | 91 | use crate::pac; |
| @@ -97,6 +98,7 @@ unsafe fn PIO0_IRQ_0() { | |||
| 97 | pac::PIO0.irqs(0).inte().write_clear(|m| m.0 = ints); | 98 | pac::PIO0.irqs(0).inte().write_clear(|m| m.0 = ints); |
| 98 | } | 99 | } |
| 99 | 100 | ||
| 101 | #[cfg(feature = "rt")] | ||
| 100 | #[interrupt] | 102 | #[interrupt] |
| 101 | unsafe fn PIO1_IRQ_0() { | 103 | unsafe fn PIO1_IRQ_0() { |
| 102 | use crate::pac; | 104 | use crate::pac; |
| @@ -110,15 +112,15 @@ unsafe fn PIO1_IRQ_0() { | |||
| 110 | } | 112 | } |
| 111 | 113 | ||
| 112 | pub(crate) unsafe fn init() { | 114 | pub(crate) unsafe fn init() { |
| 113 | interrupt::PIO0_IRQ_0::disable(); | 115 | interrupt::PIO0_IRQ_0.disable(); |
| 114 | interrupt::PIO0_IRQ_0::set_priority(interrupt::Priority::P3); | 116 | interrupt::PIO0_IRQ_0.set_priority(interrupt::Priority::P3); |
| 115 | pac::PIO0.irqs(0).inte().write(|m| m.0 = 0); | 117 | pac::PIO0.irqs(0).inte().write(|m| m.0 = 0); |
| 116 | interrupt::PIO0_IRQ_0::enable(); | 118 | interrupt::PIO0_IRQ_0.enable(); |
| 117 | 119 | ||
| 118 | interrupt::PIO1_IRQ_0::disable(); | 120 | interrupt::PIO1_IRQ_0.disable(); |
| 119 | interrupt::PIO1_IRQ_0::set_priority(interrupt::Priority::P3); | 121 | interrupt::PIO1_IRQ_0.set_priority(interrupt::Priority::P3); |
| 120 | pac::PIO1.irqs(0).inte().write(|m| m.0 = 0); | 122 | pac::PIO1.irqs(0).inte().write(|m| m.0 = 0); |
| 121 | interrupt::PIO1_IRQ_0::enable(); | 123 | interrupt::PIO1_IRQ_0.enable(); |
| 122 | } | 124 | } |
| 123 | 125 | ||
| 124 | /// Future that waits for TX-FIFO to become writable | 126 | /// Future that waits for TX-FIFO to become writable |
diff --git a/embassy-rp/src/timer.rs b/embassy-rp/src/timer.rs index 68793950f..ca8c96c0f 100644 --- a/embassy-rp/src/timer.rs +++ b/embassy-rp/src/timer.rs | |||
| @@ -6,7 +6,7 @@ use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | |||
| 6 | use embassy_sync::blocking_mutex::Mutex; | 6 | use embassy_sync::blocking_mutex::Mutex; |
| 7 | use embassy_time::driver::{AlarmHandle, Driver}; | 7 | use embassy_time::driver::{AlarmHandle, Driver}; |
| 8 | 8 | ||
| 9 | use crate::interrupt::Interrupt; | 9 | use crate::interrupt::InterruptExt; |
| 10 | use crate::{interrupt, pac}; | 10 | use crate::{interrupt, pac}; |
| 11 | 11 | ||
| 12 | struct AlarmState { | 12 | struct AlarmState { |
| @@ -145,27 +145,31 @@ pub unsafe fn init() { | |||
| 145 | w.set_alarm(2, true); | 145 | w.set_alarm(2, true); |
| 146 | w.set_alarm(3, true); | 146 | w.set_alarm(3, true); |
| 147 | }); | 147 | }); |
| 148 | interrupt::TIMER_IRQ_0::enable(); | 148 | interrupt::TIMER_IRQ_0.enable(); |
| 149 | interrupt::TIMER_IRQ_1::enable(); | 149 | interrupt::TIMER_IRQ_1.enable(); |
| 150 | interrupt::TIMER_IRQ_2::enable(); | 150 | interrupt::TIMER_IRQ_2.enable(); |
| 151 | interrupt::TIMER_IRQ_3::enable(); | 151 | interrupt::TIMER_IRQ_3.enable(); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | #[cfg(feature = "rt")] | ||
| 154 | #[interrupt] | 155 | #[interrupt] |
| 155 | unsafe fn TIMER_IRQ_0() { | 156 | unsafe fn TIMER_IRQ_0() { |
| 156 | DRIVER.check_alarm(0) | 157 | DRIVER.check_alarm(0) |
| 157 | } | 158 | } |
| 158 | 159 | ||
| 160 | #[cfg(feature = "rt")] | ||
| 159 | #[interrupt] | 161 | #[interrupt] |
| 160 | unsafe fn TIMER_IRQ_1() { | 162 | unsafe fn TIMER_IRQ_1() { |
| 161 | DRIVER.check_alarm(1) | 163 | DRIVER.check_alarm(1) |
| 162 | } | 164 | } |
| 163 | 165 | ||
| 166 | #[cfg(feature = "rt")] | ||
| 164 | #[interrupt] | 167 | #[interrupt] |
| 165 | unsafe fn TIMER_IRQ_2() { | 168 | unsafe fn TIMER_IRQ_2() { |
| 166 | DRIVER.check_alarm(2) | 169 | DRIVER.check_alarm(2) |
| 167 | } | 170 | } |
| 168 | 171 | ||
| 172 | #[cfg(feature = "rt")] | ||
| 169 | #[interrupt] | 173 | #[interrupt] |
| 170 | unsafe fn TIMER_IRQ_3() { | 174 | unsafe fn TIMER_IRQ_3() { |
| 171 | DRIVER.check_alarm(3) | 175 | DRIVER.check_alarm(3) |
diff --git a/embassy-rp/src/uart/buffered.rs b/embassy-rp/src/uart/buffered.rs index bb808c467..6660d5dc9 100644 --- a/embassy-rp/src/uart/buffered.rs +++ b/embassy-rp/src/uart/buffered.rs | |||
| @@ -3,14 +3,14 @@ use core::slice; | |||
| 3 | use core::task::Poll; | 3 | use core::task::Poll; |
| 4 | 4 | ||
| 5 | use atomic_polyfill::{AtomicU8, Ordering}; | 5 | use atomic_polyfill::{AtomicU8, Ordering}; |
| 6 | use embassy_cortex_m::interrupt::{self, Binding, Interrupt}; | ||
| 7 | use embassy_hal_common::atomic_ring_buffer::RingBuffer; | 6 | use embassy_hal_common::atomic_ring_buffer::RingBuffer; |
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 7 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | 9 | ||
| 11 | use super::*; | 10 | use super::*; |
| 12 | use crate::clocks::clk_peri_freq; | 11 | use crate::clocks::clk_peri_freq; |
| 13 | use crate::RegExt; | 12 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 13 | use crate::{interrupt, RegExt}; | ||
| 14 | 14 | ||
| 15 | pub struct State { | 15 | pub struct State { |
| 16 | tx_waker: AtomicWaker, | 16 | tx_waker: AtomicWaker, |
| @@ -485,7 +485,7 @@ pub struct BufferedInterruptHandler<T: Instance> { | |||
| 485 | _uart: PhantomData<T>, | 485 | _uart: PhantomData<T>, |
| 486 | } | 486 | } |
| 487 | 487 | ||
| 488 | impl<T: Instance> interrupt::Handler<T::Interrupt> for BufferedInterruptHandler<T> { | 488 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for BufferedInterruptHandler<T> { |
| 489 | unsafe fn on_interrupt() { | 489 | unsafe fn on_interrupt() { |
| 490 | let r = T::regs(); | 490 | let r = T::regs(); |
| 491 | if r.uartdmacr().read().rxdmae() { | 491 | if r.uartdmacr().read().rxdmae() { |
diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs index a83d94e49..5e3ae8a25 100644 --- a/embassy-rp/src/uart/mod.rs +++ b/embassy-rp/src/uart/mod.rs | |||
| @@ -3,7 +3,6 @@ use core::marker::PhantomData; | |||
| 3 | use core::task::Poll; | 3 | use core::task::Poll; |
| 4 | 4 | ||
| 5 | use atomic_polyfill::{AtomicU16, Ordering}; | 5 | use atomic_polyfill::{AtomicU16, Ordering}; |
| 6 | use embassy_cortex_m::interrupt::{self, Binding, Interrupt}; | ||
| 7 | use embassy_futures::select::{select, Either}; | 6 | use embassy_futures::select::{select, Either}; |
| 8 | use embassy_hal_common::{into_ref, PeripheralRef}; | 7 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 8 | use embassy_sync::waitqueue::AtomicWaker; |
| @@ -14,8 +13,9 @@ use crate::clocks::clk_peri_freq; | |||
| 14 | use crate::dma::{AnyChannel, Channel}; | 13 | use crate::dma::{AnyChannel, Channel}; |
| 15 | use crate::gpio::sealed::Pin; | 14 | use crate::gpio::sealed::Pin; |
| 16 | use crate::gpio::AnyPin; | 15 | use crate::gpio::AnyPin; |
| 16 | use crate::interrupt::typelevel::{Binding, Interrupt}; | ||
| 17 | use crate::pac::io::vals::{Inover, Outover}; | 17 | use crate::pac::io::vals::{Inover, Outover}; |
| 18 | use crate::{pac, peripherals, Peripheral, RegExt}; | 18 | use crate::{interrupt, pac, peripherals, Peripheral, RegExt}; |
| 19 | 19 | ||
| 20 | #[cfg(feature = "nightly")] | 20 | #[cfg(feature = "nightly")] |
| 21 | mod buffered; | 21 | mod buffered; |
| @@ -332,7 +332,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 332 | _uart: PhantomData<T>, | 332 | _uart: PhantomData<T>, |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 335 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 336 | unsafe fn on_interrupt() { | 336 | unsafe fn on_interrupt() { |
| 337 | let uart = T::regs(); | 337 | let uart = T::regs(); |
| 338 | if !uart.uartdmacr().read().rxdmae() { | 338 | if !uart.uartdmacr().read().rxdmae() { |
| @@ -930,7 +930,7 @@ mod sealed { | |||
| 930 | const TX_DREQ: u8; | 930 | const TX_DREQ: u8; |
| 931 | const RX_DREQ: u8; | 931 | const RX_DREQ: u8; |
| 932 | 932 | ||
| 933 | type Interrupt: crate::interrupt::Interrupt; | 933 | type Interrupt: interrupt::typelevel::Interrupt; |
| 934 | 934 | ||
| 935 | fn regs() -> pac::uart::Uart; | 935 | fn regs() -> pac::uart::Uart; |
| 936 | 936 | ||
| @@ -968,7 +968,7 @@ macro_rules! impl_instance { | |||
| 968 | const TX_DREQ: u8 = $tx_dreq; | 968 | const TX_DREQ: u8 = $tx_dreq; |
| 969 | const RX_DREQ: u8 = $rx_dreq; | 969 | const RX_DREQ: u8 = $rx_dreq; |
| 970 | 970 | ||
| 971 | type Interrupt = crate::interrupt::$irq; | 971 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 972 | 972 | ||
| 973 | fn regs() -> pac::uart::Uart { | 973 | fn regs() -> pac::uart::Uart { |
| 974 | pac::$inst | 974 | pac::$inst |
diff --git a/embassy-rp/src/usb.rs b/embassy-rp/src/usb.rs index cc88226df..9fb0dfb70 100644 --- a/embassy-rp/src/usb.rs +++ b/embassy-rp/src/usb.rs | |||
| @@ -4,15 +4,14 @@ use core::slice; | |||
| 4 | use core::sync::atomic::{compiler_fence, Ordering}; | 4 | use core::sync::atomic::{compiler_fence, Ordering}; |
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | 6 | ||
| 7 | use embassy_cortex_m::interrupt::{self, Binding}; | ||
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 7 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | use embassy_usb_driver as driver; | 8 | use embassy_usb_driver as driver; |
| 10 | use embassy_usb_driver::{ | 9 | use embassy_usb_driver::{ |
| 11 | Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported, | 10 | Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported, |
| 12 | }; | 11 | }; |
| 13 | 12 | ||
| 14 | use crate::interrupt::Interrupt; | 13 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 15 | use crate::{pac, peripherals, Peripheral, RegExt}; | 14 | use crate::{interrupt, pac, peripherals, Peripheral, RegExt}; |
| 16 | 15 | ||
| 17 | pub(crate) mod sealed { | 16 | pub(crate) mod sealed { |
| 18 | pub trait Instance { | 17 | pub trait Instance { |
| @@ -22,7 +21,7 @@ pub(crate) mod sealed { | |||
| 22 | } | 21 | } |
| 23 | 22 | ||
| 24 | pub trait Instance: sealed::Instance + 'static { | 23 | pub trait Instance: sealed::Instance + 'static { |
| 25 | type Interrupt: Interrupt; | 24 | type Interrupt: interrupt::typelevel::Interrupt; |
| 26 | } | 25 | } |
| 27 | 26 | ||
| 28 | impl crate::usb::sealed::Instance for peripherals::USB { | 27 | impl crate::usb::sealed::Instance for peripherals::USB { |
| @@ -35,7 +34,7 @@ impl crate::usb::sealed::Instance for peripherals::USB { | |||
| 35 | } | 34 | } |
| 36 | 35 | ||
| 37 | impl crate::usb::Instance for peripherals::USB { | 36 | impl crate::usb::Instance for peripherals::USB { |
| 38 | type Interrupt = crate::interrupt::USBCTRL_IRQ; | 37 | type Interrupt = crate::interrupt::typelevel::USBCTRL_IRQ; |
| 39 | } | 38 | } |
| 40 | 39 | ||
| 41 | const EP_COUNT: usize = 16; | 40 | const EP_COUNT: usize = 16; |
| @@ -249,7 +248,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 249 | _uart: PhantomData<T>, | 248 | _uart: PhantomData<T>, |
| 250 | } | 249 | } |
| 251 | 250 | ||
| 252 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 251 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 253 | unsafe fn on_interrupt() { | 252 | unsafe fn on_interrupt() { |
| 254 | let regs = T::regs(); | 253 | let regs = T::regs(); |
| 255 | //let x = regs.istr().read().0; | 254 | //let x = regs.istr().read().0; |
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 4e29bb32f..f876c7146 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml | |||
| @@ -32,11 +32,9 @@ flavors = [ | |||
| 32 | 32 | ||
| 33 | [dependencies] | 33 | [dependencies] |
| 34 | embassy-sync = { version = "0.2.0", path = "../embassy-sync" } | 34 | embassy-sync = { version = "0.2.0", path = "../embassy-sync" } |
| 35 | embassy-executor = { version = "0.2.0", path = "../embassy-executor" } | ||
| 36 | embassy-time = { version = "0.1.0", path = "../embassy-time", optional = true } | 35 | embassy-time = { version = "0.1.0", path = "../embassy-time", optional = true } |
| 37 | embassy-futures = { version = "0.1.0", path = "../embassy-futures" } | 36 | embassy-futures = { version = "0.1.0", path = "../embassy-futures" } |
| 38 | embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-4"]} | 37 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common", features = ["cortex-m", "prio-bits-4"] } |
| 39 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } | ||
| 40 | embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } | 38 | embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } |
| 41 | embassy-net-driver = { version = "0.1.0", path = "../embassy-net-driver" } | 39 | embassy-net-driver = { version = "0.1.0", path = "../embassy-net-driver" } |
| 42 | embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional = true } | 40 | embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional = true } |
| @@ -79,8 +77,10 @@ quote = "1.0.15" | |||
| 79 | stm32-metapac = { version = "9", default-features = false, features = ["metadata"]} | 77 | stm32-metapac = { version = "9", default-features = false, features = ["metadata"]} |
| 80 | 78 | ||
| 81 | [features] | 79 | [features] |
| 82 | default = ["stm32-metapac/rt"] | 80 | default = ["rt"] |
| 83 | defmt = ["dep:defmt", "bxcan/unstable-defmt", "embassy-sync/defmt", "embassy-executor/defmt", "embassy-embedded-hal/defmt", "embassy-hal-common/defmt", "embedded-io?/defmt", "embassy-usb-driver?/defmt", "embassy-net-driver/defmt"] | 81 | rt = ["stm32-metapac/rt"] |
| 82 | |||
| 83 | defmt = ["dep:defmt", "bxcan/unstable-defmt", "embassy-sync/defmt", "embassy-embedded-hal/defmt", "embassy-hal-common/defmt", "embedded-io?/defmt", "embassy-usb-driver?/defmt", "embassy-net-driver/defmt"] | ||
| 84 | memory-x = ["stm32-metapac/memory-x"] | 84 | memory-x = ["stm32-metapac/memory-x"] |
| 85 | exti = [] | 85 | exti = [] |
| 86 | 86 | ||
| @@ -99,7 +99,7 @@ time-driver-tim12 = ["_time-driver"] | |||
| 99 | time-driver-tim15 = ["_time-driver"] | 99 | time-driver-tim15 = ["_time-driver"] |
| 100 | 100 | ||
| 101 | # Enable nightly-only features | 101 | # Enable nightly-only features |
| 102 | nightly = ["embassy-executor/nightly", "embedded-hal-1", "embedded-hal-async", "embedded-storage-async", "dep:embedded-io", "dep:embassy-usb-driver", "embassy-embedded-hal/nightly"] | 102 | nightly = ["embedded-hal-1", "embedded-hal-async", "embedded-storage-async", "dep:embedded-io", "dep:embassy-usb-driver", "embassy-embedded-hal/nightly"] |
| 103 | 103 | ||
| 104 | # Reexport stm32-metapac at `embassy_stm32::pac`. | 104 | # Reexport stm32-metapac at `embassy_stm32::pac`. |
| 105 | # This is unstable because semver-minor (non-breaking) releases of embassy-stm32 may major-bump (breaking) the stm32-metapac version. | 105 | # This is unstable because semver-minor (non-breaking) releases of embassy-stm32 may major-bump (breaking) the stm32-metapac version. |
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 730c78f5e..9e597f187 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -160,13 +160,11 @@ fn main() { | |||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | g.extend(quote! { | 162 | g.extend(quote! { |
| 163 | pub mod interrupt { | 163 | embassy_hal_common::interrupt_mod!( |
| 164 | use crate::pac::Interrupt as InterruptEnum; | ||
| 165 | use embassy_cortex_m::interrupt::_export::declare; | ||
| 166 | #( | 164 | #( |
| 167 | declare!(#irqs); | 165 | #irqs, |
| 168 | )* | 166 | )* |
| 169 | } | 167 | ); |
| 170 | }); | 168 | }); |
| 171 | 169 | ||
| 172 | // ======== | 170 | // ======== |
| @@ -297,6 +295,7 @@ fn main() { | |||
| 297 | let channels = channels.iter().map(|(_, dma, ch)| format_ident!("{}_{}", dma, ch)); | 295 | let channels = channels.iter().map(|(_, dma, ch)| format_ident!("{}_{}", dma, ch)); |
| 298 | 296 | ||
| 299 | g.extend(quote! { | 297 | g.extend(quote! { |
| 298 | #[cfg(feature = "rt")] | ||
| 300 | #[crate::interrupt] | 299 | #[crate::interrupt] |
| 301 | unsafe fn #irq () { | 300 | unsafe fn #irq () { |
| 302 | #( | 301 | #( |
diff --git a/embassy-stm32/src/dcmi.rs b/embassy-stm32/src/dcmi.rs index c13915a1b..41305d273 100644 --- a/embassy-stm32/src/dcmi.rs +++ b/embassy-stm32/src/dcmi.rs | |||
| @@ -8,7 +8,7 @@ use embassy_sync::waitqueue::AtomicWaker; | |||
| 8 | use crate::dma::Transfer; | 8 | use crate::dma::Transfer; |
| 9 | use crate::gpio::sealed::AFType; | 9 | use crate::gpio::sealed::AFType; |
| 10 | use crate::gpio::Speed; | 10 | use crate::gpio::Speed; |
| 11 | use crate::interrupt::Interrupt; | 11 | use crate::interrupt::typelevel::Interrupt; |
| 12 | use crate::{interrupt, Peripheral}; | 12 | use crate::{interrupt, Peripheral}; |
| 13 | 13 | ||
| 14 | /// Interrupt handler. | 14 | /// Interrupt handler. |
| @@ -16,7 +16,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 16 | _phantom: PhantomData<T>, | 16 | _phantom: PhantomData<T>, |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 19 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 20 | unsafe fn on_interrupt() { | 20 | unsafe fn on_interrupt() { |
| 21 | let ris = crate::pac::DCMI.ris().read(); | 21 | let ris = crate::pac::DCMI.ris().read(); |
| 22 | if ris.err_ris() { | 22 | if ris.err_ris() { |
| @@ -119,7 +119,7 @@ where | |||
| 119 | pub fn new_8bit( | 119 | pub fn new_8bit( |
| 120 | peri: impl Peripheral<P = T> + 'd, | 120 | peri: impl Peripheral<P = T> + 'd, |
| 121 | dma: impl Peripheral<P = Dma> + 'd, | 121 | dma: impl Peripheral<P = Dma> + 'd, |
| 122 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 122 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 123 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, | 123 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, |
| 124 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, | 124 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, |
| 125 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, | 125 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, |
| @@ -143,7 +143,7 @@ where | |||
| 143 | pub fn new_10bit( | 143 | pub fn new_10bit( |
| 144 | peri: impl Peripheral<P = T> + 'd, | 144 | peri: impl Peripheral<P = T> + 'd, |
| 145 | dma: impl Peripheral<P = Dma> + 'd, | 145 | dma: impl Peripheral<P = Dma> + 'd, |
| 146 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 146 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 147 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, | 147 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, |
| 148 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, | 148 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, |
| 149 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, | 149 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, |
| @@ -169,7 +169,7 @@ where | |||
| 169 | pub fn new_12bit( | 169 | pub fn new_12bit( |
| 170 | peri: impl Peripheral<P = T> + 'd, | 170 | peri: impl Peripheral<P = T> + 'd, |
| 171 | dma: impl Peripheral<P = Dma> + 'd, | 171 | dma: impl Peripheral<P = Dma> + 'd, |
| 172 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 172 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 173 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, | 173 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, |
| 174 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, | 174 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, |
| 175 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, | 175 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, |
| @@ -197,7 +197,7 @@ where | |||
| 197 | pub fn new_14bit( | 197 | pub fn new_14bit( |
| 198 | peri: impl Peripheral<P = T> + 'd, | 198 | peri: impl Peripheral<P = T> + 'd, |
| 199 | dma: impl Peripheral<P = Dma> + 'd, | 199 | dma: impl Peripheral<P = Dma> + 'd, |
| 200 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 200 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 201 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, | 201 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, |
| 202 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, | 202 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, |
| 203 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, | 203 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, |
| @@ -227,7 +227,7 @@ where | |||
| 227 | pub fn new_es_8bit( | 227 | pub fn new_es_8bit( |
| 228 | peri: impl Peripheral<P = T> + 'd, | 228 | peri: impl Peripheral<P = T> + 'd, |
| 229 | dma: impl Peripheral<P = Dma> + 'd, | 229 | dma: impl Peripheral<P = Dma> + 'd, |
| 230 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 230 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 231 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, | 231 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, |
| 232 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, | 232 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, |
| 233 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, | 233 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, |
| @@ -249,7 +249,7 @@ where | |||
| 249 | pub fn new_es_10bit( | 249 | pub fn new_es_10bit( |
| 250 | peri: impl Peripheral<P = T> + 'd, | 250 | peri: impl Peripheral<P = T> + 'd, |
| 251 | dma: impl Peripheral<P = Dma> + 'd, | 251 | dma: impl Peripheral<P = Dma> + 'd, |
| 252 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 252 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 253 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, | 253 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, |
| 254 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, | 254 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, |
| 255 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, | 255 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, |
| @@ -273,7 +273,7 @@ where | |||
| 273 | pub fn new_es_12bit( | 273 | pub fn new_es_12bit( |
| 274 | peri: impl Peripheral<P = T> + 'd, | 274 | peri: impl Peripheral<P = T> + 'd, |
| 275 | dma: impl Peripheral<P = Dma> + 'd, | 275 | dma: impl Peripheral<P = Dma> + 'd, |
| 276 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 276 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 277 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, | 277 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, |
| 278 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, | 278 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, |
| 279 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, | 279 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, |
| @@ -299,7 +299,7 @@ where | |||
| 299 | pub fn new_es_14bit( | 299 | pub fn new_es_14bit( |
| 300 | peri: impl Peripheral<P = T> + 'd, | 300 | peri: impl Peripheral<P = T> + 'd, |
| 301 | dma: impl Peripheral<P = Dma> + 'd, | 301 | dma: impl Peripheral<P = Dma> + 'd, |
| 302 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 302 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 303 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, | 303 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, |
| 304 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, | 304 | d1: impl Peripheral<P = impl D1Pin<T>> + 'd, |
| 305 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, | 305 | d2: impl Peripheral<P = impl D2Pin<T>> + 'd, |
| @@ -570,7 +570,7 @@ mod sealed { | |||
| 570 | } | 570 | } |
| 571 | 571 | ||
| 572 | pub trait Instance: sealed::Instance + 'static { | 572 | pub trait Instance: sealed::Instance + 'static { |
| 573 | type Interrupt: Interrupt; | 573 | type Interrupt: interrupt::typelevel::Interrupt; |
| 574 | } | 574 | } |
| 575 | 575 | ||
| 576 | pin_trait!(D0Pin, Instance); | 576 | pin_trait!(D0Pin, Instance); |
| @@ -602,7 +602,7 @@ macro_rules! impl_peripheral { | |||
| 602 | } | 602 | } |
| 603 | 603 | ||
| 604 | impl Instance for crate::peripherals::$inst { | 604 | impl Instance for crate::peripherals::$inst { |
| 605 | type Interrupt = crate::interrupt::$irq; | 605 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 606 | } | 606 | } |
| 607 | }; | 607 | }; |
| 608 | } | 608 | } |
diff --git a/embassy-stm32/src/dma/bdma.rs b/embassy-stm32/src/dma/bdma.rs index 7a1ecda35..c0a503e25 100644 --- a/embassy-stm32/src/dma/bdma.rs +++ b/embassy-stm32/src/dma/bdma.rs | |||
| @@ -6,7 +6,6 @@ use core::sync::atomic::{fence, Ordering}; | |||
| 6 | use core::task::{Context, Poll, Waker}; | 6 | use core::task::{Context, Poll, Waker}; |
| 7 | 7 | ||
| 8 | use atomic_polyfill::AtomicUsize; | 8 | use atomic_polyfill::AtomicUsize; |
| 9 | use embassy_cortex_m::interrupt::Priority; | ||
| 10 | use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 9 | use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 11 | use embassy_sync::waitqueue::AtomicWaker; | 10 | use embassy_sync::waitqueue::AtomicWaker; |
| 12 | 11 | ||
| @@ -14,7 +13,8 @@ use super::ringbuffer::{DmaCtrl, DmaRingBuffer, OverrunError}; | |||
| 14 | use super::word::{Word, WordSize}; | 13 | use super::word::{Word, WordSize}; |
| 15 | use super::Dir; | 14 | use super::Dir; |
| 16 | use crate::_generated::BDMA_CHANNEL_COUNT; | 15 | use crate::_generated::BDMA_CHANNEL_COUNT; |
| 17 | use crate::interrupt::Interrupt; | 16 | use crate::interrupt::typelevel::Interrupt; |
| 17 | use crate::interrupt::Priority; | ||
| 18 | use crate::pac; | 18 | use crate::pac; |
| 19 | use crate::pac::bdma::{regs, vals}; | 19 | use crate::pac::bdma::{regs, vals}; |
| 20 | 20 | ||
| @@ -70,8 +70,8 @@ static STATE: State = State::new(); | |||
| 70 | pub(crate) unsafe fn init(irq_priority: Priority) { | 70 | pub(crate) unsafe fn init(irq_priority: Priority) { |
| 71 | foreach_interrupt! { | 71 | foreach_interrupt! { |
| 72 | ($peri:ident, bdma, $block:ident, $signal_name:ident, $irq:ident) => { | 72 | ($peri:ident, bdma, $block:ident, $signal_name:ident, $irq:ident) => { |
| 73 | crate::interrupt::$irq::set_priority(irq_priority); | 73 | crate::interrupt::typelevel::$irq::set_priority(irq_priority); |
| 74 | crate::interrupt::$irq::enable(); | 74 | crate::interrupt::typelevel::$irq::enable(); |
| 75 | }; | 75 | }; |
| 76 | } | 76 | } |
| 77 | crate::_generated::init_bdma(); | 77 | crate::_generated::init_bdma(); |
diff --git a/embassy-stm32/src/dma/dma.rs b/embassy-stm32/src/dma/dma.rs index 3b602b991..874cb013a 100644 --- a/embassy-stm32/src/dma/dma.rs +++ b/embassy-stm32/src/dma/dma.rs | |||
| @@ -5,7 +5,6 @@ use core::sync::atomic::{fence, Ordering}; | |||
| 5 | use core::task::{Context, Poll, Waker}; | 5 | use core::task::{Context, Poll, Waker}; |
| 6 | 6 | ||
| 7 | use atomic_polyfill::AtomicUsize; | 7 | use atomic_polyfill::AtomicUsize; |
| 8 | use embassy_cortex_m::interrupt::Priority; | ||
| 9 | use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 8 | use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 10 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 11 | 10 | ||
| @@ -13,7 +12,8 @@ use super::ringbuffer::{DmaCtrl, DmaRingBuffer, OverrunError}; | |||
| 13 | use super::word::{Word, WordSize}; | 12 | use super::word::{Word, WordSize}; |
| 14 | use super::Dir; | 13 | use super::Dir; |
| 15 | use crate::_generated::DMA_CHANNEL_COUNT; | 14 | use crate::_generated::DMA_CHANNEL_COUNT; |
| 16 | use crate::interrupt::Interrupt; | 15 | use crate::interrupt::typelevel::Interrupt; |
| 16 | use crate::interrupt::Priority; | ||
| 17 | use crate::pac::dma::{regs, vals}; | 17 | use crate::pac::dma::{regs, vals}; |
| 18 | use crate::{interrupt, pac}; | 18 | use crate::{interrupt, pac}; |
| 19 | 19 | ||
| @@ -149,8 +149,8 @@ static STATE: State = State::new(); | |||
| 149 | pub(crate) unsafe fn init(irq_priority: Priority) { | 149 | pub(crate) unsafe fn init(irq_priority: Priority) { |
| 150 | foreach_interrupt! { | 150 | foreach_interrupt! { |
| 151 | ($peri:ident, dma, $block:ident, $signal_name:ident, $irq:ident) => { | 151 | ($peri:ident, dma, $block:ident, $signal_name:ident, $irq:ident) => { |
| 152 | interrupt::$irq::set_priority(irq_priority); | 152 | interrupt::typelevel::$irq::set_priority(irq_priority); |
| 153 | interrupt::$irq::enable(); | 153 | interrupt::typelevel::$irq::enable(); |
| 154 | }; | 154 | }; |
| 155 | } | 155 | } |
| 156 | crate::_generated::init_dma(); | 156 | crate::_generated::init_dma(); |
diff --git a/embassy-stm32/src/dma/gpdma.rs b/embassy-stm32/src/dma/gpdma.rs index 7f8b82b46..3f0d5e8fa 100644 --- a/embassy-stm32/src/dma/gpdma.rs +++ b/embassy-stm32/src/dma/gpdma.rs | |||
| @@ -5,14 +5,14 @@ use core::pin::Pin; | |||
| 5 | use core::sync::atomic::{fence, Ordering}; | 5 | use core::sync::atomic::{fence, Ordering}; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | 7 | ||
| 8 | use embassy_cortex_m::interrupt::Priority; | ||
| 9 | use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 8 | use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 10 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 11 | 10 | ||
| 12 | use super::word::{Word, WordSize}; | 11 | use super::word::{Word, WordSize}; |
| 13 | use super::Dir; | 12 | use super::Dir; |
| 14 | use crate::_generated::GPDMA_CHANNEL_COUNT; | 13 | use crate::_generated::GPDMA_CHANNEL_COUNT; |
| 15 | use crate::interrupt::Interrupt; | 14 | use crate::interrupt::typelevel::Interrupt; |
| 15 | use crate::interrupt::Priority; | ||
| 16 | use crate::pac; | 16 | use crate::pac; |
| 17 | use crate::pac::gpdma::vals; | 17 | use crate::pac::gpdma::vals; |
| 18 | 18 | ||
| @@ -56,8 +56,8 @@ static STATE: State = State::new(); | |||
| 56 | pub(crate) unsafe fn init(irq_priority: Priority) { | 56 | pub(crate) unsafe fn init(irq_priority: Priority) { |
| 57 | foreach_interrupt! { | 57 | foreach_interrupt! { |
| 58 | ($peri:ident, gpdma, $block:ident, $signal_name:ident, $irq:ident) => { | 58 | ($peri:ident, gpdma, $block:ident, $signal_name:ident, $irq:ident) => { |
| 59 | crate::interrupt::$irq::set_priority(irq_priority); | 59 | crate::interrupt::typelevel::$irq::set_priority(irq_priority); |
| 60 | crate::interrupt::$irq::enable(); | 60 | crate::interrupt::typelevel::$irq::enable(); |
| 61 | }; | 61 | }; |
| 62 | } | 62 | } |
| 63 | crate::_generated::init_gpdma(); | 63 | crate::_generated::init_gpdma(); |
diff --git a/embassy-stm32/src/dma/mod.rs b/embassy-stm32/src/dma/mod.rs index 3ac0d1b3d..0858587bd 100644 --- a/embassy-stm32/src/dma/mod.rs +++ b/embassy-stm32/src/dma/mod.rs | |||
| @@ -26,11 +26,11 @@ pub mod word; | |||
| 26 | 26 | ||
| 27 | use core::mem; | 27 | use core::mem; |
| 28 | 28 | ||
| 29 | use embassy_cortex_m::interrupt::Priority; | ||
| 30 | use embassy_hal_common::impl_peripheral; | 29 | use embassy_hal_common::impl_peripheral; |
| 31 | 30 | ||
| 32 | #[cfg(dmamux)] | 31 | #[cfg(dmamux)] |
| 33 | pub use self::dmamux::*; | 32 | pub use self::dmamux::*; |
| 33 | use crate::interrupt::Priority; | ||
| 34 | 34 | ||
| 35 | #[derive(Debug, Copy, Clone, PartialEq, Eq)] | 35 | #[derive(Debug, Copy, Clone, PartialEq, Eq)] |
| 36 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 36 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
diff --git a/embassy-stm32/src/eth/v1/mod.rs b/embassy-stm32/src/eth/v1/mod.rs index a5f1a268d..540cdd027 100644 --- a/embassy-stm32/src/eth/v1/mod.rs +++ b/embassy-stm32/src/eth/v1/mod.rs | |||
| @@ -5,7 +5,6 @@ mod tx_desc; | |||
| 5 | 5 | ||
| 6 | use core::sync::atomic::{fence, Ordering}; | 6 | use core::sync::atomic::{fence, Ordering}; |
| 7 | 7 | ||
| 8 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 9 | use embassy_hal_common::{into_ref, PeripheralRef}; | 8 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 10 | use stm32_metapac::eth::vals::{Apcs, Cr, Dm, DmaomrSr, Fes, Ftf, Ifg, MbProgress, Mw, Pbl, Rsf, St, Tsf}; | 9 | use stm32_metapac::eth::vals::{Apcs, Cr, Dm, DmaomrSr, Fes, Ftf, Ifg, MbProgress, Mw, Pbl, Rsf, St, Tsf}; |
| 11 | 10 | ||
| @@ -14,6 +13,7 @@ pub(crate) use self::tx_desc::{TDes, TDesRing}; | |||
| 14 | use super::*; | 13 | use super::*; |
| 15 | use crate::gpio::sealed::{AFType, Pin as __GpioPin}; | 14 | use crate::gpio::sealed::{AFType, Pin as __GpioPin}; |
| 16 | use crate::gpio::AnyPin; | 15 | use crate::gpio::AnyPin; |
| 16 | use crate::interrupt::InterruptExt; | ||
| 17 | #[cfg(eth_v1a)] | 17 | #[cfg(eth_v1a)] |
| 18 | use crate::pac::AFIO; | 18 | use crate::pac::AFIO; |
| 19 | #[cfg(any(eth_v1b, eth_v1c))] | 19 | #[cfg(any(eth_v1b, eth_v1c))] |
| @@ -24,7 +24,7 @@ use crate::{interrupt, Peripheral}; | |||
| 24 | /// Interrupt handler. | 24 | /// Interrupt handler. |
| 25 | pub struct InterruptHandler {} | 25 | pub struct InterruptHandler {} |
| 26 | 26 | ||
| 27 | impl interrupt::Handler<interrupt::ETH> for InterruptHandler { | 27 | impl interrupt::typelevel::Handler<interrupt::typelevel::ETH> for InterruptHandler { |
| 28 | unsafe fn on_interrupt() { | 28 | unsafe fn on_interrupt() { |
| 29 | WAKER.wake(); | 29 | WAKER.wake(); |
| 30 | 30 | ||
| @@ -100,7 +100,7 @@ impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> { | |||
| 100 | pub fn new<const TX: usize, const RX: usize>( | 100 | pub fn new<const TX: usize, const RX: usize>( |
| 101 | queue: &'d mut PacketQueue<TX, RX>, | 101 | queue: &'d mut PacketQueue<TX, RX>, |
| 102 | peri: impl Peripheral<P = T> + 'd, | 102 | peri: impl Peripheral<P = T> + 'd, |
| 103 | _irq: impl interrupt::Binding<interrupt::ETH, InterruptHandler> + 'd, | 103 | _irq: impl interrupt::typelevel::Binding<interrupt::typelevel::ETH, InterruptHandler> + 'd, |
| 104 | ref_clk: impl Peripheral<P = impl RefClkPin<T>> + 'd, | 104 | ref_clk: impl Peripheral<P = impl RefClkPin<T>> + 'd, |
| 105 | mdio: impl Peripheral<P = impl MDIOPin<T>> + 'd, | 105 | mdio: impl Peripheral<P = impl MDIOPin<T>> + 'd, |
| 106 | mdc: impl Peripheral<P = impl MDCPin<T>> + 'd, | 106 | mdc: impl Peripheral<P = impl MDCPin<T>> + 'd, |
| @@ -267,8 +267,8 @@ impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> { | |||
| 267 | P::phy_reset(&mut this); | 267 | P::phy_reset(&mut this); |
| 268 | P::phy_init(&mut this); | 268 | P::phy_init(&mut this); |
| 269 | 269 | ||
| 270 | interrupt::ETH::unpend(); | 270 | interrupt::ETH.unpend(); |
| 271 | interrupt::ETH::enable(); | 271 | interrupt::ETH.enable(); |
| 272 | 272 | ||
| 273 | this | 273 | this |
| 274 | } | 274 | } |
diff --git a/embassy-stm32/src/eth/v2/mod.rs b/embassy-stm32/src/eth/v2/mod.rs index 9efa436ac..3e45eafd5 100644 --- a/embassy-stm32/src/eth/v2/mod.rs +++ b/embassy-stm32/src/eth/v2/mod.rs | |||
| @@ -2,20 +2,20 @@ mod descriptors; | |||
| 2 | 2 | ||
| 3 | use core::sync::atomic::{fence, Ordering}; | 3 | use core::sync::atomic::{fence, Ordering}; |
| 4 | 4 | ||
| 5 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 6 | use embassy_hal_common::{into_ref, PeripheralRef}; | 5 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 7 | 6 | ||
| 8 | pub(crate) use self::descriptors::{RDes, RDesRing, TDes, TDesRing}; | 7 | pub(crate) use self::descriptors::{RDes, RDesRing, TDes, TDesRing}; |
| 9 | use super::*; | 8 | use super::*; |
| 10 | use crate::gpio::sealed::{AFType, Pin as _}; | 9 | use crate::gpio::sealed::{AFType, Pin as _}; |
| 11 | use crate::gpio::{AnyPin, Speed}; | 10 | use crate::gpio::{AnyPin, Speed}; |
| 11 | use crate::interrupt::InterruptExt; | ||
| 12 | use crate::pac::ETH; | 12 | use crate::pac::ETH; |
| 13 | use crate::{interrupt, Peripheral}; | 13 | use crate::{interrupt, Peripheral}; |
| 14 | 14 | ||
| 15 | /// Interrupt handler. | 15 | /// Interrupt handler. |
| 16 | pub struct InterruptHandler {} | 16 | pub struct InterruptHandler {} |
| 17 | 17 | ||
| 18 | impl interrupt::Handler<interrupt::ETH> for InterruptHandler { | 18 | impl interrupt::typelevel::Handler<interrupt::typelevel::ETH> for InterruptHandler { |
| 19 | unsafe fn on_interrupt() { | 19 | unsafe fn on_interrupt() { |
| 20 | WAKER.wake(); | 20 | WAKER.wake(); |
| 21 | 21 | ||
| @@ -64,7 +64,7 @@ impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> { | |||
| 64 | pub fn new<const TX: usize, const RX: usize>( | 64 | pub fn new<const TX: usize, const RX: usize>( |
| 65 | queue: &'d mut PacketQueue<TX, RX>, | 65 | queue: &'d mut PacketQueue<TX, RX>, |
| 66 | peri: impl Peripheral<P = T> + 'd, | 66 | peri: impl Peripheral<P = T> + 'd, |
| 67 | _irq: impl interrupt::Binding<interrupt::ETH, InterruptHandler> + 'd, | 67 | _irq: impl interrupt::typelevel::Binding<interrupt::typelevel::ETH, InterruptHandler> + 'd, |
| 68 | ref_clk: impl Peripheral<P = impl RefClkPin<T>> + 'd, | 68 | ref_clk: impl Peripheral<P = impl RefClkPin<T>> + 'd, |
| 69 | mdio: impl Peripheral<P = impl MDIOPin<T>> + 'd, | 69 | mdio: impl Peripheral<P = impl MDIOPin<T>> + 'd, |
| 70 | mdc: impl Peripheral<P = impl MDCPin<T>> + 'd, | 70 | mdc: impl Peripheral<P = impl MDCPin<T>> + 'd, |
| @@ -238,8 +238,8 @@ impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> { | |||
| 238 | P::phy_reset(&mut this); | 238 | P::phy_reset(&mut this); |
| 239 | P::phy_init(&mut this); | 239 | P::phy_init(&mut this); |
| 240 | 240 | ||
| 241 | interrupt::ETH::unpend(); | 241 | interrupt::ETH.unpend(); |
| 242 | interrupt::ETH::enable(); | 242 | interrupt::ETH.enable(); |
| 243 | 243 | ||
| 244 | this | 244 | this |
| 245 | } | 245 | } |
diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index c2fa31b20..0631ae473 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs | |||
| @@ -291,6 +291,7 @@ macro_rules! foreach_exti_irq { | |||
| 291 | 291 | ||
| 292 | macro_rules! impl_irq { | 292 | macro_rules! impl_irq { |
| 293 | ($e:ident) => { | 293 | ($e:ident) => { |
| 294 | #[cfg(feature = "rt")] | ||
| 294 | #[interrupt] | 295 | #[interrupt] |
| 295 | unsafe fn $e() { | 296 | unsafe fn $e() { |
| 296 | on_irq() | 297 | on_irq() |
| @@ -354,13 +355,13 @@ impl_exti!(EXTI15, 15); | |||
| 354 | 355 | ||
| 355 | macro_rules! enable_irq { | 356 | macro_rules! enable_irq { |
| 356 | ($e:ident) => { | 357 | ($e:ident) => { |
| 357 | crate::interrupt::$e::enable(); | 358 | crate::interrupt::typelevel::$e::enable(); |
| 358 | }; | 359 | }; |
| 359 | } | 360 | } |
| 360 | 361 | ||
| 361 | /// safety: must be called only once | 362 | /// safety: must be called only once |
| 362 | pub(crate) unsafe fn init() { | 363 | pub(crate) unsafe fn init() { |
| 363 | use crate::interrupt::Interrupt; | 364 | use crate::interrupt::typelevel::Interrupt; |
| 364 | 365 | ||
| 365 | foreach_exti_irq!(enable_irq); | 366 | foreach_exti_irq!(enable_irq); |
| 366 | 367 | ||
diff --git a/embassy-stm32/src/flash/asynch.rs b/embassy-stm32/src/flash/asynch.rs index 872614d4e..70a5ded62 100644 --- a/embassy-stm32/src/flash/asynch.rs +++ b/embassy-stm32/src/flash/asynch.rs | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | use core::marker::PhantomData; | 1 | use core::marker::PhantomData; |
| 2 | 2 | ||
| 3 | use atomic_polyfill::{fence, Ordering}; | 3 | use atomic_polyfill::{fence, Ordering}; |
| 4 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 5 | use embassy_hal_common::drop::OnDrop; | 4 | use embassy_hal_common::drop::OnDrop; |
| 6 | use embassy_hal_common::into_ref; | 5 | use embassy_hal_common::into_ref; |
| 7 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 6 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| @@ -11,6 +10,7 @@ use super::{ | |||
| 11 | blocking_read, ensure_sector_aligned, family, get_sector, Async, Error, Flash, FlashLayout, FLASH_BASE, FLASH_SIZE, | 10 | blocking_read, ensure_sector_aligned, family, get_sector, Async, Error, Flash, FlashLayout, FLASH_BASE, FLASH_SIZE, |
| 12 | WRITE_SIZE, | 11 | WRITE_SIZE, |
| 13 | }; | 12 | }; |
| 13 | use crate::interrupt::InterruptExt; | ||
| 14 | use crate::peripherals::FLASH; | 14 | use crate::peripherals::FLASH; |
| 15 | use crate::{interrupt, Peripheral}; | 15 | use crate::{interrupt, Peripheral}; |
| 16 | 16 | ||
| @@ -19,12 +19,12 @@ pub(super) static REGION_ACCESS: Mutex<CriticalSectionRawMutex, ()> = Mutex::new | |||
| 19 | impl<'d> Flash<'d, Async> { | 19 | impl<'d> Flash<'d, Async> { |
| 20 | pub fn new( | 20 | pub fn new( |
| 21 | p: impl Peripheral<P = FLASH> + 'd, | 21 | p: impl Peripheral<P = FLASH> + 'd, |
| 22 | _irq: impl interrupt::Binding<crate::interrupt::FLASH, InterruptHandler> + 'd, | 22 | _irq: impl interrupt::typelevel::Binding<crate::interrupt::typelevel::FLASH, InterruptHandler> + 'd, |
| 23 | ) -> Self { | 23 | ) -> Self { |
| 24 | into_ref!(p); | 24 | into_ref!(p); |
| 25 | 25 | ||
| 26 | crate::interrupt::FLASH::unpend(); | 26 | crate::interrupt::FLASH.unpend(); |
| 27 | unsafe { crate::interrupt::FLASH::enable() }; | 27 | unsafe { crate::interrupt::FLASH.enable() }; |
| 28 | 28 | ||
| 29 | Self { | 29 | Self { |
| 30 | inner: p, | 30 | inner: p, |
| @@ -49,7 +49,7 @@ impl<'d> Flash<'d, Async> { | |||
| 49 | /// Interrupt handler | 49 | /// Interrupt handler |
| 50 | pub struct InterruptHandler; | 50 | pub struct InterruptHandler; |
| 51 | 51 | ||
| 52 | impl interrupt::Handler<crate::interrupt::FLASH> for InterruptHandler { | 52 | impl interrupt::typelevel::Handler<crate::interrupt::typelevel::FLASH> for InterruptHandler { |
| 53 | unsafe fn on_interrupt() { | 53 | unsafe fn on_interrupt() { |
| 54 | family::on_interrupt(); | 54 | family::on_interrupt(); |
| 55 | } | 55 | } |
diff --git a/embassy-stm32/src/i2c/mod.rs b/embassy-stm32/src/i2c/mod.rs index f898fcc8b..b35678ed9 100644 --- a/embassy-stm32/src/i2c/mod.rs +++ b/embassy-stm32/src/i2c/mod.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | 2 | ||
| 3 | use crate::interrupt::Interrupt; | 3 | use crate::interrupt; |
| 4 | 4 | ||
| 5 | #[cfg_attr(i2c_v1, path = "v1.rs")] | 5 | #[cfg_attr(i2c_v1, path = "v1.rs")] |
| 6 | #[cfg_attr(i2c_v2, path = "v2.rs")] | 6 | #[cfg_attr(i2c_v2, path = "v2.rs")] |
| @@ -35,7 +35,7 @@ pub(crate) mod sealed { | |||
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | pub trait Instance: sealed::Instance + 'static { | 37 | pub trait Instance: sealed::Instance + 'static { |
| 38 | type Interrupt: Interrupt; | 38 | type Interrupt: interrupt::typelevel::Interrupt; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | pin_trait!(SclPin, Instance); | 41 | pin_trait!(SclPin, Instance); |
| @@ -57,7 +57,7 @@ foreach_interrupt!( | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | impl Instance for peripherals::$inst { | 59 | impl Instance for peripherals::$inst { |
| 60 | type Interrupt = crate::interrupt::$irq; | 60 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 61 | } | 61 | } |
| 62 | }; | 62 | }; |
| 63 | ); | 63 | ); |
diff --git a/embassy-stm32/src/i2c/v1.rs b/embassy-stm32/src/i2c/v1.rs index b9be2e587..e04038886 100644 --- a/embassy-stm32/src/i2c/v1.rs +++ b/embassy-stm32/src/i2c/v1.rs | |||
| @@ -16,7 +16,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 16 | _phantom: PhantomData<T>, | 16 | _phantom: PhantomData<T>, |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 19 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 20 | unsafe fn on_interrupt() {} | 20 | unsafe fn on_interrupt() {} |
| 21 | } | 21 | } |
| 22 | 22 | ||
| @@ -57,7 +57,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 57 | _peri: impl Peripheral<P = T> + 'd, | 57 | _peri: impl Peripheral<P = T> + 'd, |
| 58 | scl: impl Peripheral<P = impl SclPin<T>> + 'd, | 58 | scl: impl Peripheral<P = impl SclPin<T>> + 'd, |
| 59 | sda: impl Peripheral<P = impl SdaPin<T>> + 'd, | 59 | sda: impl Peripheral<P = impl SdaPin<T>> + 'd, |
| 60 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 60 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 61 | tx_dma: impl Peripheral<P = TXDMA> + 'd, | 61 | tx_dma: impl Peripheral<P = TXDMA> + 'd, |
| 62 | rx_dma: impl Peripheral<P = RXDMA> + 'd, | 62 | rx_dma: impl Peripheral<P = RXDMA> + 'd, |
| 63 | freq: Hertz, | 63 | freq: Hertz, |
diff --git a/embassy-stm32/src/i2c/v2.rs b/embassy-stm32/src/i2c/v2.rs index 10f57f700..1aaf2b46b 100644 --- a/embassy-stm32/src/i2c/v2.rs +++ b/embassy-stm32/src/i2c/v2.rs | |||
| @@ -3,7 +3,6 @@ use core::future::poll_fn; | |||
| 3 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 4 | use core::task::Poll; | 4 | use core::task::Poll; |
| 5 | 5 | ||
| 6 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 7 | use embassy_embedded_hal::SetConfig; | 6 | use embassy_embedded_hal::SetConfig; |
| 8 | use embassy_hal_common::drop::OnDrop; | 7 | use embassy_hal_common::drop::OnDrop; |
| 9 | use embassy_hal_common::{into_ref, PeripheralRef}; | 8 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| @@ -13,6 +12,7 @@ use crate::dma::{NoDma, Transfer}; | |||
| 13 | use crate::gpio::sealed::AFType; | 12 | use crate::gpio::sealed::AFType; |
| 14 | use crate::gpio::Pull; | 13 | use crate::gpio::Pull; |
| 15 | use crate::i2c::{Error, Instance, SclPin, SdaPin}; | 14 | use crate::i2c::{Error, Instance, SclPin, SdaPin}; |
| 15 | use crate::interrupt::typelevel::Interrupt; | ||
| 16 | use crate::pac::i2c; | 16 | use crate::pac::i2c; |
| 17 | use crate::time::Hertz; | 17 | use crate::time::Hertz; |
| 18 | use crate::{interrupt, Peripheral}; | 18 | use crate::{interrupt, Peripheral}; |
| @@ -22,7 +22,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 22 | _phantom: PhantomData<T>, | 22 | _phantom: PhantomData<T>, |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 25 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 26 | unsafe fn on_interrupt() { | 26 | unsafe fn on_interrupt() { |
| 27 | let regs = T::regs(); | 27 | let regs = T::regs(); |
| 28 | let isr = regs.isr().read(); | 28 | let isr = regs.isr().read(); |
| @@ -78,7 +78,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 78 | peri: impl Peripheral<P = T> + 'd, | 78 | peri: impl Peripheral<P = T> + 'd, |
| 79 | scl: impl Peripheral<P = impl SclPin<T>> + 'd, | 79 | scl: impl Peripheral<P = impl SclPin<T>> + 'd, |
| 80 | sda: impl Peripheral<P = impl SdaPin<T>> + 'd, | 80 | sda: impl Peripheral<P = impl SdaPin<T>> + 'd, |
| 81 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 81 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 82 | tx_dma: impl Peripheral<P = TXDMA> + 'd, | 82 | tx_dma: impl Peripheral<P = TXDMA> + 'd, |
| 83 | rx_dma: impl Peripheral<P = RXDMA> + 'd, | 83 | rx_dma: impl Peripheral<P = RXDMA> + 'd, |
| 84 | freq: Hertz, | 84 | freq: Hertz, |
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 8c13774a0..6fde61c06 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -72,52 +72,47 @@ pub(crate) mod _generated { | |||
| 72 | include!(concat!(env!("OUT_DIR"), "/_generated.rs")); | 72 | include!(concat!(env!("OUT_DIR"), "/_generated.rs")); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | pub mod interrupt { | 75 | pub use crate::_generated::interrupt; |
| 76 | //! Interrupt definitions and macros to bind them. | 76 | |
| 77 | pub use cortex_m::interrupt::{CriticalSection, Mutex}; | 77 | /// Macro to bind interrupts to handlers. |
| 78 | pub use embassy_cortex_m::interrupt::{Binding, Handler, Interrupt, Priority}; | 78 | /// |
| 79 | 79 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) | |
| 80 | pub use crate::_generated::interrupt::*; | 80 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to |
| 81 | 81 | /// prove at compile-time that the right interrupts have been bound. | |
| 82 | /// Macro to bind interrupts to handlers. | 82 | // developer note: this macro can't be in `embassy-hal-common` due to the use of `$crate`. |
| 83 | /// | 83 | #[macro_export] |
| 84 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) | 84 | macro_rules! bind_interrupts { |
| 85 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to | 85 | ($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => { |
| 86 | /// prove at compile-time that the right interrupts have been bound. | 86 | $vis struct $name; |
| 87 | // developer note: this macro can't be in `embassy-cortex-m` due to the use of `$crate`. | 87 | |
| 88 | #[macro_export] | 88 | $( |
| 89 | macro_rules! bind_interrupts { | 89 | #[allow(non_snake_case)] |
| 90 | ($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => { | 90 | #[no_mangle] |
| 91 | $vis struct $name; | 91 | unsafe extern "C" fn $irq() { |
| 92 | |||
| 93 | $( | ||
| 94 | #[allow(non_snake_case)] | ||
| 95 | #[no_mangle] | ||
| 96 | unsafe extern "C" fn $irq() { | ||
| 97 | $( | ||
| 98 | <$handler as $crate::interrupt::Handler<$crate::interrupt::$irq>>::on_interrupt(); | ||
| 99 | )* | ||
| 100 | } | ||
| 101 | |||
| 102 | $( | 92 | $( |
| 103 | unsafe impl $crate::interrupt::Binding<$crate::interrupt::$irq, $handler> for $name {} | 93 | <$handler as $crate::interrupt::typelevel::Handler<$crate::interrupt::typelevel::$irq>>::on_interrupt(); |
| 104 | )* | 94 | )* |
| 95 | } | ||
| 96 | |||
| 97 | $( | ||
| 98 | unsafe impl $crate::interrupt::typelevel::Binding<$crate::interrupt::typelevel::$irq, $handler> for $name {} | ||
| 105 | )* | 99 | )* |
| 106 | }; | 100 | )* |
| 107 | } | 101 | }; |
| 108 | } | 102 | } |
| 109 | 103 | ||
| 110 | // Reexports | 104 | // Reexports |
| 111 | pub use _generated::{peripherals, Peripherals}; | 105 | pub use _generated::{peripherals, Peripherals}; |
| 112 | pub use embassy_cortex_m::executor; | ||
| 113 | use embassy_cortex_m::interrupt::Priority; | ||
| 114 | pub use embassy_cortex_m::interrupt::_export::interrupt; | ||
| 115 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 106 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 116 | #[cfg(feature = "unstable-pac")] | 107 | #[cfg(feature = "unstable-pac")] |
| 117 | pub use stm32_metapac as pac; | 108 | pub use stm32_metapac as pac; |
| 118 | #[cfg(not(feature = "unstable-pac"))] | 109 | #[cfg(not(feature = "unstable-pac"))] |
| 119 | pub(crate) use stm32_metapac as pac; | 110 | pub(crate) use stm32_metapac as pac; |
| 120 | 111 | ||
| 112 | use crate::interrupt::Priority; | ||
| 113 | #[cfg(feature = "rt")] | ||
| 114 | pub use crate::pac::NVIC_PRIO_BITS; | ||
| 115 | |||
| 121 | #[non_exhaustive] | 116 | #[non_exhaustive] |
| 122 | pub struct Config { | 117 | pub struct Config { |
| 123 | pub rcc: rcc::Config, | 118 | pub rcc: rcc::Config, |
diff --git a/embassy-stm32/src/rcc/g4.rs b/embassy-stm32/src/rcc/g4.rs index 7e748c7b5..2b52416b2 100644 --- a/embassy-stm32/src/rcc/g4.rs +++ b/embassy-stm32/src/rcc/g4.rs | |||
| @@ -1,4 +1,6 @@ | |||
| 1 | use stm32_metapac::rcc::vals::{Hpre, Ppre, Sw}; | 1 | use stm32_metapac::flash::vals::Latency; |
| 2 | use stm32_metapac::rcc::vals::{Hpre, Pllsrc, Ppre, Sw}; | ||
| 3 | use stm32_metapac::FLASH; | ||
| 2 | 4 | ||
| 3 | use crate::pac::{PWR, RCC}; | 5 | use crate::pac::{PWR, RCC}; |
| 4 | use crate::rcc::{set_freqs, Clocks}; | 6 | use crate::rcc::{set_freqs, Clocks}; |
| @@ -15,6 +17,7 @@ pub const LSI_FREQ: Hertz = Hertz(32_000); | |||
| 15 | pub enum ClockSrc { | 17 | pub enum ClockSrc { |
| 16 | HSE(Hertz), | 18 | HSE(Hertz), |
| 17 | HSI16, | 19 | HSI16, |
| 20 | PLLCLK(PllSrc, PllM, PllN, PllR), | ||
| 18 | } | 21 | } |
| 19 | 22 | ||
| 20 | /// AHB prescaler | 23 | /// AHB prescaler |
| @@ -41,6 +44,128 @@ pub enum APBPrescaler { | |||
| 41 | Div16, | 44 | Div16, |
| 42 | } | 45 | } |
| 43 | 46 | ||
| 47 | /// PLL clock input source | ||
| 48 | #[derive(Clone, Copy, Debug)] | ||
| 49 | pub enum PllSrc { | ||
| 50 | HSI16, | ||
| 51 | HSE(Hertz), | ||
| 52 | } | ||
| 53 | |||
| 54 | impl Into<Pllsrc> for PllSrc { | ||
| 55 | fn into(self) -> Pllsrc { | ||
| 56 | match self { | ||
| 57 | PllSrc::HSE(..) => Pllsrc::HSE, | ||
| 58 | PllSrc::HSI16 => Pllsrc::HSI16, | ||
| 59 | } | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | #[derive(Clone, Copy)] | ||
| 64 | pub enum PllR { | ||
| 65 | Div2, | ||
| 66 | Div4, | ||
| 67 | Div6, | ||
| 68 | Div8, | ||
| 69 | } | ||
| 70 | |||
| 71 | impl PllR { | ||
| 72 | pub fn to_div(self) -> u32 { | ||
| 73 | let val: u8 = self.into(); | ||
| 74 | (val as u32 + 1) * 2 | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | impl From<PllR> for u8 { | ||
| 79 | fn from(val: PllR) -> u8 { | ||
| 80 | match val { | ||
| 81 | PllR::Div2 => 0b00, | ||
| 82 | PllR::Div4 => 0b01, | ||
| 83 | PllR::Div6 => 0b10, | ||
| 84 | PllR::Div8 => 0b11, | ||
| 85 | } | ||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 89 | seq_macro::seq!(N in 8..=127 { | ||
| 90 | #[derive(Clone, Copy)] | ||
| 91 | pub enum PllN { | ||
| 92 | #( | ||
| 93 | Mul~N, | ||
| 94 | )* | ||
| 95 | } | ||
| 96 | |||
| 97 | impl From<PllN> for u8 { | ||
| 98 | fn from(val: PllN) -> u8 { | ||
| 99 | match val { | ||
| 100 | #( | ||
| 101 | PllN::Mul~N => N, | ||
| 102 | )* | ||
| 103 | } | ||
| 104 | } | ||
| 105 | } | ||
| 106 | |||
| 107 | impl PllN { | ||
| 108 | pub fn to_mul(self) -> u32 { | ||
| 109 | match self { | ||
| 110 | #( | ||
| 111 | PllN::Mul~N => N, | ||
| 112 | )* | ||
| 113 | } | ||
| 114 | } | ||
| 115 | } | ||
| 116 | }); | ||
| 117 | |||
| 118 | // Pre-division | ||
| 119 | #[derive(Copy, Clone)] | ||
| 120 | pub enum PllM { | ||
| 121 | Div1, | ||
| 122 | Div2, | ||
| 123 | Div3, | ||
| 124 | Div4, | ||
| 125 | Div5, | ||
| 126 | Div6, | ||
| 127 | Div7, | ||
| 128 | Div8, | ||
| 129 | Div9, | ||
| 130 | Div10, | ||
| 131 | Div11, | ||
| 132 | Div12, | ||
| 133 | Div13, | ||
| 134 | Div14, | ||
| 135 | Div15, | ||
| 136 | Div16, | ||
| 137 | } | ||
| 138 | |||
| 139 | impl PllM { | ||
| 140 | pub fn to_div(self) -> u32 { | ||
| 141 | let val: u8 = self.into(); | ||
| 142 | val as u32 + 1 | ||
| 143 | } | ||
| 144 | } | ||
| 145 | |||
| 146 | impl From<PllM> for u8 { | ||
| 147 | fn from(val: PllM) -> u8 { | ||
| 148 | match val { | ||
| 149 | PllM::Div1 => 0b0000, | ||
| 150 | PllM::Div2 => 0b0001, | ||
| 151 | PllM::Div3 => 0b0010, | ||
| 152 | PllM::Div4 => 0b0011, | ||
| 153 | PllM::Div5 => 0b0100, | ||
| 154 | PllM::Div6 => 0b0101, | ||
| 155 | PllM::Div7 => 0b0110, | ||
| 156 | PllM::Div8 => 0b0111, | ||
| 157 | PllM::Div9 => 0b1000, | ||
| 158 | PllM::Div10 => 0b1001, | ||
| 159 | PllM::Div11 => 0b1010, | ||
| 160 | PllM::Div12 => 0b1011, | ||
| 161 | PllM::Div13 => 0b1100, | ||
| 162 | PllM::Div14 => 0b1101, | ||
| 163 | PllM::Div15 => 0b1110, | ||
| 164 | PllM::Div16 => 0b1111, | ||
| 165 | } | ||
| 166 | } | ||
| 167 | } | ||
| 168 | |||
| 44 | impl AHBPrescaler { | 169 | impl AHBPrescaler { |
| 45 | const fn div(self) -> u32 { | 170 | const fn div(self) -> u32 { |
| 46 | match self { | 171 | match self { |
| @@ -135,6 +260,76 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 135 | 260 | ||
| 136 | (freq.0, Sw::HSE) | 261 | (freq.0, Sw::HSE) |
| 137 | } | 262 | } |
| 263 | ClockSrc::PLLCLK(src, prediv, mul, div) => { | ||
| 264 | let src_freq = match src { | ||
| 265 | PllSrc::HSI16 => { | ||
| 266 | // Enable HSI16 as clock source for PLL | ||
| 267 | RCC.cr().write(|w| w.set_hsion(true)); | ||
| 268 | while !RCC.cr().read().hsirdy() {} | ||
| 269 | |||
| 270 | HSI_FREQ.0 | ||
| 271 | } | ||
| 272 | PllSrc::HSE(freq) => { | ||
| 273 | // Enable HSE as clock source for PLL | ||
| 274 | RCC.cr().write(|w| w.set_hseon(true)); | ||
| 275 | while !RCC.cr().read().hserdy() {} | ||
| 276 | |||
| 277 | freq.0 | ||
| 278 | } | ||
| 279 | }; | ||
| 280 | |||
| 281 | // Make sure PLL is disabled while we configure it | ||
| 282 | RCC.cr().modify(|w| w.set_pllon(false)); | ||
| 283 | while RCC.cr().read().pllrdy() {} | ||
| 284 | |||
| 285 | let freq = src_freq / prediv.to_div() * mul.to_mul() / div.to_div(); | ||
| 286 | assert!(freq <= 170_000_000); | ||
| 287 | |||
| 288 | if freq >= 150_000_000 { | ||
| 289 | // Enable Core Boost mode on freq >= 150Mhz ([RM0440] p234) | ||
| 290 | PWR.cr5().modify(|w| w.set_r1mode(false)); | ||
| 291 | // Set flash wait state in boost mode based on frequency ([RM0440] p191) | ||
| 292 | if freq <= 36_000_000 { | ||
| 293 | FLASH.acr().modify(|w| w.set_latency(Latency::WS0)); | ||
| 294 | } else if freq <= 68_000_000 { | ||
| 295 | FLASH.acr().modify(|w| w.set_latency(Latency::WS1)); | ||
| 296 | } else if freq <= 102_000_000 { | ||
| 297 | FLASH.acr().modify(|w| w.set_latency(Latency::WS2)); | ||
| 298 | } else if freq <= 136_000_000 { | ||
| 299 | FLASH.acr().modify(|w| w.set_latency(Latency::WS3)); | ||
| 300 | } else { | ||
| 301 | FLASH.acr().modify(|w| w.set_latency(Latency::WS4)); | ||
| 302 | } | ||
| 303 | } else { | ||
| 304 | PWR.cr5().modify(|w| w.set_r1mode(true)); | ||
| 305 | // Set flash wait state in normal mode based on frequency ([RM0440] p191) | ||
| 306 | if freq <= 30_000_000 { | ||
| 307 | FLASH.acr().modify(|w| w.set_latency(Latency::WS0)); | ||
| 308 | } else if freq <= 60_000_000 { | ||
| 309 | FLASH.acr().modify(|w| w.set_latency(Latency::WS1)); | ||
| 310 | } else if freq <= 80_000_000 { | ||
| 311 | FLASH.acr().modify(|w| w.set_latency(Latency::WS2)); | ||
| 312 | } else if freq <= 120_000_000 { | ||
| 313 | FLASH.acr().modify(|w| w.set_latency(Latency::WS3)); | ||
| 314 | } else { | ||
| 315 | FLASH.acr().modify(|w| w.set_latency(Latency::WS4)); | ||
| 316 | } | ||
| 317 | } | ||
| 318 | |||
| 319 | RCC.pllcfgr().write(move |w| { | ||
| 320 | w.set_plln(mul.into()); | ||
| 321 | w.set_pllm(prediv.into()); | ||
| 322 | w.set_pllr(div.into()); | ||
| 323 | w.set_pllsrc(src.into()); | ||
| 324 | }); | ||
| 325 | |||
| 326 | // Enable PLL | ||
| 327 | RCC.cr().modify(|w| w.set_pllon(true)); | ||
| 328 | while !RCC.cr().read().pllrdy() {} | ||
| 329 | RCC.pllcfgr().modify(|w| w.set_pllren(true)); | ||
| 330 | |||
| 331 | (freq, Sw::PLLRCLK) | ||
| 332 | } | ||
| 138 | }; | 333 | }; |
| 139 | 334 | ||
| 140 | RCC.cfgr().modify(|w| { | 335 | RCC.cfgr().modify(|w| { |
diff --git a/embassy-stm32/src/rng.rs b/embassy-stm32/src/rng.rs index 1e16b8478..c657bf70e 100644 --- a/embassy-stm32/src/rng.rs +++ b/embassy-stm32/src/rng.rs | |||
| @@ -149,6 +149,7 @@ foreach_peripheral!( | |||
| 149 | }; | 149 | }; |
| 150 | ); | 150 | ); |
| 151 | 151 | ||
| 152 | #[cfg(feature = "rt")] | ||
| 152 | macro_rules! irq { | 153 | macro_rules! irq { |
| 153 | ($irq:ident) => { | 154 | ($irq:ident) => { |
| 154 | mod rng_irq { | 155 | mod rng_irq { |
| @@ -166,6 +167,7 @@ macro_rules! irq { | |||
| 166 | }; | 167 | }; |
| 167 | } | 168 | } |
| 168 | 169 | ||
| 170 | #[cfg(feature = "rt")] | ||
| 169 | foreach_interrupt!( | 171 | foreach_interrupt!( |
| 170 | (RNG) => { | 172 | (RNG) => { |
| 171 | irq!(RNG); | 173 | irq!(RNG); |
diff --git a/embassy-stm32/src/sdmmc/mod.rs b/embassy-stm32/src/sdmmc/mod.rs index 3cc17aa68..28eb49ab6 100644 --- a/embassy-stm32/src/sdmmc/mod.rs +++ b/embassy-stm32/src/sdmmc/mod.rs | |||
| @@ -14,7 +14,7 @@ use sdio_host::{BusWidth, CardCapacity, CardStatus, CurrentState, SDStatus, CID, | |||
| 14 | use crate::dma::NoDma; | 14 | use crate::dma::NoDma; |
| 15 | use crate::gpio::sealed::{AFType, Pin}; | 15 | use crate::gpio::sealed::{AFType, Pin}; |
| 16 | use crate::gpio::{AnyPin, Pull, Speed}; | 16 | use crate::gpio::{AnyPin, Pull, Speed}; |
| 17 | use crate::interrupt::Interrupt; | 17 | use crate::interrupt::typelevel::Interrupt; |
| 18 | use crate::pac::sdmmc::Sdmmc as RegBlock; | 18 | use crate::pac::sdmmc::Sdmmc as RegBlock; |
| 19 | use crate::rcc::RccPeripheral; | 19 | use crate::rcc::RccPeripheral; |
| 20 | use crate::time::Hertz; | 20 | use crate::time::Hertz; |
| @@ -42,7 +42,7 @@ impl<T: Instance> InterruptHandler<T> { | |||
| 42 | } | 42 | } |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 45 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 46 | unsafe fn on_interrupt() { | 46 | unsafe fn on_interrupt() { |
| 47 | Self::data_interrupts(false); | 47 | Self::data_interrupts(false); |
| 48 | T::state().wake(); | 48 | T::state().wake(); |
| @@ -276,7 +276,7 @@ pub struct Sdmmc<'d, T: Instance, Dma: SdmmcDma<T> = NoDma> { | |||
| 276 | impl<'d, T: Instance, Dma: SdmmcDma<T>> Sdmmc<'d, T, Dma> { | 276 | impl<'d, T: Instance, Dma: SdmmcDma<T>> Sdmmc<'d, T, Dma> { |
| 277 | pub fn new_1bit( | 277 | pub fn new_1bit( |
| 278 | sdmmc: impl Peripheral<P = T> + 'd, | 278 | sdmmc: impl Peripheral<P = T> + 'd, |
| 279 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 279 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 280 | dma: impl Peripheral<P = Dma> + 'd, | 280 | dma: impl Peripheral<P = Dma> + 'd, |
| 281 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, | 281 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, |
| 282 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, | 282 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, |
| @@ -310,7 +310,7 @@ impl<'d, T: Instance, Dma: SdmmcDma<T>> Sdmmc<'d, T, Dma> { | |||
| 310 | 310 | ||
| 311 | pub fn new_4bit( | 311 | pub fn new_4bit( |
| 312 | sdmmc: impl Peripheral<P = T> + 'd, | 312 | sdmmc: impl Peripheral<P = T> + 'd, |
| 313 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 313 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 314 | dma: impl Peripheral<P = Dma> + 'd, | 314 | dma: impl Peripheral<P = Dma> + 'd, |
| 315 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, | 315 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, |
| 316 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, | 316 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, |
| @@ -356,7 +356,7 @@ impl<'d, T: Instance, Dma: SdmmcDma<T>> Sdmmc<'d, T, Dma> { | |||
| 356 | impl<'d, T: Instance> Sdmmc<'d, T, NoDma> { | 356 | impl<'d, T: Instance> Sdmmc<'d, T, NoDma> { |
| 357 | pub fn new_1bit( | 357 | pub fn new_1bit( |
| 358 | sdmmc: impl Peripheral<P = T> + 'd, | 358 | sdmmc: impl Peripheral<P = T> + 'd, |
| 359 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 359 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 360 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, | 360 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, |
| 361 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, | 361 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, |
| 362 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, | 362 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, |
| @@ -389,7 +389,7 @@ impl<'d, T: Instance> Sdmmc<'d, T, NoDma> { | |||
| 389 | 389 | ||
| 390 | pub fn new_4bit( | 390 | pub fn new_4bit( |
| 391 | sdmmc: impl Peripheral<P = T> + 'd, | 391 | sdmmc: impl Peripheral<P = T> + 'd, |
| 392 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 392 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 393 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, | 393 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, |
| 394 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, | 394 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, |
| 395 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, | 395 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, |
| @@ -1401,7 +1401,7 @@ pub(crate) mod sealed { | |||
| 1401 | use super::*; | 1401 | use super::*; |
| 1402 | 1402 | ||
| 1403 | pub trait Instance { | 1403 | pub trait Instance { |
| 1404 | type Interrupt: Interrupt; | 1404 | type Interrupt: interrupt::typelevel::Interrupt; |
| 1405 | 1405 | ||
| 1406 | fn regs() -> RegBlock; | 1406 | fn regs() -> RegBlock; |
| 1407 | fn state() -> &'static AtomicWaker; | 1407 | fn state() -> &'static AtomicWaker; |
| @@ -1490,7 +1490,7 @@ cfg_if::cfg_if! { | |||
| 1490 | foreach_peripheral!( | 1490 | foreach_peripheral!( |
| 1491 | (sdmmc, $inst:ident) => { | 1491 | (sdmmc, $inst:ident) => { |
| 1492 | impl sealed::Instance for peripherals::$inst { | 1492 | impl sealed::Instance for peripherals::$inst { |
| 1493 | type Interrupt = crate::interrupt::$inst; | 1493 | type Interrupt = crate::interrupt::typelevel::$inst; |
| 1494 | 1494 | ||
| 1495 | fn regs() -> RegBlock { | 1495 | fn regs() -> RegBlock { |
| 1496 | crate::pac::$inst | 1496 | crate::pac::$inst |
diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs index bab700993..e82501a45 100644 --- a/embassy-stm32/src/time_driver.rs +++ b/embassy-stm32/src/time_driver.rs | |||
| @@ -11,7 +11,7 @@ use embassy_time::driver::{AlarmHandle, Driver}; | |||
| 11 | use embassy_time::TICK_HZ; | 11 | use embassy_time::TICK_HZ; |
| 12 | use stm32_metapac::timer::regs; | 12 | use stm32_metapac::timer::regs; |
| 13 | 13 | ||
| 14 | use crate::interrupt::Interrupt; | 14 | use crate::interrupt::typelevel::Interrupt; |
| 15 | use crate::pac::timer::vals; | 15 | use crate::pac::timer::vals; |
| 16 | use crate::rcc::sealed::RccPeripheral; | 16 | use crate::rcc::sealed::RccPeripheral; |
| 17 | use crate::timer::sealed::{Basic16bitInstance as BasicInstance, GeneralPurpose16bitInstance as Instance}; | 17 | use crate::timer::sealed::{Basic16bitInstance as BasicInstance, GeneralPurpose16bitInstance as Instance}; |
| @@ -40,6 +40,7 @@ type T = peripherals::TIM15; | |||
| 40 | foreach_interrupt! { | 40 | foreach_interrupt! { |
| 41 | (TIM2, timer, $block:ident, UP, $irq:ident) => { | 41 | (TIM2, timer, $block:ident, UP, $irq:ident) => { |
| 42 | #[cfg(time_driver_tim2)] | 42 | #[cfg(time_driver_tim2)] |
| 43 | #[cfg(feature = "rt")] | ||
| 43 | #[interrupt] | 44 | #[interrupt] |
| 44 | fn $irq() { | 45 | fn $irq() { |
| 45 | DRIVER.on_interrupt() | 46 | DRIVER.on_interrupt() |
| @@ -47,6 +48,7 @@ foreach_interrupt! { | |||
| 47 | }; | 48 | }; |
| 48 | (TIM3, timer, $block:ident, UP, $irq:ident) => { | 49 | (TIM3, timer, $block:ident, UP, $irq:ident) => { |
| 49 | #[cfg(time_driver_tim3)] | 50 | #[cfg(time_driver_tim3)] |
| 51 | #[cfg(feature = "rt")] | ||
| 50 | #[interrupt] | 52 | #[interrupt] |
| 51 | fn $irq() { | 53 | fn $irq() { |
| 52 | DRIVER.on_interrupt() | 54 | DRIVER.on_interrupt() |
| @@ -54,6 +56,7 @@ foreach_interrupt! { | |||
| 54 | }; | 56 | }; |
| 55 | (TIM4, timer, $block:ident, UP, $irq:ident) => { | 57 | (TIM4, timer, $block:ident, UP, $irq:ident) => { |
| 56 | #[cfg(time_driver_tim4)] | 58 | #[cfg(time_driver_tim4)] |
| 59 | #[cfg(feature = "rt")] | ||
| 57 | #[interrupt] | 60 | #[interrupt] |
| 58 | fn $irq() { | 61 | fn $irq() { |
| 59 | DRIVER.on_interrupt() | 62 | DRIVER.on_interrupt() |
| @@ -61,6 +64,7 @@ foreach_interrupt! { | |||
| 61 | }; | 64 | }; |
| 62 | (TIM5, timer, $block:ident, UP, $irq:ident) => { | 65 | (TIM5, timer, $block:ident, UP, $irq:ident) => { |
| 63 | #[cfg(time_driver_tim5)] | 66 | #[cfg(time_driver_tim5)] |
| 67 | #[cfg(feature = "rt")] | ||
| 64 | #[interrupt] | 68 | #[interrupt] |
| 65 | fn $irq() { | 69 | fn $irq() { |
| 66 | DRIVER.on_interrupt() | 70 | DRIVER.on_interrupt() |
| @@ -68,6 +72,7 @@ foreach_interrupt! { | |||
| 68 | }; | 72 | }; |
| 69 | (TIM12, timer, $block:ident, UP, $irq:ident) => { | 73 | (TIM12, timer, $block:ident, UP, $irq:ident) => { |
| 70 | #[cfg(time_driver_tim12)] | 74 | #[cfg(time_driver_tim12)] |
| 75 | #[cfg(feature = "rt")] | ||
| 71 | #[interrupt] | 76 | #[interrupt] |
| 72 | fn $irq() { | 77 | fn $irq() { |
| 73 | DRIVER.on_interrupt() | 78 | DRIVER.on_interrupt() |
| @@ -75,6 +80,7 @@ foreach_interrupt! { | |||
| 75 | }; | 80 | }; |
| 76 | (TIM15, timer, $block:ident, UP, $irq:ident) => { | 81 | (TIM15, timer, $block:ident, UP, $irq:ident) => { |
| 77 | #[cfg(time_driver_tim15)] | 82 | #[cfg(time_driver_tim15)] |
| 83 | #[cfg(feature = "rt")] | ||
| 78 | #[interrupt] | 84 | #[interrupt] |
| 79 | fn $irq() { | 85 | fn $irq() { |
| 80 | DRIVER.on_interrupt() | 86 | DRIVER.on_interrupt() |
diff --git a/embassy-stm32/src/timer/mod.rs b/embassy-stm32/src/timer/mod.rs index 772c67686..14db97024 100644 --- a/embassy-stm32/src/timer/mod.rs +++ b/embassy-stm32/src/timer/mod.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use stm32_metapac::timer::vals; | 1 | use stm32_metapac::timer::vals; |
| 2 | 2 | ||
| 3 | use crate::interrupt::Interrupt; | 3 | use crate::interrupt; |
| 4 | use crate::rcc::sealed::RccPeripheral as __RccPeri; | 4 | use crate::rcc::sealed::RccPeripheral as __RccPeri; |
| 5 | use crate::rcc::RccPeripheral; | 5 | use crate::rcc::RccPeripheral; |
| 6 | use crate::time::Hertz; | 6 | use crate::time::Hertz; |
| @@ -13,7 +13,7 @@ pub mod low_level { | |||
| 13 | pub(crate) mod sealed { | 13 | pub(crate) mod sealed { |
| 14 | use super::*; | 14 | use super::*; |
| 15 | pub trait Basic16bitInstance: RccPeripheral { | 15 | pub trait Basic16bitInstance: RccPeripheral { |
| 16 | type Interrupt: Interrupt; | 16 | type Interrupt: interrupt::typelevel::Interrupt; |
| 17 | 17 | ||
| 18 | fn regs() -> crate::pac::timer::TimBasic; | 18 | fn regs() -> crate::pac::timer::TimBasic; |
| 19 | 19 | ||
| @@ -57,7 +57,7 @@ pub trait Basic16bitInstance: sealed::Basic16bitInstance + 'static {} | |||
| 57 | macro_rules! impl_basic_16bit_timer { | 57 | macro_rules! impl_basic_16bit_timer { |
| 58 | ($inst:ident, $irq:ident) => { | 58 | ($inst:ident, $irq:ident) => { |
| 59 | impl sealed::Basic16bitInstance for crate::peripherals::$inst { | 59 | impl sealed::Basic16bitInstance for crate::peripherals::$inst { |
| 60 | type Interrupt = crate::interrupt::$irq; | 60 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 61 | 61 | ||
| 62 | fn regs() -> crate::pac::timer::TimBasic { | 62 | fn regs() -> crate::pac::timer::TimBasic { |
| 63 | crate::pac::timer::TimBasic(crate::pac::$inst.0) | 63 | crate::pac::timer::TimBasic(crate::pac::$inst.0) |
diff --git a/embassy-stm32/src/usart/buffered.rs b/embassy-stm32/src/usart/buffered.rs index 252e945da..613da5674 100644 --- a/embassy-stm32/src/usart/buffered.rs +++ b/embassy-stm32/src/usart/buffered.rs | |||
| @@ -2,18 +2,18 @@ use core::future::poll_fn; | |||
| 2 | use core::slice; | 2 | use core::slice; |
| 3 | use core::task::Poll; | 3 | use core::task::Poll; |
| 4 | 4 | ||
| 5 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 6 | use embassy_hal_common::atomic_ring_buffer::RingBuffer; | 5 | use embassy_hal_common::atomic_ring_buffer::RingBuffer; |
| 7 | use embassy_sync::waitqueue::AtomicWaker; | 6 | use embassy_sync::waitqueue::AtomicWaker; |
| 8 | 7 | ||
| 9 | use super::*; | 8 | use super::*; |
| 9 | use crate::interrupt::typelevel::Interrupt; | ||
| 10 | 10 | ||
| 11 | /// Interrupt handler. | 11 | /// Interrupt handler. |
| 12 | pub struct InterruptHandler<T: BasicInstance> { | 12 | pub struct InterruptHandler<T: BasicInstance> { |
| 13 | _phantom: PhantomData<T>, | 13 | _phantom: PhantomData<T>, |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | impl<T: BasicInstance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 16 | impl<T: BasicInstance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 17 | unsafe fn on_interrupt() { | 17 | unsafe fn on_interrupt() { |
| 18 | let r = T::regs(); | 18 | let r = T::regs(); |
| 19 | let state = T::buffered_state(); | 19 | let state = T::buffered_state(); |
| @@ -115,7 +115,7 @@ pub struct BufferedUartRx<'d, T: BasicInstance> { | |||
| 115 | impl<'d, T: BasicInstance> BufferedUart<'d, T> { | 115 | impl<'d, T: BasicInstance> BufferedUart<'d, T> { |
| 116 | pub fn new( | 116 | pub fn new( |
| 117 | peri: impl Peripheral<P = T> + 'd, | 117 | peri: impl Peripheral<P = T> + 'd, |
| 118 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 118 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 119 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, | 119 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, |
| 120 | tx: impl Peripheral<P = impl TxPin<T>> + 'd, | 120 | tx: impl Peripheral<P = impl TxPin<T>> + 'd, |
| 121 | tx_buffer: &'d mut [u8], | 121 | tx_buffer: &'d mut [u8], |
| @@ -130,7 +130,7 @@ impl<'d, T: BasicInstance> BufferedUart<'d, T> { | |||
| 130 | 130 | ||
| 131 | pub fn new_with_rtscts( | 131 | pub fn new_with_rtscts( |
| 132 | peri: impl Peripheral<P = T> + 'd, | 132 | peri: impl Peripheral<P = T> + 'd, |
| 133 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 133 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 134 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, | 134 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, |
| 135 | tx: impl Peripheral<P = impl TxPin<T>> + 'd, | 135 | tx: impl Peripheral<P = impl TxPin<T>> + 'd, |
| 136 | rts: impl Peripheral<P = impl RtsPin<T>> + 'd, | 136 | rts: impl Peripheral<P = impl RtsPin<T>> + 'd, |
| @@ -159,7 +159,7 @@ impl<'d, T: BasicInstance> BufferedUart<'d, T> { | |||
| 159 | #[cfg(not(any(usart_v1, usart_v2)))] | 159 | #[cfg(not(any(usart_v1, usart_v2)))] |
| 160 | pub fn new_with_de( | 160 | pub fn new_with_de( |
| 161 | peri: impl Peripheral<P = T> + 'd, | 161 | peri: impl Peripheral<P = T> + 'd, |
| 162 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 162 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 163 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, | 163 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, |
| 164 | tx: impl Peripheral<P = impl TxPin<T>> + 'd, | 164 | tx: impl Peripheral<P = impl TxPin<T>> + 'd, |
| 165 | de: impl Peripheral<P = impl DePin<T>> + 'd, | 165 | de: impl Peripheral<P = impl DePin<T>> + 'd, |
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index ef1080153..da3644a81 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs | |||
| @@ -5,13 +5,13 @@ use core::marker::PhantomData; | |||
| 5 | use core::sync::atomic::{compiler_fence, Ordering}; | 5 | use core::sync::atomic::{compiler_fence, Ordering}; |
| 6 | use core::task::Poll; | 6 | use core::task::Poll; |
| 7 | 7 | ||
| 8 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 9 | use embassy_hal_common::drop::OnDrop; | 8 | use embassy_hal_common::drop::OnDrop; |
| 10 | use embassy_hal_common::{into_ref, PeripheralRef}; | 9 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 11 | use futures::future::{select, Either}; | 10 | use futures::future::{select, Either}; |
| 12 | 11 | ||
| 13 | use crate::dma::{NoDma, Transfer}; | 12 | use crate::dma::{NoDma, Transfer}; |
| 14 | use crate::gpio::sealed::AFType; | 13 | use crate::gpio::sealed::AFType; |
| 14 | use crate::interrupt::typelevel::Interrupt; | ||
| 15 | #[cfg(not(any(usart_v1, usart_v2)))] | 15 | #[cfg(not(any(usart_v1, usart_v2)))] |
| 16 | #[allow(unused_imports)] | 16 | #[allow(unused_imports)] |
| 17 | use crate::pac::usart::regs::Isr as Sr; | 17 | use crate::pac::usart::regs::Isr as Sr; |
| @@ -31,7 +31,7 @@ pub struct InterruptHandler<T: BasicInstance> { | |||
| 31 | _phantom: PhantomData<T>, | 31 | _phantom: PhantomData<T>, |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | impl<T: BasicInstance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 34 | impl<T: BasicInstance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 35 | unsafe fn on_interrupt() { | 35 | unsafe fn on_interrupt() { |
| 36 | let r = T::regs(); | 36 | let r = T::regs(); |
| 37 | let s = T::state(); | 37 | let s = T::state(); |
| @@ -281,7 +281,7 @@ impl<'d, T: BasicInstance, RxDma> UartRx<'d, T, RxDma> { | |||
| 281 | /// Useful if you only want Uart Rx. It saves 1 pin and consumes a little less power. | 281 | /// Useful if you only want Uart Rx. It saves 1 pin and consumes a little less power. |
| 282 | pub fn new( | 282 | pub fn new( |
| 283 | peri: impl Peripheral<P = T> + 'd, | 283 | peri: impl Peripheral<P = T> + 'd, |
| 284 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 284 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 285 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, | 285 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, |
| 286 | rx_dma: impl Peripheral<P = RxDma> + 'd, | 286 | rx_dma: impl Peripheral<P = RxDma> + 'd, |
| 287 | config: Config, | 287 | config: Config, |
| @@ -294,7 +294,7 @@ impl<'d, T: BasicInstance, RxDma> UartRx<'d, T, RxDma> { | |||
| 294 | 294 | ||
| 295 | pub fn new_with_rts( | 295 | pub fn new_with_rts( |
| 296 | peri: impl Peripheral<P = T> + 'd, | 296 | peri: impl Peripheral<P = T> + 'd, |
| 297 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 297 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 298 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, | 298 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, |
| 299 | rts: impl Peripheral<P = impl RtsPin<T>> + 'd, | 299 | rts: impl Peripheral<P = impl RtsPin<T>> + 'd, |
| 300 | rx_dma: impl Peripheral<P = RxDma> + 'd, | 300 | rx_dma: impl Peripheral<P = RxDma> + 'd, |
| @@ -650,7 +650,7 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> { | |||
| 650 | peri: impl Peripheral<P = T> + 'd, | 650 | peri: impl Peripheral<P = T> + 'd, |
| 651 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, | 651 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, |
| 652 | tx: impl Peripheral<P = impl TxPin<T>> + 'd, | 652 | tx: impl Peripheral<P = impl TxPin<T>> + 'd, |
| 653 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 653 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 654 | tx_dma: impl Peripheral<P = TxDma> + 'd, | 654 | tx_dma: impl Peripheral<P = TxDma> + 'd, |
| 655 | rx_dma: impl Peripheral<P = RxDma> + 'd, | 655 | rx_dma: impl Peripheral<P = RxDma> + 'd, |
| 656 | config: Config, | 656 | config: Config, |
| @@ -665,7 +665,7 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> { | |||
| 665 | peri: impl Peripheral<P = T> + 'd, | 665 | peri: impl Peripheral<P = T> + 'd, |
| 666 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, | 666 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, |
| 667 | tx: impl Peripheral<P = impl TxPin<T>> + 'd, | 667 | tx: impl Peripheral<P = impl TxPin<T>> + 'd, |
| 668 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 668 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 669 | rts: impl Peripheral<P = impl RtsPin<T>> + 'd, | 669 | rts: impl Peripheral<P = impl RtsPin<T>> + 'd, |
| 670 | cts: impl Peripheral<P = impl CtsPin<T>> + 'd, | 670 | cts: impl Peripheral<P = impl CtsPin<T>> + 'd, |
| 671 | tx_dma: impl Peripheral<P = TxDma> + 'd, | 671 | tx_dma: impl Peripheral<P = TxDma> + 'd, |
| @@ -693,7 +693,7 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> { | |||
| 693 | peri: impl Peripheral<P = T> + 'd, | 693 | peri: impl Peripheral<P = T> + 'd, |
| 694 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, | 694 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, |
| 695 | tx: impl Peripheral<P = impl TxPin<T>> + 'd, | 695 | tx: impl Peripheral<P = impl TxPin<T>> + 'd, |
| 696 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 696 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 697 | de: impl Peripheral<P = impl DePin<T>> + 'd, | 697 | de: impl Peripheral<P = impl DePin<T>> + 'd, |
| 698 | tx_dma: impl Peripheral<P = TxDma> + 'd, | 698 | tx_dma: impl Peripheral<P = TxDma> + 'd, |
| 699 | rx_dma: impl Peripheral<P = RxDma> + 'd, | 699 | rx_dma: impl Peripheral<P = RxDma> + 'd, |
| @@ -1179,7 +1179,7 @@ pub(crate) mod sealed { | |||
| 1179 | 1179 | ||
| 1180 | pub trait BasicInstance: crate::rcc::RccPeripheral { | 1180 | pub trait BasicInstance: crate::rcc::RccPeripheral { |
| 1181 | const KIND: Kind; | 1181 | const KIND: Kind; |
| 1182 | type Interrupt: crate::interrupt::Interrupt; | 1182 | type Interrupt: interrupt::typelevel::Interrupt; |
| 1183 | 1183 | ||
| 1184 | fn regs() -> Regs; | 1184 | fn regs() -> Regs; |
| 1185 | fn state() -> &'static State; | 1185 | fn state() -> &'static State; |
| @@ -1211,7 +1211,7 @@ macro_rules! impl_usart { | |||
| 1211 | ($inst:ident, $irq:ident, $kind:expr) => { | 1211 | ($inst:ident, $irq:ident, $kind:expr) => { |
| 1212 | impl sealed::BasicInstance for crate::peripherals::$inst { | 1212 | impl sealed::BasicInstance for crate::peripherals::$inst { |
| 1213 | const KIND: Kind = $kind; | 1213 | const KIND: Kind = $kind; |
| 1214 | type Interrupt = crate::interrupt::$irq; | 1214 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 1215 | 1215 | ||
| 1216 | fn regs() -> Regs { | 1216 | fn regs() -> Regs { |
| 1217 | Regs(crate::pac::$inst.0) | 1217 | Regs(crate::pac::$inst.0) |
diff --git a/embassy-stm32/src/usb/mod.rs b/embassy-stm32/src/usb/mod.rs index fbd1fa823..bee287fe6 100644 --- a/embassy-stm32/src/usb/mod.rs +++ b/embassy-stm32/src/usb/mod.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use crate::interrupt::Interrupt; | 1 | use crate::interrupt; |
| 2 | use crate::rcc::RccPeripheral; | 2 | use crate::rcc::RccPeripheral; |
| 3 | 3 | ||
| 4 | #[cfg(feature = "nightly")] | 4 | #[cfg(feature = "nightly")] |
| @@ -13,7 +13,7 @@ pub(crate) mod sealed { | |||
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | pub trait Instance: sealed::Instance + RccPeripheral + 'static { | 15 | pub trait Instance: sealed::Instance + RccPeripheral + 'static { |
| 16 | type Interrupt: Interrupt; | 16 | type Interrupt: interrupt::typelevel::Interrupt; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | // Internal PHY pins | 19 | // Internal PHY pins |
| @@ -29,7 +29,7 @@ foreach_interrupt!( | |||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | impl Instance for crate::peripherals::$inst { | 31 | impl Instance for crate::peripherals::$inst { |
| 32 | type Interrupt = crate::interrupt::$irq; | 32 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 33 | } | 33 | } |
| 34 | }; | 34 | }; |
| 35 | ); | 35 | ); |
diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index 134107978..7486bd376 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs | |||
| @@ -14,7 +14,7 @@ use embassy_usb_driver::{ | |||
| 14 | 14 | ||
| 15 | use super::{DmPin, DpPin, Instance}; | 15 | use super::{DmPin, DpPin, Instance}; |
| 16 | use crate::gpio::sealed::AFType; | 16 | use crate::gpio::sealed::AFType; |
| 17 | use crate::interrupt::Interrupt; | 17 | use crate::interrupt::typelevel::Interrupt; |
| 18 | use crate::pac::usb::regs; | 18 | use crate::pac::usb::regs; |
| 19 | use crate::pac::usb::vals::{EpType, Stat}; | 19 | use crate::pac::usb::vals::{EpType, Stat}; |
| 20 | use crate::pac::USBRAM; | 20 | use crate::pac::USBRAM; |
| @@ -26,7 +26,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 26 | _phantom: PhantomData<T>, | 26 | _phantom: PhantomData<T>, |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 29 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 30 | unsafe fn on_interrupt() { | 30 | unsafe fn on_interrupt() { |
| 31 | unsafe { | 31 | unsafe { |
| 32 | let regs = T::regs(); | 32 | let regs = T::regs(); |
| @@ -255,7 +255,7 @@ pub struct Driver<'d, T: Instance> { | |||
| 255 | impl<'d, T: Instance> Driver<'d, T> { | 255 | impl<'d, T: Instance> Driver<'d, T> { |
| 256 | pub fn new( | 256 | pub fn new( |
| 257 | _usb: impl Peripheral<P = T> + 'd, | 257 | _usb: impl Peripheral<P = T> + 'd, |
| 258 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 258 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 259 | dp: impl Peripheral<P = impl DpPin<T>> + 'd, | 259 | dp: impl Peripheral<P = impl DpPin<T>> + 'd, |
| 260 | dm: impl Peripheral<P = impl DmPin<T>> + 'd, | 260 | dm: impl Peripheral<P = impl DmPin<T>> + 'd, |
| 261 | ) -> Self { | 261 | ) -> Self { |
diff --git a/embassy-stm32/src/usb_otg/mod.rs b/embassy-stm32/src/usb_otg/mod.rs index 193e0df0d..317264cbb 100644 --- a/embassy-stm32/src/usb_otg/mod.rs +++ b/embassy-stm32/src/usb_otg/mod.rs | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 2 | |||
| 3 | use crate::peripherals; | ||
| 4 | use crate::rcc::RccPeripheral; | 1 | use crate::rcc::RccPeripheral; |
| 2 | use crate::{interrupt, peripherals}; | ||
| 5 | 3 | ||
| 6 | #[cfg(feature = "nightly")] | 4 | #[cfg(feature = "nightly")] |
| 7 | mod usb; | 5 | mod usb; |
| @@ -25,7 +23,7 @@ pub(crate) mod sealed { | |||
| 25 | } | 23 | } |
| 26 | 24 | ||
| 27 | pub trait Instance: sealed::Instance + RccPeripheral { | 25 | pub trait Instance: sealed::Instance + RccPeripheral { |
| 28 | type Interrupt: Interrupt; | 26 | type Interrupt: interrupt::typelevel::Interrupt; |
| 29 | } | 27 | } |
| 30 | 28 | ||
| 31 | // Internal PHY pins | 29 | // Internal PHY pins |
| @@ -109,7 +107,7 @@ foreach_interrupt!( | |||
| 109 | } | 107 | } |
| 110 | 108 | ||
| 111 | impl Instance for peripherals::USB_OTG_FS { | 109 | impl Instance for peripherals::USB_OTG_FS { |
| 112 | type Interrupt = crate::interrupt::$irq; | 110 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 113 | } | 111 | } |
| 114 | }; | 112 | }; |
| 115 | 113 | ||
| @@ -161,7 +159,7 @@ foreach_interrupt!( | |||
| 161 | } | 159 | } |
| 162 | 160 | ||
| 163 | impl Instance for peripherals::USB_OTG_HS { | 161 | impl Instance for peripherals::USB_OTG_HS { |
| 164 | type Interrupt = crate::interrupt::$irq; | 162 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 165 | } | 163 | } |
| 166 | }; | 164 | }; |
| 167 | ); | 165 | ); |
diff --git a/embassy-stm32/src/usb_otg/usb.rs b/embassy-stm32/src/usb_otg/usb.rs index e602bcb70..16cbf1a95 100644 --- a/embassy-stm32/src/usb_otg/usb.rs +++ b/embassy-stm32/src/usb_otg/usb.rs | |||
| @@ -3,7 +3,6 @@ use core::marker::PhantomData; | |||
| 3 | use core::task::Poll; | 3 | use core::task::Poll; |
| 4 | 4 | ||
| 5 | use atomic_polyfill::{AtomicBool, AtomicU16, Ordering}; | 5 | use atomic_polyfill::{AtomicBool, AtomicU16, Ordering}; |
| 6 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 7 | use embassy_hal_common::{into_ref, Peripheral}; | 6 | use embassy_hal_common::{into_ref, Peripheral}; |
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 7 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | use embassy_usb_driver::{ | 8 | use embassy_usb_driver::{ |
| @@ -15,6 +14,7 @@ use futures::future::poll_fn; | |||
| 15 | use super::*; | 14 | use super::*; |
| 16 | use crate::gpio::sealed::AFType; | 15 | use crate::gpio::sealed::AFType; |
| 17 | use crate::interrupt; | 16 | use crate::interrupt; |
| 17 | use crate::interrupt::typelevel::Interrupt; | ||
| 18 | use crate::pac::otg::{regs, vals}; | 18 | use crate::pac::otg::{regs, vals}; |
| 19 | use crate::rcc::sealed::RccPeripheral; | 19 | use crate::rcc::sealed::RccPeripheral; |
| 20 | use crate::time::Hertz; | 20 | use crate::time::Hertz; |
| @@ -24,7 +24,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 24 | _phantom: PhantomData<T>, | 24 | _phantom: PhantomData<T>, |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 27 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 28 | unsafe fn on_interrupt() { | 28 | unsafe fn on_interrupt() { |
| 29 | trace!("irq"); | 29 | trace!("irq"); |
| 30 | let r = T::regs(); | 30 | let r = T::regs(); |
| @@ -291,7 +291,7 @@ impl<'d, T: Instance> Driver<'d, T> { | |||
| 291 | /// Endpoint allocation will fail if it is too small. | 291 | /// Endpoint allocation will fail if it is too small. |
| 292 | pub fn new_fs( | 292 | pub fn new_fs( |
| 293 | _peri: impl Peripheral<P = T> + 'd, | 293 | _peri: impl Peripheral<P = T> + 'd, |
| 294 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 294 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 295 | dp: impl Peripheral<P = impl DpPin<T>> + 'd, | 295 | dp: impl Peripheral<P = impl DpPin<T>> + 'd, |
| 296 | dm: impl Peripheral<P = impl DmPin<T>> + 'd, | 296 | dm: impl Peripheral<P = impl DmPin<T>> + 'd, |
| 297 | ep_out_buffer: &'d mut [u8], | 297 | ep_out_buffer: &'d mut [u8], |
| @@ -322,7 +322,7 @@ impl<'d, T: Instance> Driver<'d, T> { | |||
| 322 | /// Endpoint allocation will fail if it is too small. | 322 | /// Endpoint allocation will fail if it is too small. |
| 323 | pub fn new_hs_ulpi( | 323 | pub fn new_hs_ulpi( |
| 324 | _peri: impl Peripheral<P = T> + 'd, | 324 | _peri: impl Peripheral<P = T> + 'd, |
| 325 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 325 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 326 | ulpi_clk: impl Peripheral<P = impl UlpiClkPin<T>> + 'd, | 326 | ulpi_clk: impl Peripheral<P = impl UlpiClkPin<T>> + 'd, |
| 327 | ulpi_dir: impl Peripheral<P = impl UlpiDirPin<T>> + 'd, | 327 | ulpi_dir: impl Peripheral<P = impl UlpiDirPin<T>> + 'd, |
| 328 | ulpi_nxt: impl Peripheral<P = impl UlpiNxtPin<T>> + 'd, | 328 | ulpi_nxt: impl Peripheral<P = impl UlpiNxtPin<T>> + 'd, |
diff --git a/embassy-sync/src/fmt.rs b/embassy-sync/src/fmt.rs index f8bb0a035..066970813 100644 --- a/embassy-sync/src/fmt.rs +++ b/embassy-sync/src/fmt.rs | |||
| @@ -195,9 +195,6 @@ macro_rules! unwrap { | |||
| 195 | } | 195 | } |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | #[cfg(feature = "defmt-timestamp-uptime")] | ||
| 199 | defmt::timestamp! {"{=u64:us}", crate::time::Instant::now().as_micros() } | ||
| 200 | |||
| 201 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | 198 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] |
| 202 | pub struct NoneError; | 199 | pub struct NoneError; |
| 203 | 200 | ||
diff --git a/examples/nrf52840-rtic/.cargo/config.toml b/examples/nrf52840-rtic/.cargo/config.toml new file mode 100644 index 000000000..3872e7189 --- /dev/null +++ b/examples/nrf52840-rtic/.cargo/config.toml | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | ||
| 2 | # replace nRF82840_xxAA with your chip as listed in `probe-rs-cli chip list` | ||
| 3 | runner = "probe-rs-cli run --chip nRF52840_xxAA" | ||
| 4 | |||
| 5 | [build] | ||
| 6 | target = "thumbv7em-none-eabi" | ||
| 7 | |||
| 8 | [env] | ||
| 9 | DEFMT_LOG = "trace" | ||
diff --git a/examples/nrf52840-rtic/Cargo.toml b/examples/nrf52840-rtic/Cargo.toml new file mode 100644 index 000000000..0f9048b0f --- /dev/null +++ b/examples/nrf52840-rtic/Cargo.toml | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | [package] | ||
| 2 | edition = "2021" | ||
| 3 | name = "embassy-nrf52840-rtic-examples" | ||
| 4 | version = "0.1.0" | ||
| 5 | license = "MIT OR Apache-2.0" | ||
| 6 | |||
| 7 | [dependencies] | ||
| 8 | rtic = { version = "2", features = ["thumbv7-backend"] } | ||
| 9 | |||
| 10 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | ||
| 11 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | ||
| 12 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "generic-queue"] } | ||
| 13 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nightly", "unstable-traits", "defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } | ||
| 14 | |||
| 15 | defmt = "0.3" | ||
| 16 | defmt-rtt = "0.4" | ||
| 17 | |||
| 18 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | ||
| 19 | cortex-m-rt = "0.7.0" | ||
| 20 | panic-probe = { version = "0.3", features = ["print-defmt"] } | ||
| 21 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | ||
diff --git a/examples/nrf52840-rtic/build.rs b/examples/nrf52840-rtic/build.rs new file mode 100644 index 000000000..30691aa97 --- /dev/null +++ b/examples/nrf52840-rtic/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/nrf52840-rtic/memory.x b/examples/nrf52840-rtic/memory.x new file mode 100644 index 000000000..9b04edec0 --- /dev/null +++ b/examples/nrf52840-rtic/memory.x | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | MEMORY | ||
| 2 | { | ||
| 3 | /* NOTE 1 K = 1 KiBi = 1024 bytes */ | ||
| 4 | /* These values correspond to the NRF52840 with Softdevices S140 7.0.1 */ | ||
| 5 | FLASH : ORIGIN = 0x00000000, LENGTH = 1024K | ||
| 6 | RAM : ORIGIN = 0x20000000, LENGTH = 256K | ||
| 7 | } | ||
diff --git a/examples/nrf52840-rtic/src/bin/blinky.rs b/examples/nrf52840-rtic/src/bin/blinky.rs new file mode 100644 index 000000000..a682c1932 --- /dev/null +++ b/examples/nrf52840-rtic/src/bin/blinky.rs | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use {defmt_rtt as _, panic_probe as _}; | ||
| 6 | |||
| 7 | #[rtic::app(device = embassy_nrf, peripherals = false, dispatchers = [SWI0_EGU0, SWI1_EGU1])] | ||
| 8 | mod app { | ||
| 9 | use defmt::info; | ||
| 10 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | ||
| 11 | use embassy_nrf::peripherals; | ||
| 12 | use embassy_time::{Duration, Timer}; | ||
| 13 | |||
| 14 | #[shared] | ||
| 15 | struct Shared {} | ||
| 16 | |||
| 17 | #[local] | ||
| 18 | struct Local {} | ||
| 19 | |||
| 20 | #[init] | ||
| 21 | fn init(_: init::Context) -> (Shared, Local) { | ||
| 22 | info!("Hello World!"); | ||
| 23 | |||
| 24 | let p = embassy_nrf::init(Default::default()); | ||
| 25 | blink::spawn(p.P0_13).map_err(|_| ()).unwrap(); | ||
| 26 | |||
| 27 | (Shared {}, Local {}) | ||
| 28 | } | ||
| 29 | |||
| 30 | #[task(priority = 1)] | ||
| 31 | async fn blink(_cx: blink::Context, pin: peripherals::P0_13) { | ||
| 32 | let mut led = Output::new(pin, Level::Low, OutputDrive::Standard); | ||
| 33 | |||
| 34 | loop { | ||
| 35 | info!("off!"); | ||
| 36 | led.set_high(); | ||
| 37 | Timer::after(Duration::from_millis(300)).await; | ||
| 38 | info!("on!"); | ||
| 39 | led.set_low(); | ||
| 40 | Timer::after(Duration::from_millis(300)).await; | ||
| 41 | } | ||
| 42 | } | ||
| 43 | } | ||
diff --git a/examples/nrf52840/src/bin/multiprio.rs b/examples/nrf52840/src/bin/multiprio.rs index 851e189ea..aab819117 100644 --- a/examples/nrf52840/src/bin/multiprio.rs +++ b/examples/nrf52840/src/bin/multiprio.rs | |||
| @@ -57,14 +57,11 @@ | |||
| 57 | #![no_main] | 57 | #![no_main] |
| 58 | #![feature(type_alias_impl_trait)] | 58 | #![feature(type_alias_impl_trait)] |
| 59 | 59 | ||
| 60 | use core::mem; | ||
| 61 | |||
| 62 | use cortex_m::peripheral::NVIC; | ||
| 63 | use cortex_m_rt::entry; | 60 | use cortex_m_rt::entry; |
| 64 | use defmt::{info, unwrap}; | 61 | use defmt::{info, unwrap}; |
| 65 | use embassy_nrf::executor::{Executor, InterruptExecutor}; | 62 | use embassy_executor::{Executor, InterruptExecutor}; |
| 66 | use embassy_nrf::interrupt; | 63 | use embassy_nrf::interrupt; |
| 67 | use embassy_nrf::pac::Interrupt; | 64 | use embassy_nrf::interrupt::{InterruptExt, Priority}; |
| 68 | use embassy_time::{Duration, Instant, Timer}; | 65 | use embassy_time::{Duration, Instant, Timer}; |
| 69 | use static_cell::StaticCell; | 66 | use static_cell::StaticCell; |
| 70 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -130,16 +127,15 @@ fn main() -> ! { | |||
| 130 | info!("Hello World!"); | 127 | info!("Hello World!"); |
| 131 | 128 | ||
| 132 | let _p = embassy_nrf::init(Default::default()); | 129 | let _p = embassy_nrf::init(Default::default()); |
| 133 | let mut nvic: NVIC = unsafe { mem::transmute(()) }; | ||
| 134 | 130 | ||
| 135 | // High-priority executor: SWI1_EGU1, priority level 6 | 131 | // High-priority executor: SWI1_EGU1, priority level 6 |
| 136 | unsafe { nvic.set_priority(Interrupt::SWI1_EGU1, 6 << 5) }; | 132 | interrupt::SWI1_EGU1.set_priority(Priority::P6); |
| 137 | let spawner = EXECUTOR_HIGH.start(Interrupt::SWI1_EGU1); | 133 | let spawner = EXECUTOR_HIGH.start(interrupt::SWI1_EGU1); |
| 138 | unwrap!(spawner.spawn(run_high())); | 134 | unwrap!(spawner.spawn(run_high())); |
| 139 | 135 | ||
| 140 | // Medium-priority executor: SWI0_EGU0, priority level 7 | 136 | // Medium-priority executor: SWI0_EGU0, priority level 7 |
| 141 | unsafe { nvic.set_priority(Interrupt::SWI0_EGU0, 7 << 5) }; | 137 | interrupt::SWI0_EGU0.set_priority(Priority::P7); |
| 142 | let spawner = EXECUTOR_MED.start(Interrupt::SWI0_EGU0); | 138 | let spawner = EXECUTOR_MED.start(interrupt::SWI0_EGU0); |
| 143 | unwrap!(spawner.spawn(run_med())); | 139 | unwrap!(spawner.spawn(run_med())); |
| 144 | 140 | ||
| 145 | // Low priority executor: runs in thread mode, using WFE/SEV | 141 | // Low priority executor: runs in thread mode, using WFE/SEV |
diff --git a/examples/nrf52840/src/bin/usb_ethernet.rs b/examples/nrf52840/src/bin/usb_ethernet.rs index 1065f5b5d..f527c0d7f 100644 --- a/examples/nrf52840/src/bin/usb_ethernet.rs +++ b/examples/nrf52840/src/bin/usb_ethernet.rs | |||
| @@ -97,12 +97,12 @@ async fn main(spawner: Spawner) { | |||
| 97 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); | 97 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); |
| 98 | unwrap!(spawner.spawn(usb_ncm_task(runner))); | 98 | unwrap!(spawner.spawn(usb_ncm_task(runner))); |
| 99 | 99 | ||
| 100 | let config = embassy_net::Config::Dhcp(Default::default()); | 100 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| 101 | //let config = embassy_net::Config::Static(embassy_net::StaticConfig { | 101 | // let config = embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 { |
| 102 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), | 102 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), |
| 103 | // dns_servers: Vec::new(), | 103 | // dns_servers: Vec::new(), |
| 104 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), | 104 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), |
| 105 | //}); | 105 | // }); |
| 106 | 106 | ||
| 107 | // Generate random seed | 107 | // Generate random seed |
| 108 | let mut rng = Rng::new(p.RNG, Irqs); | 108 | let mut rng = Rng::new(p.RNG, Irqs); |
diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index e946b481d..48f3a26bb 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml | |||
| @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" | |||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal", features = ["defmt"] } | 9 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal", features = ["defmt"] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime"] } | 12 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime"] } |
| 13 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver", "critical-section-impl"] } | 13 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver", "critical-section-impl"] } |
| 14 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 14 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
diff --git a/examples/rp/src/bin/ethernet_w5500_multisocket.rs b/examples/rp/src/bin/ethernet_w5500_multisocket.rs index 63e142e7d..82568254a 100644 --- a/examples/rp/src/bin/ethernet_w5500_multisocket.rs +++ b/examples/rp/src/bin/ethernet_w5500_multisocket.rs | |||
| @@ -64,7 +64,7 @@ async fn main(spawner: Spawner) { | |||
| 64 | // Init network stack | 64 | // Init network stack |
| 65 | let stack = &*make_static!(Stack::new( | 65 | let stack = &*make_static!(Stack::new( |
| 66 | device, | 66 | device, |
| 67 | embassy_net::Config::Dhcp(Default::default()), | 67 | embassy_net::Config::dhcpv4(Default::default()), |
| 68 | make_static!(StackResources::<3>::new()), | 68 | make_static!(StackResources::<3>::new()), |
| 69 | seed | 69 | seed |
| 70 | )); | 70 | )); |
| @@ -120,9 +120,9 @@ async fn listen_task(stack: &'static Stack<Device<'static>>, id: u8, port: u16) | |||
| 120 | } | 120 | } |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfig { | 123 | async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfigV4 { |
| 124 | loop { | 124 | loop { |
| 125 | if let Some(config) = stack.config() { | 125 | if let Some(config) = stack.config_v4() { |
| 126 | return config.clone(); | 126 | return config.clone(); |
| 127 | } | 127 | } |
| 128 | yield_now().await; | 128 | yield_now().await; |
diff --git a/examples/rp/src/bin/ethernet_w5500_tcp_client.rs b/examples/rp/src/bin/ethernet_w5500_tcp_client.rs index a532de00d..d562defad 100644 --- a/examples/rp/src/bin/ethernet_w5500_tcp_client.rs +++ b/examples/rp/src/bin/ethernet_w5500_tcp_client.rs | |||
| @@ -67,7 +67,7 @@ async fn main(spawner: Spawner) { | |||
| 67 | // Init network stack | 67 | // Init network stack |
| 68 | let stack = &*make_static!(Stack::new( | 68 | let stack = &*make_static!(Stack::new( |
| 69 | device, | 69 | device, |
| 70 | embassy_net::Config::Dhcp(Default::default()), | 70 | embassy_net::Config::dhcpv4(Default::default()), |
| 71 | make_static!(StackResources::<2>::new()), | 71 | make_static!(StackResources::<2>::new()), |
| 72 | seed | 72 | seed |
| 73 | )); | 73 | )); |
| @@ -108,9 +108,9 @@ async fn main(spawner: Spawner) { | |||
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfig { | 111 | async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfigV4 { |
| 112 | loop { | 112 | loop { |
| 113 | if let Some(config) = stack.config() { | 113 | if let Some(config) = stack.config_v4() { |
| 114 | return config.clone(); | 114 | return config.clone(); |
| 115 | } | 115 | } |
| 116 | yield_now().await; | 116 | yield_now().await; |
diff --git a/examples/rp/src/bin/ethernet_w5500_tcp_server.rs b/examples/rp/src/bin/ethernet_w5500_tcp_server.rs index 599f6b1e9..7f521cdb4 100644 --- a/examples/rp/src/bin/ethernet_w5500_tcp_server.rs +++ b/examples/rp/src/bin/ethernet_w5500_tcp_server.rs | |||
| @@ -65,7 +65,7 @@ async fn main(spawner: Spawner) { | |||
| 65 | // Init network stack | 65 | // Init network stack |
| 66 | let stack = &*make_static!(Stack::new( | 66 | let stack = &*make_static!(Stack::new( |
| 67 | device, | 67 | device, |
| 68 | embassy_net::Config::Dhcp(Default::default()), | 68 | embassy_net::Config::dhcpv4(Default::default()), |
| 69 | make_static!(StackResources::<2>::new()), | 69 | make_static!(StackResources::<2>::new()), |
| 70 | seed | 70 | seed |
| 71 | )); | 71 | )); |
| @@ -116,9 +116,9 @@ async fn main(spawner: Spawner) { | |||
| 116 | } | 116 | } |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfig { | 119 | async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfigV4 { |
| 120 | loop { | 120 | loop { |
| 121 | if let Some(config) = stack.config() { | 121 | if let Some(config) = stack.config_v4() { |
| 122 | return config.clone(); | 122 | return config.clone(); |
| 123 | } | 123 | } |
| 124 | yield_now().await; | 124 | yield_now().await; |
diff --git a/examples/rp/src/bin/ethernet_w5500_udp.rs b/examples/rp/src/bin/ethernet_w5500_udp.rs index ac5a65bb6..ada86ae55 100644 --- a/examples/rp/src/bin/ethernet_w5500_udp.rs +++ b/examples/rp/src/bin/ethernet_w5500_udp.rs | |||
| @@ -62,7 +62,7 @@ async fn main(spawner: Spawner) { | |||
| 62 | // Init network stack | 62 | // Init network stack |
| 63 | let stack = &*make_static!(Stack::new( | 63 | let stack = &*make_static!(Stack::new( |
| 64 | device, | 64 | device, |
| 65 | embassy_net::Config::Dhcp(Default::default()), | 65 | embassy_net::Config::dhcpv4(Default::default()), |
| 66 | make_static!(StackResources::<2>::new()), | 66 | make_static!(StackResources::<2>::new()), |
| 67 | seed | 67 | seed |
| 68 | )); | 68 | )); |
| @@ -95,9 +95,9 @@ async fn main(spawner: Spawner) { | |||
| 95 | } | 95 | } |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfig { | 98 | async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfigV4 { |
| 99 | loop { | 99 | loop { |
| 100 | if let Some(config) = stack.config() { | 100 | if let Some(config) = stack.config_v4() { |
| 101 | return config.clone(); | 101 | return config.clone(); |
| 102 | } | 102 | } |
| 103 | yield_now().await; | 103 | yield_now().await; |
diff --git a/examples/rp/src/bin/multiprio.rs b/examples/rp/src/bin/multiprio.rs index 2f79ba49e..9ace4cd68 100644 --- a/examples/rp/src/bin/multiprio.rs +++ b/examples/rp/src/bin/multiprio.rs | |||
| @@ -57,14 +57,11 @@ | |||
| 57 | #![no_main] | 57 | #![no_main] |
| 58 | #![feature(type_alias_impl_trait)] | 58 | #![feature(type_alias_impl_trait)] |
| 59 | 59 | ||
| 60 | use core::mem; | ||
| 61 | |||
| 62 | use cortex_m::peripheral::NVIC; | ||
| 63 | use cortex_m_rt::entry; | 60 | use cortex_m_rt::entry; |
| 64 | use defmt::{info, unwrap}; | 61 | use defmt::{info, unwrap}; |
| 65 | use embassy_rp::executor::{Executor, InterruptExecutor}; | 62 | use embassy_executor::{Executor, InterruptExecutor}; |
| 66 | use embassy_rp::interrupt; | 63 | use embassy_rp::interrupt; |
| 67 | use embassy_rp::pac::Interrupt; | 64 | use embassy_rp::interrupt::{InterruptExt, Priority}; |
| 68 | use embassy_time::{Duration, Instant, Timer, TICK_HZ}; | 65 | use embassy_time::{Duration, Instant, Timer, TICK_HZ}; |
| 69 | use static_cell::StaticCell; | 66 | use static_cell::StaticCell; |
| 70 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -130,18 +127,15 @@ fn main() -> ! { | |||
| 130 | info!("Hello World!"); | 127 | info!("Hello World!"); |
| 131 | 128 | ||
| 132 | let _p = embassy_rp::init(Default::default()); | 129 | let _p = embassy_rp::init(Default::default()); |
| 133 | let mut nvic: NVIC = unsafe { mem::transmute(()) }; | ||
| 134 | 130 | ||
| 135 | // High-priority executor: SWI_IRQ_1, priority level 2 | 131 | // High-priority executor: SWI_IRQ_1, priority level 2 |
| 136 | unsafe { nvic.set_priority(Interrupt::SWI_IRQ_1, 2 << 6) }; | 132 | interrupt::SWI_IRQ_1.set_priority(Priority::P2); |
| 137 | info!("bla: {}", NVIC::get_priority(Interrupt::SWI_IRQ_1)); | 133 | let spawner = EXECUTOR_HIGH.start(interrupt::SWI_IRQ_1); |
| 138 | let spawner = EXECUTOR_HIGH.start(Interrupt::SWI_IRQ_1); | ||
| 139 | unwrap!(spawner.spawn(run_high())); | 134 | unwrap!(spawner.spawn(run_high())); |
| 140 | 135 | ||
| 141 | // Medium-priority executor: SWI_IRQ_0, priority level 3 | 136 | // Medium-priority executor: SWI_IRQ_0, priority level 3 |
| 142 | unsafe { nvic.set_priority(Interrupt::SWI_IRQ_0, 3 << 6) }; | 137 | interrupt::SWI_IRQ_0.set_priority(Priority::P3); |
| 143 | info!("bla: {}", NVIC::get_priority(Interrupt::SWI_IRQ_0)); | 138 | let spawner = EXECUTOR_MED.start(interrupt::SWI_IRQ_0); |
| 144 | let spawner = EXECUTOR_MED.start(Interrupt::SWI_IRQ_0); | ||
| 145 | unwrap!(spawner.spawn(run_med())); | 139 | unwrap!(spawner.spawn(run_med())); |
| 146 | 140 | ||
| 147 | // Low priority executor: runs in thread mode, using WFE/SEV | 141 | // Low priority executor: runs in thread mode, using WFE/SEV |
diff --git a/examples/rp/src/bin/usb_ethernet.rs b/examples/rp/src/bin/usb_ethernet.rs index 16fbf5e91..91d1ec8e7 100644 --- a/examples/rp/src/bin/usb_ethernet.rs +++ b/examples/rp/src/bin/usb_ethernet.rs | |||
| @@ -86,8 +86,8 @@ async fn main(spawner: Spawner) { | |||
| 86 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); | 86 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); |
| 87 | unwrap!(spawner.spawn(usb_ncm_task(runner))); | 87 | unwrap!(spawner.spawn(usb_ncm_task(runner))); |
| 88 | 88 | ||
| 89 | let config = embassy_net::Config::Dhcp(Default::default()); | 89 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| 90 | //let config = embassy_net::Config::Static(embassy_net::StaticConfig { | 90 | //let config = embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 { |
| 91 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), | 91 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), |
| 92 | // dns_servers: Vec::new(), | 92 | // dns_servers: Vec::new(), |
| 93 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), | 93 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), |
diff --git a/examples/rp/src/bin/wifi_ap_tcp_server.rs b/examples/rp/src/bin/wifi_ap_tcp_server.rs index b27d3c9f8..e8197390c 100644 --- a/examples/rp/src/bin/wifi_ap_tcp_server.rs +++ b/examples/rp/src/bin/wifi_ap_tcp_server.rs | |||
| @@ -62,7 +62,7 @@ async fn main(spawner: Spawner) { | |||
| 62 | .await; | 62 | .await; |
| 63 | 63 | ||
| 64 | // Use a link-local address for communication without DHCP server | 64 | // Use a link-local address for communication without DHCP server |
| 65 | let config = Config::Static(embassy_net::StaticConfig { | 65 | let config = Config::ipv4_static(embassy_net::StaticConfigV4 { |
| 66 | address: embassy_net::Ipv4Cidr::new(embassy_net::Ipv4Address::new(169, 254, 1, 1), 16), | 66 | address: embassy_net::Ipv4Cidr::new(embassy_net::Ipv4Address::new(169, 254, 1, 1), 16), |
| 67 | dns_servers: heapless::Vec::new(), | 67 | dns_servers: heapless::Vec::new(), |
| 68 | gateway: None, | 68 | gateway: None, |
diff --git a/examples/rp/src/bin/wifi_tcp_server.rs b/examples/rp/src/bin/wifi_tcp_server.rs index 1a00bca96..026e056fa 100644 --- a/examples/rp/src/bin/wifi_tcp_server.rs +++ b/examples/rp/src/bin/wifi_tcp_server.rs | |||
| @@ -61,8 +61,8 @@ async fn main(spawner: Spawner) { | |||
| 61 | .set_power_management(cyw43::PowerManagementMode::PowerSave) | 61 | .set_power_management(cyw43::PowerManagementMode::PowerSave) |
| 62 | .await; | 62 | .await; |
| 63 | 63 | ||
| 64 | let config = Config::Dhcp(Default::default()); | 64 | let config = Config::dhcpv4(Default::default()); |
| 65 | //let config = embassy_net::Config::Static(embassy_net::Config { | 65 | //let config = embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 { |
| 66 | // address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), | 66 | // address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), |
| 67 | // dns_servers: Vec::new(), | 67 | // dns_servers: Vec::new(), |
| 68 | // gateway: Some(Ipv4Address::new(192, 168, 69, 1)), | 68 | // gateway: Some(Ipv4Address::new(192, 168, 69, 1)), |
diff --git a/examples/std/src/bin/net.rs b/examples/std/src/bin/net.rs index b42bfc13b..3aadb029d 100644 --- a/examples/std/src/bin/net.rs +++ b/examples/std/src/bin/net.rs | |||
| @@ -42,13 +42,13 @@ async fn main_task(spawner: Spawner) { | |||
| 42 | 42 | ||
| 43 | // Choose between dhcp or static ip | 43 | // Choose between dhcp or static ip |
| 44 | let config = if opts.static_ip { | 44 | let config = if opts.static_ip { |
| 45 | Config::Static(embassy_net::StaticConfig { | 45 | Config::ipv4_static(embassy_net::StaticConfigV4 { |
| 46 | address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), | 46 | address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), |
| 47 | dns_servers: Vec::new(), | 47 | dns_servers: Vec::new(), |
| 48 | gateway: Some(Ipv4Address::new(192, 168, 69, 1)), | 48 | gateway: Some(Ipv4Address::new(192, 168, 69, 1)), |
| 49 | }) | 49 | }) |
| 50 | } else { | 50 | } else { |
| 51 | Config::Dhcp(Default::default()) | 51 | Config::dhcpv4(Default::default()) |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| 54 | // Generate random seed | 54 | // Generate random seed |
diff --git a/examples/std/src/bin/net_dns.rs b/examples/std/src/bin/net_dns.rs index 932ac5831..65b5a2cd9 100644 --- a/examples/std/src/bin/net_dns.rs +++ b/examples/std/src/bin/net_dns.rs | |||
| @@ -40,14 +40,14 @@ async fn main_task(spawner: Spawner) { | |||
| 40 | 40 | ||
| 41 | // Choose between dhcp or static ip | 41 | // Choose between dhcp or static ip |
| 42 | let config = if opts.static_ip { | 42 | let config = if opts.static_ip { |
| 43 | Config::Static(embassy_net::StaticConfig { | 43 | Config::ipv4_static(embassy_net::StaticConfigV4 { |
| 44 | address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 1), 24), | 44 | address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 1), 24), |
| 45 | dns_servers: Vec::from_slice(&[Ipv4Address::new(8, 8, 4, 4).into(), Ipv4Address::new(8, 8, 8, 8).into()]) | 45 | dns_servers: Vec::from_slice(&[Ipv4Address::new(8, 8, 4, 4).into(), Ipv4Address::new(8, 8, 8, 8).into()]) |
| 46 | .unwrap(), | 46 | .unwrap(), |
| 47 | gateway: Some(Ipv4Address::new(192, 168, 69, 100)), | 47 | gateway: Some(Ipv4Address::new(192, 168, 69, 100)), |
| 48 | }) | 48 | }) |
| 49 | } else { | 49 | } else { |
| 50 | Config::Dhcp(Default::default()) | 50 | Config::dhcpv4(Default::default()) |
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| 53 | // Generate random seed | 53 | // Generate random seed |
diff --git a/examples/std/src/bin/net_udp.rs b/examples/std/src/bin/net_udp.rs index d89ec7643..3fc46156c 100644 --- a/examples/std/src/bin/net_udp.rs +++ b/examples/std/src/bin/net_udp.rs | |||
| @@ -38,13 +38,13 @@ async fn main_task(spawner: Spawner) { | |||
| 38 | 38 | ||
| 39 | // Choose between dhcp or static ip | 39 | // Choose between dhcp or static ip |
| 40 | let config = if opts.static_ip { | 40 | let config = if opts.static_ip { |
| 41 | Config::Static(embassy_net::StaticConfig { | 41 | Config::ipv4_static(embassy_net::StaticConfigV4 { |
| 42 | address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), | 42 | address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), |
| 43 | dns_servers: Vec::new(), | 43 | dns_servers: Vec::new(), |
| 44 | gateway: Some(Ipv4Address::new(192, 168, 69, 1)), | 44 | gateway: Some(Ipv4Address::new(192, 168, 69, 1)), |
| 45 | }) | 45 | }) |
| 46 | } else { | 46 | } else { |
| 47 | Config::Dhcp(Default::default()) | 47 | Config::dhcpv4(Default::default()) |
| 48 | }; | 48 | }; |
| 49 | 49 | ||
| 50 | // Generate random seed | 50 | // Generate random seed |
diff --git a/examples/std/src/bin/tcp_accept.rs b/examples/std/src/bin/tcp_accept.rs index 01695baea..df09986ac 100644 --- a/examples/std/src/bin/tcp_accept.rs +++ b/examples/std/src/bin/tcp_accept.rs | |||
| @@ -53,13 +53,13 @@ async fn main_task(spawner: Spawner) { | |||
| 53 | 53 | ||
| 54 | // Choose between dhcp or static ip | 54 | // Choose between dhcp or static ip |
| 55 | let config = if opts.static_ip { | 55 | let config = if opts.static_ip { |
| 56 | Config::Static(embassy_net::StaticConfig { | 56 | Config::ipv4_static(embassy_net::StaticConfigV4 { |
| 57 | address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), | 57 | address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), |
| 58 | dns_servers: Vec::new(), | 58 | dns_servers: Vec::new(), |
| 59 | gateway: Some(Ipv4Address::new(192, 168, 69, 1)), | 59 | gateway: Some(Ipv4Address::new(192, 168, 69, 1)), |
| 60 | }) | 60 | }) |
| 61 | } else { | 61 | } else { |
| 62 | Config::Dhcp(Default::default()) | 62 | Config::dhcpv4(Default::default()) |
| 63 | }; | 63 | }; |
| 64 | 64 | ||
| 65 | // Generate random seed | 65 | // Generate random seed |
diff --git a/examples/stm32c0/Cargo.toml b/examples/stm32c0/Cargo.toml index ad11fbd1c..43f432520 100644 --- a/examples/stm32c0/Cargo.toml +++ b/examples/stm32c0/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32c031c6", "memory-x", "unstable-pac", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32c031c6", "memory-x", "unstable-pac", "exti"] } |
| 12 | 12 | ||
diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index ff134bb0e..8d2248ed0 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml | |||
| @@ -13,7 +13,7 @@ defmt = "0.3" | |||
| 13 | defmt-rtt = "0.4" | 13 | defmt-rtt = "0.4" |
| 14 | panic-probe = "0.3" | 14 | panic-probe = "0.3" |
| 15 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 15 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 16 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } | 16 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } |
| 17 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 17 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 18 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "memory-x", "stm32f091rc", "time-driver-any", "exti", "unstable-pac"] } | 18 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "memory-x", "stm32f091rc", "time-driver-any", "exti", "unstable-pac"] } |
| 19 | static_cell = { version = "1.1", features = ["nightly"]} | 19 | static_cell = { version = "1.1", features = ["nightly"]} |
diff --git a/examples/stm32f0/src/bin/multiprio.rs b/examples/stm32f0/src/bin/multiprio.rs index 430a805fc..988ffeef1 100644 --- a/examples/stm32f0/src/bin/multiprio.rs +++ b/examples/stm32f0/src/bin/multiprio.rs | |||
| @@ -57,14 +57,11 @@ | |||
| 57 | #![no_main] | 57 | #![no_main] |
| 58 | #![feature(type_alias_impl_trait)] | 58 | #![feature(type_alias_impl_trait)] |
| 59 | 59 | ||
| 60 | use core::mem; | ||
| 61 | |||
| 62 | use cortex_m::peripheral::NVIC; | ||
| 63 | use cortex_m_rt::entry; | 60 | use cortex_m_rt::entry; |
| 64 | use defmt::*; | 61 | use defmt::*; |
| 65 | use embassy_executor::{Executor, InterruptExecutor}; | 62 | use embassy_executor::{Executor, InterruptExecutor}; |
| 66 | use embassy_stm32::interrupt; | 63 | use embassy_stm32::interrupt; |
| 67 | use embassy_stm32::pac::Interrupt; | 64 | use embassy_stm32::interrupt::{InterruptExt, Priority}; |
| 68 | use embassy_time::{Duration, Instant, Timer}; | 65 | use embassy_time::{Duration, Instant, Timer}; |
| 69 | use static_cell::StaticCell; | 66 | use static_cell::StaticCell; |
| 70 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -129,16 +126,15 @@ unsafe fn USART2() { | |||
| 129 | fn main() -> ! { | 126 | fn main() -> ! { |
| 130 | // Initialize and create handle for devicer peripherals | 127 | // Initialize and create handle for devicer peripherals |
| 131 | let _p = embassy_stm32::init(Default::default()); | 128 | let _p = embassy_stm32::init(Default::default()); |
| 132 | let mut nvic: NVIC = unsafe { mem::transmute(()) }; | ||
| 133 | 129 | ||
| 134 | // High-priority executor: USART1, priority level 6 | 130 | // High-priority executor: USART1, priority level 6 |
| 135 | unsafe { nvic.set_priority(Interrupt::USART1, 6 << 4) }; | 131 | interrupt::USART1.set_priority(Priority::P6); |
| 136 | let spawner = EXECUTOR_HIGH.start(Interrupt::USART1); | 132 | let spawner = EXECUTOR_HIGH.start(interrupt::USART1); |
| 137 | unwrap!(spawner.spawn(run_high())); | 133 | unwrap!(spawner.spawn(run_high())); |
| 138 | 134 | ||
| 139 | // Medium-priority executor: USART2, priority level 7 | 135 | // Medium-priority executor: USART2, priority level 7 |
| 140 | unsafe { nvic.set_priority(Interrupt::USART2, 7 << 4) }; | 136 | interrupt::USART2.set_priority(Priority::P7); |
| 141 | let spawner = EXECUTOR_MED.start(Interrupt::USART2); | 137 | let spawner = EXECUTOR_MED.start(interrupt::USART2); |
| 142 | unwrap!(spawner.spawn(run_med())); | 138 | unwrap!(spawner.spawn(run_med())); |
| 143 | 139 | ||
| 144 | // Low priority executor: runs in thread mode, using WFE/SEV | 140 | // Low priority executor: runs in thread mode, using WFE/SEV |
diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml index 345e948a6..d34fd439a 100644 --- a/examples/stm32f1/Cargo.toml +++ b/examples/stm32f1/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any", "unstable-traits" ] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any", "unstable-traits" ] } |
| 12 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 12 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml index e4f97a589..5e3e0d0f7 100644 --- a/examples/stm32f2/Cargo.toml +++ b/examples/stm32f2/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } |
| 12 | 12 | ||
diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index 0fe9cb122..29ab2009c 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } |
| 12 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 12 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
diff --git a/examples/stm32f3/src/bin/multiprio.rs b/examples/stm32f3/src/bin/multiprio.rs index 5d010f799..80bf59deb 100644 --- a/examples/stm32f3/src/bin/multiprio.rs +++ b/examples/stm32f3/src/bin/multiprio.rs | |||
| @@ -57,14 +57,11 @@ | |||
| 57 | #![no_main] | 57 | #![no_main] |
| 58 | #![feature(type_alias_impl_trait)] | 58 | #![feature(type_alias_impl_trait)] |
| 59 | 59 | ||
| 60 | use core::mem; | ||
| 61 | |||
| 62 | use cortex_m::peripheral::NVIC; | ||
| 63 | use cortex_m_rt::entry; | 60 | use cortex_m_rt::entry; |
| 64 | use defmt::*; | 61 | use defmt::*; |
| 65 | use embassy_executor::{Executor, InterruptExecutor}; | 62 | use embassy_executor::{Executor, InterruptExecutor}; |
| 66 | use embassy_stm32::interrupt; | 63 | use embassy_stm32::interrupt; |
| 67 | use embassy_stm32::pac::Interrupt; | 64 | use embassy_stm32::interrupt::{InterruptExt, Priority}; |
| 68 | use embassy_time::{Duration, Instant, Timer}; | 65 | use embassy_time::{Duration, Instant, Timer}; |
| 69 | use static_cell::StaticCell; | 66 | use static_cell::StaticCell; |
| 70 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -130,16 +127,15 @@ fn main() -> ! { | |||
| 130 | info!("Hello World!"); | 127 | info!("Hello World!"); |
| 131 | 128 | ||
| 132 | let _p = embassy_stm32::init(Default::default()); | 129 | let _p = embassy_stm32::init(Default::default()); |
| 133 | let mut nvic: NVIC = unsafe { mem::transmute(()) }; | ||
| 134 | 130 | ||
| 135 | // High-priority executor: UART4, priority level 6 | 131 | // High-priority executor: UART4, priority level 6 |
| 136 | unsafe { nvic.set_priority(Interrupt::UART4, 6 << 4) }; | 132 | interrupt::UART4.set_priority(Priority::P6); |
| 137 | let spawner = EXECUTOR_HIGH.start(Interrupt::UART4); | 133 | let spawner = EXECUTOR_HIGH.start(interrupt::UART4); |
| 138 | unwrap!(spawner.spawn(run_high())); | 134 | unwrap!(spawner.spawn(run_high())); |
| 139 | 135 | ||
| 140 | // Medium-priority executor: UART5, priority level 7 | 136 | // Medium-priority executor: UART5, priority level 7 |
| 141 | unsafe { nvic.set_priority(Interrupt::UART5, 7 << 4) }; | 137 | interrupt::UART5.set_priority(Priority::P7); |
| 142 | let spawner = EXECUTOR_MED.start(Interrupt::UART5); | 138 | let spawner = EXECUTOR_MED.start(interrupt::UART5); |
| 143 | unwrap!(spawner.spawn(run_med())); | 139 | unwrap!(spawner.spawn(run_med())); |
| 144 | 140 | ||
| 145 | // Low priority executor: runs in thread mode, using WFE/SEV | 141 | // Low priority executor: runs in thread mode, using WFE/SEV |
diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index 3a8efdd06..7ecb64fce 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers", "arch-cortex-m", "executor-thread", "executor-interrupt"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers", "arch-cortex-m", "executor-thread", "executor-interrupt"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "embedded-sdmmc", "chrono"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "embedded-sdmmc", "chrono"] } |
| 12 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 12 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
diff --git a/examples/stm32f4/src/bin/multiprio.rs b/examples/stm32f4/src/bin/multiprio.rs index 5d010f799..80bf59deb 100644 --- a/examples/stm32f4/src/bin/multiprio.rs +++ b/examples/stm32f4/src/bin/multiprio.rs | |||
| @@ -57,14 +57,11 @@ | |||
| 57 | #![no_main] | 57 | #![no_main] |
| 58 | #![feature(type_alias_impl_trait)] | 58 | #![feature(type_alias_impl_trait)] |
| 59 | 59 | ||
| 60 | use core::mem; | ||
| 61 | |||
| 62 | use cortex_m::peripheral::NVIC; | ||
| 63 | use cortex_m_rt::entry; | 60 | use cortex_m_rt::entry; |
| 64 | use defmt::*; | 61 | use defmt::*; |
| 65 | use embassy_executor::{Executor, InterruptExecutor}; | 62 | use embassy_executor::{Executor, InterruptExecutor}; |
| 66 | use embassy_stm32::interrupt; | 63 | use embassy_stm32::interrupt; |
| 67 | use embassy_stm32::pac::Interrupt; | 64 | use embassy_stm32::interrupt::{InterruptExt, Priority}; |
| 68 | use embassy_time::{Duration, Instant, Timer}; | 65 | use embassy_time::{Duration, Instant, Timer}; |
| 69 | use static_cell::StaticCell; | 66 | use static_cell::StaticCell; |
| 70 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -130,16 +127,15 @@ fn main() -> ! { | |||
| 130 | info!("Hello World!"); | 127 | info!("Hello World!"); |
| 131 | 128 | ||
| 132 | let _p = embassy_stm32::init(Default::default()); | 129 | let _p = embassy_stm32::init(Default::default()); |
| 133 | let mut nvic: NVIC = unsafe { mem::transmute(()) }; | ||
| 134 | 130 | ||
| 135 | // High-priority executor: UART4, priority level 6 | 131 | // High-priority executor: UART4, priority level 6 |
| 136 | unsafe { nvic.set_priority(Interrupt::UART4, 6 << 4) }; | 132 | interrupt::UART4.set_priority(Priority::P6); |
| 137 | let spawner = EXECUTOR_HIGH.start(Interrupt::UART4); | 133 | let spawner = EXECUTOR_HIGH.start(interrupt::UART4); |
| 138 | unwrap!(spawner.spawn(run_high())); | 134 | unwrap!(spawner.spawn(run_high())); |
| 139 | 135 | ||
| 140 | // Medium-priority executor: UART5, priority level 7 | 136 | // Medium-priority executor: UART5, priority level 7 |
| 141 | unsafe { nvic.set_priority(Interrupt::UART5, 7 << 4) }; | 137 | interrupt::UART5.set_priority(Priority::P7); |
| 142 | let spawner = EXECUTOR_MED.start(Interrupt::UART5); | 138 | let spawner = EXECUTOR_MED.start(interrupt::UART5); |
| 143 | unwrap!(spawner.spawn(run_med())); | 139 | unwrap!(spawner.spawn(run_med())); |
| 144 | 140 | ||
| 145 | // Low priority executor: runs in thread mode, using WFE/SEV | 141 | // Low priority executor: runs in thread mode, using WFE/SEV |
diff --git a/examples/stm32f4/src/bin/usb_ethernet.rs b/examples/stm32f4/src/bin/usb_ethernet.rs index d229cc3ef..953d99a45 100644 --- a/examples/stm32f4/src/bin/usb_ethernet.rs +++ b/examples/stm32f4/src/bin/usb_ethernet.rs | |||
| @@ -94,8 +94,8 @@ async fn main(spawner: Spawner) { | |||
| 94 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); | 94 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); |
| 95 | unwrap!(spawner.spawn(usb_ncm_task(runner))); | 95 | unwrap!(spawner.spawn(usb_ncm_task(runner))); |
| 96 | 96 | ||
| 97 | let config = embassy_net::Config::Dhcp(Default::default()); | 97 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| 98 | //let config = embassy_net::Config::Static(embassy_net::StaticConfig { | 98 | //let config = embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 { |
| 99 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), | 99 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), |
| 100 | // dns_servers: Vec::new(), | 100 | // dns_servers: Vec::new(), |
| 101 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), | 101 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), |
diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 7a650067c..657251c50 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f767zi", "unstable-pac", "time-driver-any", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f767zi", "unstable-pac", "time-driver-any", "exti"] } |
| 12 | embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet"] } | 12 | embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet"] } |
diff --git a/examples/stm32f7/build.rs b/examples/stm32f7/build.rs index c4e15f19c..2b5d412a9 100644 --- a/examples/stm32f7/build.rs +++ b/examples/stm32f7/build.rs | |||
| @@ -1,9 +1,8 @@ | |||
| 1 | //! adapted from https://github.com/stm32-rs/stm32f7xx-hal/blob/master/build.rs | 1 | //! adapted from https://github.com/stm32-rs/stm32f7xx-hal/blob/master/build.rs |
| 2 | use std::env; | ||
| 3 | use std::fs::File; | 2 | use std::fs::File; |
| 4 | use std::io::prelude::*; | 3 | use std::io::prelude::*; |
| 5 | use std::io::{self}; | ||
| 6 | use std::path::PathBuf; | 4 | use std::path::PathBuf; |
| 5 | use std::{env, io}; | ||
| 7 | 6 | ||
| 8 | #[derive(Debug)] | 7 | #[derive(Debug)] |
| 9 | enum Error { | 8 | enum Error { |
diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index d8438241c..fde6a7576 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs | |||
| @@ -62,8 +62,8 @@ async fn main(spawner: Spawner) -> ! { | |||
| 62 | 0, | 62 | 0, |
| 63 | ); | 63 | ); |
| 64 | 64 | ||
| 65 | let config = embassy_net::Config::Dhcp(Default::default()); | 65 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| 66 | //let config = embassy_net::Config::Static(embassy_net::StaticConfig { | 66 | //let config = embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 { |
| 67 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), | 67 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), |
| 68 | // dns_servers: Vec::new(), | 68 | // dns_servers: Vec::new(), |
| 69 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), | 69 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), |
diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml index 4d7fc4548..c5245757b 100644 --- a/examples/stm32g0/Cargo.toml +++ b/examples/stm32g0/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } |
| 12 | 12 | ||
diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml index 00e2dae4c..f94df2dd3 100644 --- a/examples/stm32g4/Cargo.toml +++ b/examples/stm32g4/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } |
| 12 | embassy-hal-common = {version = "0.1.0", path = "../../embassy-hal-common" } | 12 | embassy-hal-common = {version = "0.1.0", path = "../../embassy-hal-common" } |
diff --git a/examples/stm32g4/src/bin/pll.rs b/examples/stm32g4/src/bin/pll.rs new file mode 100644 index 000000000..8cee41e9b --- /dev/null +++ b/examples/stm32g4/src/bin/pll.rs | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_stm32::rcc::{ClockSrc, PllM, PllN, PllR, PllSrc}; | ||
| 8 | use embassy_stm32::Config; | ||
| 9 | use embassy_time::{Duration, Timer}; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | ||
| 11 | |||
| 12 | #[embassy_executor::main] | ||
| 13 | async fn main(_spawner: Spawner) { | ||
| 14 | let mut config = Config::default(); | ||
| 15 | |||
| 16 | // Configure PLL to max frequency of 170 MHz | ||
| 17 | config.rcc.mux = ClockSrc::PLLCLK(PllSrc::HSI16, PllM::Div4, PllN::Mul85, PllR::Div2); | ||
| 18 | |||
| 19 | let _p = embassy_stm32::init(config); | ||
| 20 | info!("Hello World!"); | ||
| 21 | |||
| 22 | loop { | ||
| 23 | Timer::after(Duration::from_millis(1000)).await; | ||
| 24 | info!("1s elapsed"); | ||
| 25 | } | ||
| 26 | } | ||
diff --git a/examples/stm32h5/Cargo.toml b/examples/stm32h5/Cargo.toml index d49a0dde7..ebe511347 100644 --- a/examples/stm32h5/Cargo.toml +++ b/examples/stm32h5/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h563zi", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h563zi", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } |
| 12 | embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "unstable-traits", "proto-ipv6"] } | 12 | embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "unstable-traits", "proto-ipv6"] } |
diff --git a/examples/stm32h5/src/bin/eth.rs b/examples/stm32h5/src/bin/eth.rs index 5d1eadf4b..78c8282a6 100644 --- a/examples/stm32h5/src/bin/eth.rs +++ b/examples/stm32h5/src/bin/eth.rs | |||
| @@ -81,8 +81,8 @@ async fn main(spawner: Spawner) -> ! { | |||
| 81 | 0, | 81 | 0, |
| 82 | ); | 82 | ); |
| 83 | 83 | ||
| 84 | let config = embassy_net::Config::Dhcp(Default::default()); | 84 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| 85 | //let config = embassy_net::Config::Static(embassy_net::StaticConfig { | 85 | //let config = embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 { |
| 86 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), | 86 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), |
| 87 | // dns_servers: Vec::new(), | 87 | // dns_servers: Vec::new(), |
| 88 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), | 88 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), |
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 08b57f988..62ef5e9e4 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } |
| 12 | embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "unstable-traits", "proto-ipv6"] } | 12 | embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "unstable-traits", "proto-ipv6"] } |
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 3aa7b2271..12d37f7a4 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs | |||
| @@ -63,8 +63,8 @@ async fn main(spawner: Spawner) -> ! { | |||
| 63 | 0, | 63 | 0, |
| 64 | ); | 64 | ); |
| 65 | 65 | ||
| 66 | let config = embassy_net::Config::Dhcp(Default::default()); | 66 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| 67 | //let config = embassy_net::Config::Static(embassy_net::StaticConfig { | 67 | //let config = embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 { |
| 68 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), | 68 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), |
| 69 | // dns_servers: Vec::new(), | 69 | // dns_servers: Vec::new(), |
| 70 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), | 70 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), |
diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index 575c716b6..6078fc3fe 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs | |||
| @@ -64,8 +64,8 @@ async fn main(spawner: Spawner) -> ! { | |||
| 64 | 0, | 64 | 0, |
| 65 | ); | 65 | ); |
| 66 | 66 | ||
| 67 | let config = embassy_net::Config::Dhcp(Default::default()); | 67 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| 68 | //let config = embassy_net::Config::StaticConfig(embassy_net::Config { | 68 | //let config = embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 { |
| 69 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), | 69 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), |
| 70 | // dns_servers: Vec::new(), | 70 | // dns_servers: Vec::new(), |
| 71 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), | 71 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), |
diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 235f1b0b3..2ead714e4 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [features] | 7 | [features] |
| 8 | default = ["nightly"] | 8 | default = ["nightly"] |
| 9 | nightly = ["embassy-stm32/nightly", "embassy-time/nightly", "embassy-time/unstable-traits", | 9 | nightly = ["embassy-stm32/nightly", "embassy-time/nightly", "embassy-time/unstable-traits", "embassy-executor/nightly", |
| 10 | "embassy-lora", "lora-phy", "lorawan-device", "lorawan", "embedded-io/async"] | 10 | "embassy-lora", "lora-phy", "lorawan-device", "lorawan", "embedded-io/async"] |
| 11 | 11 | ||
| 12 | [dependencies] | 12 | [dependencies] |
diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml index 8b6508c87..93d48abeb 100644 --- a/examples/stm32l1/Cargo.toml +++ b/examples/stm32l1/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } |
| 12 | 12 | ||
diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index 29d091f94..3bb473ef5 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } | 11 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } |
| 12 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l4s5vi", "time-driver-any", "exti", "unstable-traits"] } | 12 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l4s5vi", "time-driver-any", "exti", "unstable-traits"] } |
diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index 2ac9c180d..6035c291f 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "unstable-traits", "memory-x"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "unstable-traits", "memory-x"] } |
| 12 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 12 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index 6163e0709..32eba4277 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs | |||
| @@ -91,8 +91,8 @@ async fn main(spawner: Spawner) { | |||
| 91 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); | 91 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); |
| 92 | unwrap!(spawner.spawn(usb_ncm_task(runner))); | 92 | unwrap!(spawner.spawn(usb_ncm_task(runner))); |
| 93 | 93 | ||
| 94 | let config = embassy_net::Config::Dhcp(Default::default()); | 94 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| 95 | //let config = embassy_net::Config::Static(embassy_net::StaticConfig { | 95 | //let config = embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 { |
| 96 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), | 96 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), |
| 97 | // dns_servers: Vec::new(), | 97 | // dns_servers: Vec::new(), |
| 98 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), | 98 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), |
diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml index be205f880..e2318c3d6 100644 --- a/examples/stm32u5/Cargo.toml +++ b/examples/stm32u5/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } |
| 12 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 12 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index 8cfac772a..14897b171 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55rg", "time-driver-any", "memory-x", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55rg", "time-driver-any", "memory-x", "exti"] } |
| 12 | 12 | ||
diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 6191d01e9..260f9afa1 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "unstable-pac", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "unstable-pac", "exti"] } |
| 12 | embassy-embedded-hal = {version = "0.1.0", path = "../../embassy-embedded-hal" } | 12 | embassy-embedded-hal = {version = "0.1.0", path = "../../embassy-embedded-hal" } |
diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index fa97fdcc4..180d0ebbe 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml | |||
| @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" | |||
| 8 | teleprobe-meta = "1.1" | 8 | teleprobe-meta = "1.1" |
| 9 | 9 | ||
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt"] } | 12 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt"] } |
| 13 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } | 13 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } |
| 14 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | 14 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } |
diff --git a/tests/rp/src/bin/cyw43-perf.rs b/tests/rp/src/bin/cyw43-perf.rs index 568f1b826..7a94ea191 100644 --- a/tests/rp/src/bin/cyw43-perf.rs +++ b/tests/rp/src/bin/cyw43-perf.rs | |||
| @@ -63,7 +63,7 @@ async fn main(spawner: Spawner) { | |||
| 63 | .set_power_management(cyw43::PowerManagementMode::PowerSave) | 63 | .set_power_management(cyw43::PowerManagementMode::PowerSave) |
| 64 | .await; | 64 | .await; |
| 65 | 65 | ||
| 66 | let config = Config::Dhcp(Default::default()); | 66 | let config = Config::dhcpv4(Default::default()); |
| 67 | //let config = embassy_net::Config::Static(embassy_net::Config { | 67 | //let config = embassy_net::Config::Static(embassy_net::Config { |
| 68 | // address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), | 68 | // address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), |
| 69 | // dns_servers: Vec::new(), | 69 | // dns_servers: Vec::new(), |
| @@ -93,7 +93,7 @@ async fn main(spawner: Spawner) { | |||
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | info!("Waiting for DHCP up..."); | 95 | info!("Waiting for DHCP up..."); |
| 96 | while stack.config().is_none() { | 96 | while stack.config_v4().is_none() { |
| 97 | Timer::after(Duration::from_millis(100)).await; | 97 | Timer::after(Duration::from_millis(100)).await; |
| 98 | } | 98 | } |
| 99 | info!("IP addressing up!"); | 99 | info!("IP addressing up!"); |
| @@ -115,9 +115,9 @@ const WIFI_NETWORK: &str = "EmbassyTest"; | |||
| 115 | const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud"; | 115 | const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud"; |
| 116 | 116 | ||
| 117 | const TEST_DURATION: usize = 10; | 117 | const TEST_DURATION: usize = 10; |
| 118 | const TEST_EXPECTED_DOWNLOAD_KBPS: usize = 500; | 118 | const TEST_EXPECTED_DOWNLOAD_KBPS: usize = 300; |
| 119 | const TEST_EXPECTED_UPLOAD_KBPS: usize = 500; | 119 | const TEST_EXPECTED_UPLOAD_KBPS: usize = 300; |
| 120 | const TEST_EXPECTED_UPLOAD_DOWNLOAD_KBPS: usize = 400; | 120 | const TEST_EXPECTED_UPLOAD_DOWNLOAD_KBPS: usize = 300; |
| 121 | const RX_BUFFER_SIZE: usize = 4096; | 121 | const RX_BUFFER_SIZE: usize = 4096; |
| 122 | const TX_BUFFER_SIZE: usize = 4096; | 122 | const TX_BUFFER_SIZE: usize = 4096; |
| 123 | const SERVER_ADDRESS: Ipv4Address = Ipv4Address::new(192, 168, 2, 2); | 123 | const SERVER_ADDRESS: Ipv4Address = Ipv4Address::new(192, 168, 2, 2); |
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index f1b0ba121..3f48bf3f1 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml | |||
| @@ -25,7 +25,7 @@ not-gpdma = [] | |||
| 25 | teleprobe-meta = "1" | 25 | teleprobe-meta = "1" |
| 26 | 26 | ||
| 27 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 27 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 28 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 28 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 29 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "tick-hz-32_768", "defmt-timestamp-uptime"] } | 29 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "tick-hz-32_768", "defmt-timestamp-uptime"] } |
| 30 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "memory-x", "time-driver-any"] } | 30 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "memory-x", "time-driver-any"] } |
| 31 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | 31 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } |
