diff options
| author | Karun Koppula <[email protected]> | 2024-04-02 15:51:50 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-04-02 15:51:50 -0400 |
| commit | 9344f55ff3107917ce1b765bc4fa57965ec86ca6 (patch) | |
| tree | 4ca4936f84d4ad9ecf85a0129159b6d6d20c53cd /embassy-nrf/src | |
| parent | 2caea89b6ab9859470ccf6c7d7414c01251bbecd (diff) | |
| parent | 990f2717673de5e6de6be6a9fb001bc0c8d34745 (diff) | |
Merge branch 'main' into karun/main_octospi_implementation
Diffstat (limited to 'embassy-nrf/src')
| -rw-r--r-- | embassy-nrf/src/fmt.rs | 3 | ||||
| -rw-r--r-- | embassy-nrf/src/gpio.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/lib.rs | 39 | ||||
| -rw-r--r-- | embassy-nrf/src/timer.rs | 2 |
5 files changed, 44 insertions, 4 deletions
diff --git a/embassy-nrf/src/fmt.rs b/embassy-nrf/src/fmt.rs index 78e583c1c..2ac42c557 100644 --- a/embassy-nrf/src/fmt.rs +++ b/embassy-nrf/src/fmt.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | 4 | use core::fmt::{Debug, Display, LowerHex}; |
| 5 | 5 | ||
| @@ -229,7 +229,6 @@ impl<T, E> Try for Result<T, E> { | |||
| 229 | } | 229 | } |
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | 232 | pub(crate) struct Bytes<'a>(pub &'a [u8]); |
| 234 | 233 | ||
| 235 | impl<'a> Debug for Bytes<'a> { | 234 | impl<'a> Debug for Bytes<'a> { |
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index 3649ea61a..f2353f21d 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs | |||
| @@ -473,10 +473,12 @@ impl sealed::Pin for AnyPin { | |||
| 473 | 473 | ||
| 474 | // ==================== | 474 | // ==================== |
| 475 | 475 | ||
| 476 | #[cfg(not(feature = "_nrf51"))] | ||
| 476 | pub(crate) trait PselBits { | 477 | pub(crate) trait PselBits { |
| 477 | fn psel_bits(&self) -> u32; | 478 | fn psel_bits(&self) -> u32; |
| 478 | } | 479 | } |
| 479 | 480 | ||
| 481 | #[cfg(not(feature = "_nrf51"))] | ||
| 480 | impl<'a, P: Pin> PselBits for Option<PeripheralRef<'a, P>> { | 482 | impl<'a, P: Pin> PselBits for Option<PeripheralRef<'a, P>> { |
| 481 | #[inline] | 483 | #[inline] |
| 482 | fn psel_bits(&self) -> u32 { | 484 | fn psel_bits(&self) -> u32 { |
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 12f4ed0a0..4a28279a9 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -167,8 +167,10 @@ unsafe fn handle_gpiote_interrupt() { | |||
| 167 | } | 167 | } |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | #[cfg(not(feature = "_nrf51"))] | ||
| 170 | struct BitIter(u32); | 171 | struct BitIter(u32); |
| 171 | 172 | ||
| 173 | #[cfg(not(feature = "_nrf51"))] | ||
| 172 | impl Iterator for BitIter { | 174 | impl Iterator for BitIter { |
| 173 | type Item = u32; | 175 | type Item = u32; |
| 174 | 176 | ||
diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index 718f229a3..3457dd933 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs | |||
| @@ -225,10 +225,31 @@ pub mod config { | |||
| 225 | /// Config for the first stage DCDC (VDDH -> VDD), if disabled LDO will be used. | 225 | /// Config for the first stage DCDC (VDDH -> VDD), if disabled LDO will be used. |
| 226 | #[cfg(feature = "nrf52840")] | 226 | #[cfg(feature = "nrf52840")] |
| 227 | pub reg0: bool, | 227 | pub reg0: bool, |
| 228 | /// Configure the voltage of the first stage DCDC. It is stored in non-volatile memory (UICR.REGOUT0 register); pass None to not touch it. | ||
| 229 | #[cfg(feature = "nrf52840")] | ||
| 230 | pub reg0_voltage: Option<Reg0Voltage>, | ||
| 228 | /// Config for the second stage DCDC (VDD -> DEC4), if disabled LDO will be used. | 231 | /// Config for the second stage DCDC (VDD -> DEC4), if disabled LDO will be used. |
| 229 | pub reg1: bool, | 232 | pub reg1: bool, |
| 230 | } | 233 | } |
| 231 | 234 | ||
| 235 | /// Output voltage setting for REG0 regulator stage. | ||
| 236 | #[cfg(feature = "nrf52840")] | ||
| 237 | pub enum Reg0Voltage { | ||
| 238 | /// 1.8 V | ||
| 239 | _1V8 = 0, | ||
| 240 | /// 2.1 V | ||
| 241 | _2V1 = 1, | ||
| 242 | /// 2.4 V | ||
| 243 | _2V4 = 2, | ||
| 244 | /// 2.7 V | ||
| 245 | _2V7 = 3, | ||
| 246 | /// 3.0 V | ||
| 247 | _3V0 = 4, | ||
| 248 | /// 3.3 V | ||
| 249 | _3v3 = 5, | ||
| 250 | //ERASED = 7, means 1.8V | ||
| 251 | } | ||
| 252 | |||
| 232 | /// Settings for enabling the built in DCDC converters. | 253 | /// Settings for enabling the built in DCDC converters. |
| 233 | #[cfg(feature = "_nrf5340-app")] | 254 | #[cfg(feature = "_nrf5340-app")] |
| 234 | pub struct DcdcConfig { | 255 | pub struct DcdcConfig { |
| @@ -279,6 +300,8 @@ pub mod config { | |||
| 279 | dcdc: DcdcConfig { | 300 | dcdc: DcdcConfig { |
| 280 | #[cfg(feature = "nrf52840")] | 301 | #[cfg(feature = "nrf52840")] |
| 281 | reg0: false, | 302 | reg0: false, |
| 303 | #[cfg(feature = "nrf52840")] | ||
| 304 | reg0_voltage: None, | ||
| 282 | reg1: false, | 305 | reg1: false, |
| 283 | }, | 306 | }, |
| 284 | #[cfg(feature = "_nrf5340-app")] | 307 | #[cfg(feature = "_nrf5340-app")] |
| @@ -337,6 +360,7 @@ mod consts { | |||
| 337 | pub const UICR_PSELRESET2: *mut u32 = 0x10001204 as *mut u32; | 360 | pub const UICR_PSELRESET2: *mut u32 = 0x10001204 as *mut u32; |
| 338 | pub const UICR_NFCPINS: *mut u32 = 0x1000120C as *mut u32; | 361 | pub const UICR_NFCPINS: *mut u32 = 0x1000120C as *mut u32; |
| 339 | pub const UICR_APPROTECT: *mut u32 = 0x10001208 as *mut u32; | 362 | pub const UICR_APPROTECT: *mut u32 = 0x10001208 as *mut u32; |
| 363 | pub const UICR_REGOUT0: *mut u32 = 0x10001304 as *mut u32; | ||
| 340 | pub const APPROTECT_ENABLED: u32 = 0x0000_0000; | 364 | pub const APPROTECT_ENABLED: u32 = 0x0000_0000; |
| 341 | pub const APPROTECT_DISABLED: u32 = 0x0000_005a; | 365 | pub const APPROTECT_DISABLED: u32 = 0x0000_005a; |
| 342 | } | 366 | } |
| @@ -493,6 +517,21 @@ pub fn init(config: config::Config) -> Peripherals { | |||
| 493 | } | 517 | } |
| 494 | } | 518 | } |
| 495 | 519 | ||
| 520 | #[cfg(feature = "nrf52840")] | ||
| 521 | unsafe { | ||
| 522 | if let Some(value) = config.dcdc.reg0_voltage { | ||
| 523 | let value = value as u32; | ||
| 524 | let res = uicr_write_masked(consts::UICR_REGOUT0, value, 0b00000000_00000000_00000000_00000111); | ||
| 525 | needs_reset |= res == WriteResult::Written; | ||
| 526 | if res == WriteResult::Failed { | ||
| 527 | warn!( | ||
| 528 | "Failed to set regulator voltage, as UICR is already programmed to some other setting, and can't be changed without erasing it.\n\ | ||
| 529 | To fix this, erase UICR manually, for example using `probe-rs erase` or `nrfjprog --eraseuicr`." | ||
| 530 | ); | ||
| 531 | } | ||
| 532 | } | ||
| 533 | } | ||
| 534 | |||
| 496 | if needs_reset { | 535 | if needs_reset { |
| 497 | cortex_m::peripheral::SCB::sys_reset(); | 536 | cortex_m::peripheral::SCB::sys_reset(); |
| 498 | } | 537 | } |
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs index 3c35baee5..2970ad3f2 100644 --- a/embassy-nrf/src/timer.rs +++ b/embassy-nrf/src/timer.rs | |||
| @@ -21,8 +21,6 @@ pub(crate) mod sealed { | |||
| 21 | fn regs() -> &'static pac::timer0::RegisterBlock; | 21 | fn regs() -> &'static pac::timer0::RegisterBlock; |
| 22 | } | 22 | } |
| 23 | pub trait ExtendedInstance {} | 23 | pub trait ExtendedInstance {} |
| 24 | |||
| 25 | pub trait TimerType {} | ||
| 26 | } | 24 | } |
| 27 | 25 | ||
| 28 | /// Basic Timer instance. | 26 | /// Basic Timer instance. |
