diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-02-20 00:47:15 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-20 00:47:15 +0000 |
| commit | b05cd77a62bc8902db2ae2dd36ed58b88acee932 (patch) | |
| tree | d53baec0b2433f856bf3b6f3ec0915d02e55c37a | |
| parent | a2bd37be40314c425467860e53cdbd332b8f2829 (diff) | |
| parent | 7fa478358ac117557af778d12d7812da5521fdfd (diff) | |
Merge #1170
1170: nrf: add support for UICR configuration. r=Dirbaio a=Dirbaio
- APPROTECT enable/disable. Notably this fixes issues with nrf52-rev3 and nrf53 from locking itself at reset.
- Use NFC pins as GPIO.
- Use RESET pin as GPIO.
NFC and RESET pins singletons are made available only when usable as GPIO, for compile-time checking.
TODO: test
- [x] nrf52 rev1
- [x] nrf52 rev3
- [x] nrf53
- [x] nrf91
Co-authored-by: Dario Nieuwenhuis <[email protected]>
| -rwxr-xr-x | ci.sh | 4 | ||||
| -rw-r--r-- | embassy-nrf/Cargo.toml | 35 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf52805.rs | 4 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf52810.rs | 4 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf52811.rs | 4 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf52820.rs | 4 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf52832.rs | 8 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf52833.rs | 8 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf52840.rs | 8 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf5340_app.rs | 4 | ||||
| -rw-r--r-- | embassy-nrf/src/lib.rs | 208 | ||||
| -rw-r--r-- | embassy-nrf/src/nvmc.rs | 12 |
12 files changed, 284 insertions, 19 deletions
| @@ -46,8 +46,8 @@ cargo batch \ | |||
| 46 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52810,gpiote,time-driver-rtc1 \ | 46 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52810,gpiote,time-driver-rtc1 \ |
| 47 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52811,gpiote,time-driver-rtc1 \ | 47 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52811,gpiote,time-driver-rtc1 \ |
| 48 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52820,gpiote,time-driver-rtc1 \ | 48 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52820,gpiote,time-driver-rtc1 \ |
| 49 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52832,gpiote,time-driver-rtc1 \ | 49 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52832,gpiote,time-driver-rtc1,reset-pin-as-gpio \ |
| 50 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52833,gpiote,time-driver-rtc1,unstable-traits \ | 50 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52833,gpiote,time-driver-rtc1,unstable-traits,nfc-pins-as-gpio \ |
| 51 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf9160-s,gpiote,time-driver-rtc1 \ | 51 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf9160-s,gpiote,time-driver-rtc1 \ |
| 52 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf9160-ns,gpiote,time-driver-rtc1,unstable-traits \ | 52 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf9160-ns,gpiote,time-driver-rtc1,unstable-traits \ |
| 53 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf5340-app-s,gpiote,time-driver-rtc1,unstable-traits \ | 53 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf5340-app-s,gpiote,time-driver-rtc1,unstable-traits \ |
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 6b06d5d05..c31ce199b 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml | |||
| @@ -34,22 +34,30 @@ unstable-pac = [] | |||
| 34 | # Implement embedded-hal-async traits if `nightly` is set as well. | 34 | # Implement embedded-hal-async traits if `nightly` is set as well. |
| 35 | unstable-traits = ["embedded-hal-1"] | 35 | unstable-traits = ["embedded-hal-1"] |
| 36 | 36 | ||
| 37 | nrf52805 = ["nrf52805-pac", "_ppi"] | 37 | nrf52805 = ["nrf52805-pac", "_nrf52"] |
| 38 | nrf52810 = ["nrf52810-pac", "_ppi"] | 38 | nrf52810 = ["nrf52810-pac", "_nrf52"] |
| 39 | nrf52811 = ["nrf52811-pac", "_ppi"] | 39 | nrf52811 = ["nrf52811-pac", "_nrf52"] |
| 40 | nrf52820 = ["nrf52820-pac", "_ppi"] | 40 | nrf52820 = ["nrf52820-pac", "_nrf52"] |
| 41 | nrf52832 = ["nrf52832-pac", "_ppi"] | 41 | nrf52832 = ["nrf52832-pac", "_nrf52"] |
| 42 | nrf52833 = ["nrf52833-pac", "_ppi", "_gpio-p1"] | 42 | nrf52833 = ["nrf52833-pac", "_nrf52", "_gpio-p1"] |
| 43 | nrf52840 = ["nrf52840-pac", "_ppi", "_gpio-p1"] | 43 | nrf52840 = ["nrf52840-pac", "_nrf52", "_gpio-p1"] |
| 44 | nrf5340-app-s = ["_nrf5340-app"] | 44 | nrf5340-app-s = ["_nrf5340-app", "_s"] |
| 45 | nrf5340-app-ns = ["_nrf5340-app"] | 45 | nrf5340-app-ns = ["_nrf5340-app", "_ns"] |
| 46 | nrf5340-net = ["_nrf5340-net"] | 46 | nrf5340-net = ["_nrf5340-net"] |
| 47 | nrf9160-s = ["_nrf9160"] | 47 | nrf9160-s = ["_nrf9160", "_s"] |
| 48 | nrf9160-ns = ["_nrf9160"] | 48 | nrf9160-ns = ["_nrf9160", "_ns"] |
| 49 | 49 | ||
| 50 | gpiote = [] | 50 | gpiote = [] |
| 51 | time-driver-rtc1 = ["_time-driver"] | 51 | time-driver-rtc1 = ["_time-driver"] |
| 52 | 52 | ||
| 53 | # Allow using the NFC pins as regular GPIO pins (P0_09/P0_10 on nRF52, P0_02/P0_03 on nRF53) | ||
| 54 | nfc-pins-as-gpio = [] | ||
| 55 | |||
| 56 | # Allow using the RST pin as a regular GPIO pin. | ||
| 57 | # nrf52805, nrf52810, nrf52811, nrf52832: P0_21 | ||
| 58 | # nrf52820, nrf52833, nrf52840: P0_18 | ||
| 59 | reset-pin-as-gpio = [] | ||
| 60 | |||
| 53 | # Features starting with `_` are for internal use only. They're not intended | 61 | # Features starting with `_` are for internal use only. They're not intended |
| 54 | # to be enabled by other crates, and are not covered by semver guarantees. | 62 | # to be enabled by other crates, and are not covered by semver guarantees. |
| 55 | 63 | ||
| @@ -57,9 +65,14 @@ _nrf5340-app = ["_nrf5340", "nrf5340-app-pac"] | |||
| 57 | _nrf5340-net = ["_nrf5340", "nrf5340-net-pac"] | 65 | _nrf5340-net = ["_nrf5340", "nrf5340-net-pac"] |
| 58 | _nrf5340 = ["_gpio-p1", "_dppi"] | 66 | _nrf5340 = ["_gpio-p1", "_dppi"] |
| 59 | _nrf9160 = ["nrf9160-pac", "_dppi"] | 67 | _nrf9160 = ["nrf9160-pac", "_dppi"] |
| 68 | _nrf52 = ["_ppi"] | ||
| 60 | 69 | ||
| 61 | _time-driver = ["dep:embassy-time", "embassy-time?/tick-hz-32_768"] | 70 | _time-driver = ["dep:embassy-time", "embassy-time?/tick-hz-32_768"] |
| 62 | 71 | ||
| 72 | # trustzone state. | ||
| 73 | _s = [] | ||
| 74 | _ns = [] | ||
| 75 | |||
| 63 | _ppi = [] | 76 | _ppi = [] |
| 64 | _dppi = [] | 77 | _dppi = [] |
| 65 | _gpio-p1 = [] | 78 | _gpio-p1 = [] |
diff --git a/embassy-nrf/src/chips/nrf52805.rs b/embassy-nrf/src/chips/nrf52805.rs index bf4019c13..3c74a2a63 100644 --- a/embassy-nrf/src/chips/nrf52805.rs +++ b/embassy-nrf/src/chips/nrf52805.rs | |||
| @@ -6,6 +6,8 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 256; | |||
| 6 | 6 | ||
| 7 | pub const FLASH_SIZE: usize = 192 * 1024; | 7 | pub const FLASH_SIZE: usize = 192 * 1024; |
| 8 | 8 | ||
| 9 | pub const RESET_PIN: u32 = 21; | ||
| 10 | |||
| 9 | embassy_hal_common::peripherals! { | 11 | embassy_hal_common::peripherals! { |
| 10 | // RTC | 12 | // RTC |
| 11 | RTC0, | 13 | RTC0, |
| @@ -108,6 +110,7 @@ embassy_hal_common::peripherals! { | |||
| 108 | P0_18, | 110 | P0_18, |
| 109 | P0_19, | 111 | P0_19, |
| 110 | P0_20, | 112 | P0_20, |
| 113 | #[cfg(feature="reset-pin-as-gpio")] | ||
| 111 | P0_21, | 114 | P0_21, |
| 112 | P0_22, | 115 | P0_22, |
| 113 | P0_23, | 116 | P0_23, |
| @@ -162,6 +165,7 @@ impl_pin!(P0_17, 0, 17); | |||
| 162 | impl_pin!(P0_18, 0, 18); | 165 | impl_pin!(P0_18, 0, 18); |
| 163 | impl_pin!(P0_19, 0, 19); | 166 | impl_pin!(P0_19, 0, 19); |
| 164 | impl_pin!(P0_20, 0, 20); | 167 | impl_pin!(P0_20, 0, 20); |
| 168 | #[cfg(feature = "reset-pin-as-gpio")] | ||
| 165 | impl_pin!(P0_21, 0, 21); | 169 | impl_pin!(P0_21, 0, 21); |
| 166 | impl_pin!(P0_22, 0, 22); | 170 | impl_pin!(P0_22, 0, 22); |
| 167 | impl_pin!(P0_23, 0, 23); | 171 | impl_pin!(P0_23, 0, 23); |
diff --git a/embassy-nrf/src/chips/nrf52810.rs b/embassy-nrf/src/chips/nrf52810.rs index 6c28a3bea..6b5c134b8 100644 --- a/embassy-nrf/src/chips/nrf52810.rs +++ b/embassy-nrf/src/chips/nrf52810.rs | |||
| @@ -6,6 +6,8 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 256; | |||
| 6 | 6 | ||
| 7 | pub const FLASH_SIZE: usize = 192 * 1024; | 7 | pub const FLASH_SIZE: usize = 192 * 1024; |
| 8 | 8 | ||
| 9 | pub const RESET_PIN: u32 = 21; | ||
| 10 | |||
| 9 | embassy_hal_common::peripherals! { | 11 | embassy_hal_common::peripherals! { |
| 10 | // RTC | 12 | // RTC |
| 11 | RTC0, | 13 | RTC0, |
| @@ -111,6 +113,7 @@ embassy_hal_common::peripherals! { | |||
| 111 | P0_18, | 113 | P0_18, |
| 112 | P0_19, | 114 | P0_19, |
| 113 | P0_20, | 115 | P0_20, |
| 116 | #[cfg(feature="reset-pin-as-gpio")] | ||
| 114 | P0_21, | 117 | P0_21, |
| 115 | P0_22, | 118 | P0_22, |
| 116 | P0_23, | 119 | P0_23, |
| @@ -170,6 +173,7 @@ impl_pin!(P0_17, 0, 17); | |||
| 170 | impl_pin!(P0_18, 0, 18); | 173 | impl_pin!(P0_18, 0, 18); |
| 171 | impl_pin!(P0_19, 0, 19); | 174 | impl_pin!(P0_19, 0, 19); |
| 172 | impl_pin!(P0_20, 0, 20); | 175 | impl_pin!(P0_20, 0, 20); |
| 176 | #[cfg(feature = "reset-pin-as-gpio")] | ||
| 173 | impl_pin!(P0_21, 0, 21); | 177 | impl_pin!(P0_21, 0, 21); |
| 174 | impl_pin!(P0_22, 0, 22); | 178 | impl_pin!(P0_22, 0, 22); |
| 175 | impl_pin!(P0_23, 0, 23); | 179 | impl_pin!(P0_23, 0, 23); |
diff --git a/embassy-nrf/src/chips/nrf52811.rs b/embassy-nrf/src/chips/nrf52811.rs index e7214cf5c..c5de9a447 100644 --- a/embassy-nrf/src/chips/nrf52811.rs +++ b/embassy-nrf/src/chips/nrf52811.rs | |||
| @@ -6,6 +6,8 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 256; | |||
| 6 | 6 | ||
| 7 | pub const FLASH_SIZE: usize = 192 * 1024; | 7 | pub const FLASH_SIZE: usize = 192 * 1024; |
| 8 | 8 | ||
| 9 | pub const RESET_PIN: u32 = 21; | ||
| 10 | |||
| 9 | embassy_hal_common::peripherals! { | 11 | embassy_hal_common::peripherals! { |
| 10 | // RTC | 12 | // RTC |
| 11 | RTC0, | 13 | RTC0, |
| @@ -111,6 +113,7 @@ embassy_hal_common::peripherals! { | |||
| 111 | P0_18, | 113 | P0_18, |
| 112 | P0_19, | 114 | P0_19, |
| 113 | P0_20, | 115 | P0_20, |
| 116 | #[cfg(feature="reset-pin-as-gpio")] | ||
| 114 | P0_21, | 117 | P0_21, |
| 115 | P0_22, | 118 | P0_22, |
| 116 | P0_23, | 119 | P0_23, |
| @@ -172,6 +175,7 @@ impl_pin!(P0_17, 0, 17); | |||
| 172 | impl_pin!(P0_18, 0, 18); | 175 | impl_pin!(P0_18, 0, 18); |
| 173 | impl_pin!(P0_19, 0, 19); | 176 | impl_pin!(P0_19, 0, 19); |
| 174 | impl_pin!(P0_20, 0, 20); | 177 | impl_pin!(P0_20, 0, 20); |
| 178 | #[cfg(feature = "reset-pin-as-gpio")] | ||
| 175 | impl_pin!(P0_21, 0, 21); | 179 | impl_pin!(P0_21, 0, 21); |
| 176 | impl_pin!(P0_22, 0, 22); | 180 | impl_pin!(P0_22, 0, 22); |
| 177 | impl_pin!(P0_23, 0, 23); | 181 | impl_pin!(P0_23, 0, 23); |
diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs index 21d1d16cc..81b07f32c 100644 --- a/embassy-nrf/src/chips/nrf52820.rs +++ b/embassy-nrf/src/chips/nrf52820.rs | |||
| @@ -6,6 +6,8 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 512; | |||
| 6 | 6 | ||
| 7 | pub const FLASH_SIZE: usize = 256 * 1024; | 7 | pub const FLASH_SIZE: usize = 256 * 1024; |
| 8 | 8 | ||
| 9 | pub const RESET_PIN: u32 = 18; | ||
| 10 | |||
| 9 | embassy_hal_common::peripherals! { | 11 | embassy_hal_common::peripherals! { |
| 10 | // USB | 12 | // USB |
| 11 | USBD, | 13 | USBD, |
| @@ -106,6 +108,7 @@ embassy_hal_common::peripherals! { | |||
| 106 | P0_15, | 108 | P0_15, |
| 107 | P0_16, | 109 | P0_16, |
| 108 | P0_17, | 110 | P0_17, |
| 111 | #[cfg(feature="reset-pin-as-gpio")] | ||
| 109 | P0_18, | 112 | P0_18, |
| 110 | P0_19, | 113 | P0_19, |
| 111 | P0_20, | 114 | P0_20, |
| @@ -168,6 +171,7 @@ impl_pin!(P0_14, 0, 14); | |||
| 168 | impl_pin!(P0_15, 0, 15); | 171 | impl_pin!(P0_15, 0, 15); |
| 169 | impl_pin!(P0_16, 0, 16); | 172 | impl_pin!(P0_16, 0, 16); |
| 170 | impl_pin!(P0_17, 0, 17); | 173 | impl_pin!(P0_17, 0, 17); |
| 174 | #[cfg(feature = "reset-pin-as-gpio")] | ||
| 171 | impl_pin!(P0_18, 0, 18); | 175 | impl_pin!(P0_18, 0, 18); |
| 172 | impl_pin!(P0_19, 0, 19); | 176 | impl_pin!(P0_19, 0, 19); |
| 173 | impl_pin!(P0_20, 0, 20); | 177 | impl_pin!(P0_20, 0, 20); |
diff --git a/embassy-nrf/src/chips/nrf52832.rs b/embassy-nrf/src/chips/nrf52832.rs index 152dad4e3..c2b23fc5b 100644 --- a/embassy-nrf/src/chips/nrf52832.rs +++ b/embassy-nrf/src/chips/nrf52832.rs | |||
| @@ -10,6 +10,8 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 255; | |||
| 10 | // nrf52832xxAB = 256kb | 10 | // nrf52832xxAB = 256kb |
| 11 | pub const FLASH_SIZE: usize = 512 * 1024; | 11 | pub const FLASH_SIZE: usize = 512 * 1024; |
| 12 | 12 | ||
| 13 | pub const RESET_PIN: u32 = 21; | ||
| 14 | |||
| 13 | embassy_hal_common::peripherals! { | 15 | embassy_hal_common::peripherals! { |
| 14 | // RTC | 16 | // RTC |
| 15 | RTC0, | 17 | RTC0, |
| @@ -109,7 +111,9 @@ embassy_hal_common::peripherals! { | |||
| 109 | P0_06, | 111 | P0_06, |
| 110 | P0_07, | 112 | P0_07, |
| 111 | P0_08, | 113 | P0_08, |
| 114 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 112 | P0_09, | 115 | P0_09, |
| 116 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 113 | P0_10, | 117 | P0_10, |
| 114 | P0_11, | 118 | P0_11, |
| 115 | P0_12, | 119 | P0_12, |
| @@ -121,6 +125,7 @@ embassy_hal_common::peripherals! { | |||
| 121 | P0_18, | 125 | P0_18, |
| 122 | P0_19, | 126 | P0_19, |
| 123 | P0_20, | 127 | P0_20, |
| 128 | #[cfg(feature="reset-pin-as-gpio")] | ||
| 124 | P0_21, | 129 | P0_21, |
| 125 | P0_22, | 130 | P0_22, |
| 126 | P0_23, | 131 | P0_23, |
| @@ -178,7 +183,9 @@ impl_pin!(P0_05, 0, 5); | |||
| 178 | impl_pin!(P0_06, 0, 6); | 183 | impl_pin!(P0_06, 0, 6); |
| 179 | impl_pin!(P0_07, 0, 7); | 184 | impl_pin!(P0_07, 0, 7); |
| 180 | impl_pin!(P0_08, 0, 8); | 185 | impl_pin!(P0_08, 0, 8); |
| 186 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 181 | impl_pin!(P0_09, 0, 9); | 187 | impl_pin!(P0_09, 0, 9); |
| 188 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 182 | impl_pin!(P0_10, 0, 10); | 189 | impl_pin!(P0_10, 0, 10); |
| 183 | impl_pin!(P0_11, 0, 11); | 190 | impl_pin!(P0_11, 0, 11); |
| 184 | impl_pin!(P0_12, 0, 12); | 191 | impl_pin!(P0_12, 0, 12); |
| @@ -190,6 +197,7 @@ impl_pin!(P0_17, 0, 17); | |||
| 190 | impl_pin!(P0_18, 0, 18); | 197 | impl_pin!(P0_18, 0, 18); |
| 191 | impl_pin!(P0_19, 0, 19); | 198 | impl_pin!(P0_19, 0, 19); |
| 192 | impl_pin!(P0_20, 0, 20); | 199 | impl_pin!(P0_20, 0, 20); |
| 200 | #[cfg(feature = "reset-pin-as-gpio")] | ||
| 193 | impl_pin!(P0_21, 0, 21); | 201 | impl_pin!(P0_21, 0, 21); |
| 194 | impl_pin!(P0_22, 0, 22); | 202 | impl_pin!(P0_22, 0, 22); |
| 195 | impl_pin!(P0_23, 0, 23); | 203 | impl_pin!(P0_23, 0, 23); |
diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs index a99ca6343..95f71ade7 100644 --- a/embassy-nrf/src/chips/nrf52833.rs +++ b/embassy-nrf/src/chips/nrf52833.rs | |||
| @@ -6,6 +6,8 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 512; | |||
| 6 | 6 | ||
| 7 | pub const FLASH_SIZE: usize = 512 * 1024; | 7 | pub const FLASH_SIZE: usize = 512 * 1024; |
| 8 | 8 | ||
| 9 | pub const RESET_PIN: u32 = 18; | ||
| 10 | |||
| 9 | embassy_hal_common::peripherals! { | 11 | embassy_hal_common::peripherals! { |
| 10 | // USB | 12 | // USB |
| 11 | USBD, | 13 | USBD, |
| @@ -111,7 +113,9 @@ embassy_hal_common::peripherals! { | |||
| 111 | P0_06, | 113 | P0_06, |
| 112 | P0_07, | 114 | P0_07, |
| 113 | P0_08, | 115 | P0_08, |
| 116 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 114 | P0_09, | 117 | P0_09, |
| 118 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 115 | P0_10, | 119 | P0_10, |
| 116 | P0_11, | 120 | P0_11, |
| 117 | P0_12, | 121 | P0_12, |
| @@ -120,6 +124,7 @@ embassy_hal_common::peripherals! { | |||
| 120 | P0_15, | 124 | P0_15, |
| 121 | P0_16, | 125 | P0_16, |
| 122 | P0_17, | 126 | P0_17, |
| 127 | #[cfg(feature="reset-pin-as-gpio")] | ||
| 123 | P0_18, | 128 | P0_18, |
| 124 | P0_19, | 129 | P0_19, |
| 125 | P0_20, | 130 | P0_20, |
| @@ -207,7 +212,9 @@ impl_pin!(P0_05, 0, 5); | |||
| 207 | impl_pin!(P0_06, 0, 6); | 212 | impl_pin!(P0_06, 0, 6); |
| 208 | impl_pin!(P0_07, 0, 7); | 213 | impl_pin!(P0_07, 0, 7); |
| 209 | impl_pin!(P0_08, 0, 8); | 214 | impl_pin!(P0_08, 0, 8); |
| 215 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 210 | impl_pin!(P0_09, 0, 9); | 216 | impl_pin!(P0_09, 0, 9); |
| 217 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 211 | impl_pin!(P0_10, 0, 10); | 218 | impl_pin!(P0_10, 0, 10); |
| 212 | impl_pin!(P0_11, 0, 11); | 219 | impl_pin!(P0_11, 0, 11); |
| 213 | impl_pin!(P0_12, 0, 12); | 220 | impl_pin!(P0_12, 0, 12); |
| @@ -216,6 +223,7 @@ impl_pin!(P0_14, 0, 14); | |||
| 216 | impl_pin!(P0_15, 0, 15); | 223 | impl_pin!(P0_15, 0, 15); |
| 217 | impl_pin!(P0_16, 0, 16); | 224 | impl_pin!(P0_16, 0, 16); |
| 218 | impl_pin!(P0_17, 0, 17); | 225 | impl_pin!(P0_17, 0, 17); |
| 226 | #[cfg(feature = "reset-pin-as-gpio")] | ||
| 219 | impl_pin!(P0_18, 0, 18); | 227 | impl_pin!(P0_18, 0, 18); |
| 220 | impl_pin!(P0_19, 0, 19); | 228 | impl_pin!(P0_19, 0, 19); |
| 221 | impl_pin!(P0_20, 0, 20); | 229 | impl_pin!(P0_20, 0, 20); |
diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs index 4f7463be2..5e7479e88 100644 --- a/embassy-nrf/src/chips/nrf52840.rs +++ b/embassy-nrf/src/chips/nrf52840.rs | |||
| @@ -6,6 +6,8 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 512; | |||
| 6 | 6 | ||
| 7 | pub const FLASH_SIZE: usize = 1024 * 1024; | 7 | pub const FLASH_SIZE: usize = 1024 * 1024; |
| 8 | 8 | ||
| 9 | pub const RESET_PIN: u32 = 18; | ||
| 10 | |||
| 9 | embassy_hal_common::peripherals! { | 11 | embassy_hal_common::peripherals! { |
| 10 | // USB | 12 | // USB |
| 11 | USBD, | 13 | USBD, |
| @@ -117,7 +119,9 @@ embassy_hal_common::peripherals! { | |||
| 117 | P0_06, | 119 | P0_06, |
| 118 | P0_07, | 120 | P0_07, |
| 119 | P0_08, | 121 | P0_08, |
| 122 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 120 | P0_09, | 123 | P0_09, |
| 124 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 121 | P0_10, | 125 | P0_10, |
| 122 | P0_11, | 126 | P0_11, |
| 123 | P0_12, | 127 | P0_12, |
| @@ -126,6 +130,7 @@ embassy_hal_common::peripherals! { | |||
| 126 | P0_15, | 130 | P0_15, |
| 127 | P0_16, | 131 | P0_16, |
| 128 | P0_17, | 132 | P0_17, |
| 133 | #[cfg(feature="reset-pin-as-gpio")] | ||
| 129 | P0_18, | 134 | P0_18, |
| 130 | P0_19, | 135 | P0_19, |
| 131 | P0_20, | 136 | P0_20, |
| @@ -212,7 +217,9 @@ impl_pin!(P0_05, 0, 5); | |||
| 212 | impl_pin!(P0_06, 0, 6); | 217 | impl_pin!(P0_06, 0, 6); |
| 213 | impl_pin!(P0_07, 0, 7); | 218 | impl_pin!(P0_07, 0, 7); |
| 214 | impl_pin!(P0_08, 0, 8); | 219 | impl_pin!(P0_08, 0, 8); |
| 220 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 215 | impl_pin!(P0_09, 0, 9); | 221 | impl_pin!(P0_09, 0, 9); |
| 222 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 216 | impl_pin!(P0_10, 0, 10); | 223 | impl_pin!(P0_10, 0, 10); |
| 217 | impl_pin!(P0_11, 0, 11); | 224 | impl_pin!(P0_11, 0, 11); |
| 218 | impl_pin!(P0_12, 0, 12); | 225 | impl_pin!(P0_12, 0, 12); |
| @@ -221,6 +228,7 @@ impl_pin!(P0_14, 0, 14); | |||
| 221 | impl_pin!(P0_15, 0, 15); | 228 | impl_pin!(P0_15, 0, 15); |
| 222 | impl_pin!(P0_16, 0, 16); | 229 | impl_pin!(P0_16, 0, 16); |
| 223 | impl_pin!(P0_17, 0, 17); | 230 | impl_pin!(P0_17, 0, 17); |
| 231 | #[cfg(feature = "reset-pin-as-gpio")] | ||
| 224 | impl_pin!(P0_18, 0, 18); | 232 | impl_pin!(P0_18, 0, 18); |
| 225 | impl_pin!(P0_19, 0, 19); | 233 | impl_pin!(P0_19, 0, 19); |
| 226 | impl_pin!(P0_20, 0, 20); | 234 | impl_pin!(P0_20, 0, 20); |
diff --git a/embassy-nrf/src/chips/nrf5340_app.rs b/embassy-nrf/src/chips/nrf5340_app.rs index c600fcbf6..2b8b55e77 100644 --- a/embassy-nrf/src/chips/nrf5340_app.rs +++ b/embassy-nrf/src/chips/nrf5340_app.rs | |||
| @@ -304,7 +304,9 @@ embassy_hal_common::peripherals! { | |||
| 304 | // GPIO port 0 | 304 | // GPIO port 0 |
| 305 | P0_00, | 305 | P0_00, |
| 306 | P0_01, | 306 | P0_01, |
| 307 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 307 | P0_02, | 308 | P0_02, |
| 309 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 308 | P0_03, | 310 | P0_03, |
| 309 | P0_04, | 311 | P0_04, |
| 310 | P0_05, | 312 | P0_05, |
| @@ -393,7 +395,9 @@ impl_timer!(TIMER2, TIMER2, TIMER2); | |||
| 393 | 395 | ||
| 394 | impl_pin!(P0_00, 0, 0); | 396 | impl_pin!(P0_00, 0, 0); |
| 395 | impl_pin!(P0_01, 0, 1); | 397 | impl_pin!(P0_01, 0, 1); |
| 398 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 396 | impl_pin!(P0_02, 0, 2); | 399 | impl_pin!(P0_02, 0, 2); |
| 400 | #[cfg(feature = "nfc-pins-as-gpio")] | ||
| 397 | impl_pin!(P0_03, 0, 3); | 401 | impl_pin!(P0_03, 0, 3); |
| 398 | impl_pin!(P0_04, 0, 4); | 402 | impl_pin!(P0_04, 0, 4); |
| 399 | impl_pin!(P0_05, 0, 5); | 403 | impl_pin!(P0_05, 0, 5); |
diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index 20e70a248..a9683df44 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs | |||
| @@ -24,6 +24,12 @@ | |||
| 24 | )))] | 24 | )))] |
| 25 | compile_error!("No chip feature activated. You must activate exactly one of the following features: nrf52810, nrf52811, nrf52832, nrf52833, nrf52840"); | 25 | compile_error!("No chip feature activated. You must activate exactly one of the following features: nrf52810, nrf52811, nrf52832, nrf52833, nrf52840"); |
| 26 | 26 | ||
| 27 | #[cfg(all(feature = "reset-pin-as-gpio", not(feature = "_nrf52")))] | ||
| 28 | compile_error!("feature `reset-pin-as-gpio` is only valid for nRF52 series chips."); | ||
| 29 | |||
| 30 | #[cfg(all(feature = "nfc-pins-as-gpio", not(any(feature = "_nrf52", feature = "_nrf5340-app"))))] | ||
| 31 | compile_error!("feature `nfc-pins-as-gpio` is only valid for nRF52, or nRF53's application core."); | ||
| 32 | |||
| 27 | // This mod MUST go first, so that the others see its macros. | 33 | // This mod MUST go first, so that the others see its macros. |
| 28 | pub(crate) mod fmt; | 34 | pub(crate) mod fmt; |
| 29 | pub(crate) mod util; | 35 | pub(crate) mod util; |
| @@ -139,6 +145,19 @@ pub mod config { | |||
| 139 | ExternalFullSwing, | 145 | ExternalFullSwing, |
| 140 | } | 146 | } |
| 141 | 147 | ||
| 148 | /// SWD access port protection setting. | ||
| 149 | #[non_exhaustive] | ||
| 150 | pub enum Debug { | ||
| 151 | /// Debugging is allowed (APPROTECT is disabled). Default. | ||
| 152 | Allowed, | ||
| 153 | /// Debugging is not allowed (APPROTECT is enabled). | ||
| 154 | Disallowed, | ||
| 155 | /// APPROTECT is not configured (neither to enable it or disable it). | ||
| 156 | /// This can be useful if you're already doing it by other means and | ||
| 157 | /// you don't want embassy-nrf to touch UICR. | ||
| 158 | NotConfigured, | ||
| 159 | } | ||
| 160 | |||
| 142 | /// Configuration for peripherals. Default configuration should work on any nRF chip. | 161 | /// Configuration for peripherals. Default configuration should work on any nRF chip. |
| 143 | #[non_exhaustive] | 162 | #[non_exhaustive] |
| 144 | pub struct Config { | 163 | pub struct Config { |
| @@ -152,6 +171,8 @@ pub mod config { | |||
| 152 | /// Time driver interrupt priority. Should be lower priority than softdevice if used. | 171 | /// Time driver interrupt priority. Should be lower priority than softdevice if used. |
| 153 | #[cfg(feature = "_time-driver")] | 172 | #[cfg(feature = "_time-driver")] |
| 154 | pub time_interrupt_priority: crate::interrupt::Priority, | 173 | pub time_interrupt_priority: crate::interrupt::Priority, |
| 174 | /// Enable or disable the debug port. | ||
| 175 | pub debug: Debug, | ||
| 155 | } | 176 | } |
| 156 | 177 | ||
| 157 | impl Default for Config { | 178 | impl Default for Config { |
| @@ -166,17 +187,204 @@ pub mod config { | |||
| 166 | gpiote_interrupt_priority: crate::interrupt::Priority::P0, | 187 | gpiote_interrupt_priority: crate::interrupt::Priority::P0, |
| 167 | #[cfg(feature = "_time-driver")] | 188 | #[cfg(feature = "_time-driver")] |
| 168 | time_interrupt_priority: crate::interrupt::Priority::P0, | 189 | time_interrupt_priority: crate::interrupt::Priority::P0, |
| 190 | |||
| 191 | // In NS mode, default to NotConfigured, assuming the S firmware will do it. | ||
| 192 | #[cfg(feature = "_ns")] | ||
| 193 | debug: Debug::NotConfigured, | ||
| 194 | #[cfg(not(feature = "_ns"))] | ||
| 195 | debug: Debug::Allowed, | ||
| 169 | } | 196 | } |
| 170 | } | 197 | } |
| 171 | } | 198 | } |
| 172 | } | 199 | } |
| 173 | 200 | ||
| 201 | #[cfg(feature = "_nrf9160")] | ||
| 202 | #[allow(unused)] | ||
| 203 | mod consts { | ||
| 204 | pub const UICR_APPROTECT: *mut u32 = 0x00FF8000 as *mut u32; | ||
| 205 | pub const UICR_SECUREAPPROTECT: *mut u32 = 0x00FF802C as *mut u32; | ||
| 206 | pub const APPROTECT_ENABLED: u32 = 0x0000_0000; | ||
| 207 | } | ||
| 208 | |||
| 209 | #[cfg(feature = "_nrf5340-app")] | ||
| 210 | #[allow(unused)] | ||
| 211 | mod consts { | ||
| 212 | pub const UICR_APPROTECT: *mut u32 = 0x00FF8000 as *mut u32; | ||
| 213 | pub const UICR_SECUREAPPROTECT: *mut u32 = 0x00FF801C as *mut u32; | ||
| 214 | pub const UICR_NFCPINS: *mut u32 = 0x00FF8028 as *mut u32; | ||
| 215 | pub const APPROTECT_ENABLED: u32 = 0x0000_0000; | ||
| 216 | pub const APPROTECT_DISABLED: u32 = 0x50FA50FA; | ||
| 217 | } | ||
| 218 | |||
| 219 | #[cfg(feature = "_nrf5340-net")] | ||
| 220 | #[allow(unused)] | ||
| 221 | mod consts { | ||
| 222 | pub const UICR_APPROTECT: *mut u32 = 0x01FF8000 as *mut u32; | ||
| 223 | pub const APPROTECT_ENABLED: u32 = 0x0000_0000; | ||
| 224 | pub const APPROTECT_DISABLED: u32 = 0x50FA50FA; | ||
| 225 | } | ||
| 226 | |||
| 227 | #[cfg(feature = "_nrf52")] | ||
| 228 | #[allow(unused)] | ||
| 229 | mod consts { | ||
| 230 | pub const UICR_PSELRESET1: *mut u32 = 0x10001200 as *mut u32; | ||
| 231 | pub const UICR_PSELRESET2: *mut u32 = 0x10001204 as *mut u32; | ||
| 232 | pub const UICR_NFCPINS: *mut u32 = 0x1000120C as *mut u32; | ||
| 233 | pub const UICR_APPROTECT: *mut u32 = 0x10001208 as *mut u32; | ||
| 234 | pub const APPROTECT_ENABLED: u32 = 0x0000_0000; | ||
| 235 | pub const APPROTECT_DISABLED: u32 = 0x0000_005a; | ||
| 236 | } | ||
| 237 | |||
| 238 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
| 239 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 240 | enum WriteResult { | ||
| 241 | /// Word was written successfully, needs reset. | ||
| 242 | Written, | ||
| 243 | /// Word was already set to the value we wanted to write, nothing was done. | ||
| 244 | Noop, | ||
| 245 | /// Word is already set to something else, we couldn't write the desired value. | ||
| 246 | Failed, | ||
| 247 | } | ||
| 248 | |||
| 249 | unsafe fn uicr_write(address: *mut u32, value: u32) -> WriteResult { | ||
| 250 | let curr_val = address.read_volatile(); | ||
| 251 | if curr_val == value { | ||
| 252 | return WriteResult::Noop; | ||
| 253 | } | ||
| 254 | |||
| 255 | // We can only change `1` bits to `0` bits. | ||
| 256 | if curr_val & value != value { | ||
| 257 | return WriteResult::Failed; | ||
| 258 | } | ||
| 259 | |||
| 260 | // Writing to UICR can only change `1` bits to `0` bits. | ||
| 261 | // If this write would change `0` bits to `1` bits, we can't do it. | ||
| 262 | // It is only possible to do when erasing UICR, which is forbidden if | ||
| 263 | // APPROTECT is enabled. | ||
| 264 | if (!curr_val) & value != 0 { | ||
| 265 | panic!("Cannot write UICR address={:08x} value={:08x}", address as u32, value) | ||
| 266 | } | ||
| 267 | |||
| 268 | let nvmc = &*pac::NVMC::ptr(); | ||
| 269 | nvmc.config.write(|w| w.wen().wen()); | ||
| 270 | while nvmc.ready.read().ready().is_busy() {} | ||
| 271 | address.write_volatile(value); | ||
| 272 | while nvmc.ready.read().ready().is_busy() {} | ||
| 273 | nvmc.config.reset(); | ||
| 274 | while nvmc.ready.read().ready().is_busy() {} | ||
| 275 | |||
| 276 | WriteResult::Written | ||
| 277 | } | ||
| 278 | |||
| 174 | /// Initialize peripherals with the provided configuration. This should only be called once at startup. | 279 | /// Initialize peripherals with the provided configuration. This should only be called once at startup. |
| 175 | pub fn init(config: config::Config) -> Peripherals { | 280 | pub fn init(config: config::Config) -> Peripherals { |
| 176 | // Do this first, so that it panics if user is calling `init` a second time | 281 | // Do this first, so that it panics if user is calling `init` a second time |
| 177 | // before doing anything important. | 282 | // before doing anything important. |
| 178 | let peripherals = Peripherals::take(); | 283 | let peripherals = Peripherals::take(); |
| 179 | 284 | ||
| 285 | let mut needs_reset = false; | ||
| 286 | |||
| 287 | // Setup debug protection. | ||
| 288 | match config.debug { | ||
| 289 | config::Debug::Allowed => { | ||
| 290 | #[cfg(feature = "_nrf52")] | ||
| 291 | unsafe { | ||
| 292 | let variant = (0x1000_0104 as *mut u32).read_volatile(); | ||
| 293 | // Get the letter for the build code (b'A' .. b'F') | ||
| 294 | let build_code = (variant >> 8) as u8; | ||
| 295 | |||
| 296 | if build_code >= b'F' { | ||
| 297 | // Chips with build code F and higher (revision 3 and higher) have an | ||
| 298 | // improved APPROTECT ("hardware and software controlled access port protection") | ||
| 299 | // which needs explicit action by the firmware to keep it unlocked | ||
| 300 | |||
| 301 | // UICR.APPROTECT = SwDisabled | ||
| 302 | let res = uicr_write(consts::UICR_APPROTECT, consts::APPROTECT_DISABLED); | ||
| 303 | needs_reset |= res == WriteResult::Written; | ||
| 304 | // APPROTECT.DISABLE = SwDisabled | ||
| 305 | (0x4000_0558 as *mut u32).write_volatile(consts::APPROTECT_DISABLED); | ||
| 306 | } else { | ||
| 307 | // nothing to do on older chips, debug is allowed by default. | ||
| 308 | } | ||
| 309 | } | ||
| 310 | |||
| 311 | #[cfg(feature = "_nrf5340")] | ||
| 312 | unsafe { | ||
| 313 | let p = &*pac::CTRLAP::ptr(); | ||
| 314 | |||
| 315 | let res = uicr_write(consts::UICR_APPROTECT, consts::APPROTECT_DISABLED); | ||
| 316 | needs_reset |= res == WriteResult::Written; | ||
| 317 | p.approtect.disable.write(|w| w.bits(consts::APPROTECT_DISABLED)); | ||
| 318 | |||
| 319 | #[cfg(feature = "_nrf5340-app")] | ||
| 320 | { | ||
| 321 | let res = uicr_write(consts::UICR_SECUREAPPROTECT, consts::APPROTECT_DISABLED); | ||
| 322 | needs_reset |= res == WriteResult::Written; | ||
| 323 | p.secureapprotect.disable.write(|w| w.bits(consts::APPROTECT_DISABLED)); | ||
| 324 | } | ||
| 325 | } | ||
| 326 | |||
| 327 | // nothing to do on the nrf9160, debug is allowed by default. | ||
| 328 | } | ||
| 329 | config::Debug::Disallowed => unsafe { | ||
| 330 | // UICR.APPROTECT = Enabled | ||
| 331 | let res = uicr_write(consts::UICR_APPROTECT, consts::APPROTECT_ENABLED); | ||
| 332 | needs_reset |= res == WriteResult::Written; | ||
| 333 | #[cfg(any(feature = "_nrf5340-app", feature = "_nrf9160"))] | ||
| 334 | { | ||
| 335 | let res = uicr_write(consts::UICR_SECUREAPPROTECT, consts::APPROTECT_ENABLED); | ||
| 336 | needs_reset |= res == WriteResult::Written; | ||
| 337 | } | ||
| 338 | }, | ||
| 339 | config::Debug::NotConfigured => {} | ||
| 340 | } | ||
| 341 | |||
| 342 | #[cfg(feature = "_nrf52")] | ||
| 343 | unsafe { | ||
| 344 | let value = if cfg!(feature = "reset-pin-as-gpio") { | ||
| 345 | !0 | ||
| 346 | } else { | ||
| 347 | chip::RESET_PIN | ||
| 348 | }; | ||
| 349 | let res1 = uicr_write(consts::UICR_PSELRESET1, value); | ||
| 350 | let res2 = uicr_write(consts::UICR_PSELRESET2, value); | ||
| 351 | needs_reset |= res1 == WriteResult::Written || res2 == WriteResult::Written; | ||
| 352 | if res1 == WriteResult::Failed || res2 == WriteResult::Failed { | ||
| 353 | #[cfg(not(feature = "reset-pin-as-gpio"))] | ||
| 354 | warn!( | ||
| 355 | "You have requested enabling chip reset functionality on the reset pin, by not enabling the Cargo feature `reset-pin-as-gpio`.\n\ | ||
| 356 | However, UICR is already programmed to some other setting, and can't be changed without erasing it.\n\ | ||
| 357 | To fix this, erase UICR manually, for example using `probe-rs-cli erase` or `nrfjprog --eraseuicr`." | ||
| 358 | ); | ||
| 359 | #[cfg(feature = "reset-pin-as-gpio")] | ||
| 360 | warn!( | ||
| 361 | "You have requested using the reset pin as GPIO, by enabling the Cargo feature `reset-pin-as-gpio`.\n\ | ||
| 362 | However, UICR is already programmed to some other setting, and can't be changed without erasing it.\n\ | ||
| 363 | To fix this, erase UICR manually, for example using `probe-rs-cli erase` or `nrfjprog --eraseuicr`." | ||
| 364 | ); | ||
| 365 | } | ||
| 366 | } | ||
| 367 | |||
| 368 | #[cfg(any(feature = "_nrf52", feature = "_nrf5340-app"))] | ||
| 369 | unsafe { | ||
| 370 | let value = if cfg!(feature = "nfc-pins-as-gpio") { 0 } else { !0 }; | ||
| 371 | let res = uicr_write(consts::UICR_NFCPINS, value); | ||
| 372 | needs_reset |= res == WriteResult::Written; | ||
| 373 | if res == WriteResult::Failed { | ||
| 374 | // with nfc-pins-as-gpio, this can never fail because we're writing all zero bits. | ||
| 375 | #[cfg(not(feature = "nfc-pins-as-gpio"))] | ||
| 376 | warn!( | ||
| 377 | "You have requested to use P0.09 and P0.10 pins for NFC, by not enabling the Cargo feature `nfc-pins-as-gpio`.\n\ | ||
| 378 | However, UICR is already programmed to some other setting, and can't be changed without erasing it.\n\ | ||
| 379 | To fix this, erase UICR manually, for example using `probe-rs-cli erase` or `nrfjprog --eraseuicr`." | ||
| 380 | ); | ||
| 381 | } | ||
| 382 | } | ||
| 383 | |||
| 384 | if needs_reset { | ||
| 385 | cortex_m::peripheral::SCB::sys_reset(); | ||
| 386 | } | ||
| 387 | |||
| 180 | let r = unsafe { &*pac::CLOCK::ptr() }; | 388 | let r = unsafe { &*pac::CLOCK::ptr() }; |
| 181 | 389 | ||
| 182 | // Start HFCLK. | 390 | // Start HFCLK. |
diff --git a/embassy-nrf/src/nvmc.rs b/embassy-nrf/src/nvmc.rs index c1ffa31aa..6f48853d5 100644 --- a/embassy-nrf/src/nvmc.rs +++ b/embassy-nrf/src/nvmc.rs | |||
| @@ -85,23 +85,23 @@ impl<'d> Nvmc<'d> { | |||
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | fn enable_erase(&self) { | 87 | fn enable_erase(&self) { |
| 88 | #[cfg(not(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns")))] | 88 | #[cfg(not(feature = "_ns"))] |
| 89 | Self::regs().config.write(|w| w.wen().een()); | 89 | Self::regs().config.write(|w| w.wen().een()); |
| 90 | #[cfg(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns"))] | 90 | #[cfg(feature = "_ns")] |
| 91 | Self::regs().configns.write(|w| w.wen().een()); | 91 | Self::regs().configns.write(|w| w.wen().een()); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | fn enable_read(&self) { | 94 | fn enable_read(&self) { |
| 95 | #[cfg(not(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns")))] | 95 | #[cfg(not(feature = "_ns"))] |
| 96 | Self::regs().config.write(|w| w.wen().ren()); | 96 | Self::regs().config.write(|w| w.wen().ren()); |
| 97 | #[cfg(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns"))] | 97 | #[cfg(feature = "_ns")] |
| 98 | Self::regs().configns.write(|w| w.wen().ren()); | 98 | Self::regs().configns.write(|w| w.wen().ren()); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | fn enable_write(&self) { | 101 | fn enable_write(&self) { |
| 102 | #[cfg(not(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns")))] | 102 | #[cfg(not(feature = "_ns"))] |
| 103 | Self::regs().config.write(|w| w.wen().wen()); | 103 | Self::regs().config.write(|w| w.wen().wen()); |
| 104 | #[cfg(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns"))] | 104 | #[cfg(feature = "_ns")] |
| 105 | Self::regs().configns.write(|w| w.wen().wen()); | 105 | Self::regs().configns.write(|w| w.wen().wen()); |
| 106 | } | 106 | } |
| 107 | } | 107 | } |
