Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add System Off and Wake on Field #3645

Merged
merged 5 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions embassy-nrf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
22 changes: 22 additions & 0 deletions embassy-nrf/src/power.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//! Power

#[cfg(feature = "nrf52840")]
use crate::chip::pac::NFCT;
#[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));
}

/// Wake the system if there if an NFC field close to the nrf52840's antenna
#[cfg(feature = "nrf52840")]
pub fn wake_on_nfc_sense() {
wackazong marked this conversation as resolved.
Show resolved Hide resolved
NFCT.tasks_sense().write_value(0x01);
}