aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-12-15 11:01:02 +0000
committerGitHub <[email protected]>2024-12-15 11:01:02 +0000
commitc84996df8a8f56404f5b57264383e1f53a912510 (patch)
tree9b8d72593a6d91f58b8f5a253bc24b8a931d4c86
parent63cc5ce61eac4d2d6477884692d0b2d45cee8033 (diff)
parentea374a47368fb917e6a89b0bc567a225778f4f9f (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.rs3
-rw-r--r--embassy-nrf/src/nfct.rs6
-rw-r--r--embassy-nrf/src/power.rs14
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))]
108pub mod pdm; 108pub 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"))]
111pub mod power;
112#[cfg(not(feature = "_nrf54l"))] // TODO
110pub mod ppi; 113pub 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
20use crate::interrupt::InterruptExt; 20use crate::interrupt::InterruptExt;
21use crate::pac::nfct::vals; 21use crate::pac::nfct::vals;
22use crate::pac::NFCT;
22use crate::peripherals::NFCT; 23use crate::peripherals::NFCT;
23use crate::util::slice_in_ram; 24use crate::util::slice_in_ram;
24use crate::{interrupt, pac, Peripheral}; 25use 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
426pub 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")]
4use crate::chip::pac::POWER;
5#[cfg(any(feature = "nrf9160-s", feature = "nrf9160-ns"))]
6use crate::chip::pac::REGULATORS;
7
8/// Puts the MCU into "System Off" mode with minimal power usage
9pub 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}