diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-12-15 11:01:02 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-12-15 11:01:02 +0000 |
| commit | c84996df8a8f56404f5b57264383e1f53a912510 (patch) | |
| tree | 9b8d72593a6d91f58b8f5a253bc24b8a931d4c86 | |
| parent | 63cc5ce61eac4d2d6477884692d0b2d45cee8033 (diff) | |
| parent | ea374a47368fb917e6a89b0bc567a225778f4f9f (diff) | |
Merge pull request #3645 from wackazong/power-wake-on-field
Add System Off and Wake on Field
| -rw-r--r-- | embassy-nrf/src/lib.rs | 3 | ||||
| -rw-r--r-- | embassy-nrf/src/nfct.rs | 6 | ||||
| -rw-r--r-- | embassy-nrf/src/power.rs | 14 |
3 files changed, 23 insertions, 0 deletions
diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index e7ec4eb9d..ec5e9f864 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs | |||
| @@ -107,6 +107,9 @@ pub mod nvmc; | |||
| 107 | ))] | 107 | ))] |
| 108 | pub mod pdm; | 108 | pub mod pdm; |
| 109 | #[cfg(not(feature = "_nrf54l"))] // TODO | 109 | #[cfg(not(feature = "_nrf54l"))] // TODO |
| 110 | #[cfg(any(feature = "nrf52840", feature = "nrf9160-s", feature = "nrf9160-ns"))] | ||
| 111 | pub mod power; | ||
| 112 | #[cfg(not(feature = "_nrf54l"))] // TODO | ||
| 110 | pub mod ppi; | 113 | pub mod ppi; |
| 111 | #[cfg(not(feature = "_nrf54l"))] // TODO | 114 | #[cfg(not(feature = "_nrf54l"))] // TODO |
| 112 | #[cfg(not(any( | 115 | #[cfg(not(any( |
diff --git a/embassy-nrf/src/nfct.rs b/embassy-nrf/src/nfct.rs index cbd3920ee..8b4b6dfe0 100644 --- a/embassy-nrf/src/nfct.rs +++ b/embassy-nrf/src/nfct.rs | |||
| @@ -19,6 +19,7 @@ pub use vals::{Bitframesdd as SddPat, Discardmode as DiscardMode}; | |||
| 19 | 19 | ||
| 20 | use crate::interrupt::InterruptExt; | 20 | use crate::interrupt::InterruptExt; |
| 21 | use crate::pac::nfct::vals; | 21 | use crate::pac::nfct::vals; |
| 22 | use crate::pac::NFCT; | ||
| 22 | use crate::peripherals::NFCT; | 23 | use crate::peripherals::NFCT; |
| 23 | use crate::util::slice_in_ram; | 24 | use crate::util::slice_in_ram; |
| 24 | use crate::{interrupt, pac, Peripheral}; | 25 | use crate::{interrupt, pac, Peripheral}; |
| @@ -420,3 +421,8 @@ impl<'d> NfcT<'d> { | |||
| 420 | Ok(n) | 421 | Ok(n) |
| 421 | } | 422 | } |
| 422 | } | 423 | } |
| 424 | |||
| 425 | /// Wake the system if there if an NFC field close to the antenna | ||
| 426 | pub fn wake_on_nfc_sense() { | ||
| 427 | NFCT.tasks_sense().write_value(0x01); | ||
| 428 | } | ||
diff --git a/embassy-nrf/src/power.rs b/embassy-nrf/src/power.rs new file mode 100644 index 000000000..f93bf8f49 --- /dev/null +++ b/embassy-nrf/src/power.rs | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | //! Power | ||
| 2 | |||
| 3 | #[cfg(feature = "nrf52840")] | ||
| 4 | use crate::chip::pac::POWER; | ||
| 5 | #[cfg(any(feature = "nrf9160-s", feature = "nrf9160-ns"))] | ||
| 6 | use crate::chip::pac::REGULATORS; | ||
| 7 | |||
| 8 | /// Puts the MCU into "System Off" mode with minimal power usage | ||
| 9 | pub fn set_system_off() { | ||
| 10 | #[cfg(feature = "nrf52840")] | ||
| 11 | POWER.systemoff().write(|w| w.set_systemoff(true)); | ||
| 12 | #[cfg(any(feature = "nrf9160-s", feature = "nrf9160-ns"))] | ||
| 13 | REGULATORS.systemoff().write(|w| w.set_systemoff(true)); | ||
| 14 | } | ||
