Merge pull request #3645 from wackazong/power-wake-on-field

Add System Off and Wake on Field
This commit is contained in:
Dario Nieuwenhuis 2024-12-15 11:01:02 +00:00 committed by GitHub
commit c84996df8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 0 deletions

View File

@ -107,6 +107,9 @@ pub mod nvmc;
))]
pub mod pdm;
#[cfg(not(feature = "_nrf54l"))] // TODO
#[cfg(any(feature = "nrf52840", feature = "nrf9160-s", feature = "nrf9160-ns"))]
pub mod power;
#[cfg(not(feature = "_nrf54l"))] // TODO
pub mod ppi;
#[cfg(not(feature = "_nrf54l"))] // TODO
#[cfg(not(any(

View File

@ -19,6 +19,7 @@ pub use vals::{Bitframesdd as SddPat, Discardmode as DiscardMode};
use crate::interrupt::InterruptExt;
use crate::pac::nfct::vals;
use crate::pac::NFCT;
use crate::peripherals::NFCT;
use crate::util::slice_in_ram;
use crate::{interrupt, pac, Peripheral};
@ -420,3 +421,8 @@ impl<'d> NfcT<'d> {
Ok(n)
}
}
/// Wake the system if there if an NFC field close to the antenna
pub fn wake_on_nfc_sense() {
NFCT.tasks_sense().write_value(0x01);
}

14
embassy-nrf/src/power.rs Normal file
View File

@ -0,0 +1,14 @@
//! Power
#[cfg(feature = "nrf52840")]
use crate::chip::pac::POWER;
#[cfg(any(feature = "nrf9160-s", feature = "nrf9160-ns"))]
use crate::chip::pac::REGULATORS;
/// Puts the MCU into "System Off" mode with minimal power usage
pub fn set_system_off() {
#[cfg(feature = "nrf52840")]
POWER.systemoff().write(|w| w.set_systemoff(true));
#[cfg(any(feature = "nrf9160-s", feature = "nrf9160-ns"))]
REGULATORS.systemoff().write(|w| w.set_systemoff(true));
}