Skip to content

Commit

Permalink
Merge pull request #3645 from wackazong/power-wake-on-field
Browse files Browse the repository at this point in the history
Add System Off and Wake on Field
  • Loading branch information
Dirbaio authored Dec 15, 2024
2 parents 63cc5ce + ea374a4 commit c84996d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
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
6 changes: 6 additions & 0 deletions embassy-nrf/src/nfct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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 changes: 14 additions & 0 deletions embassy-nrf/src/power.rs
Original file line number Diff line number Diff line change
@@ -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));
}

0 comments on commit c84996d

Please sign in to comment.