Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion embassy-nrf/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- changed: Remove `T: Instance` generic params in all drivers.
- changed: nrf54l: Disable glitch detection and enable DC/DC in init.
- changed: Add embassy-net-driver-channel implementation for IEEE 802.15.4
- changed: add persist() method for gpio and ppi
- added: basic RTC driver
- changed: add persist() method for gpio, gpiote, timer and ppi
- changed: impl Drop for Timer
- added: expose `regs` for timer driver
- added: timer driver CC `clear_events` method
- added: expose `regs` for all peripherals

## 0.7.0 - 2025-08-26

Expand Down
9 changes: 9 additions & 0 deletions embassy-nrf/src/egu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ impl<'d> Egu<'d> {
}

pub(crate) trait SealedInstance {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::egu::Egu;
}

Expand All @@ -46,17 +47,25 @@ pub(crate) trait SealedInstance {
pub trait Instance: SealedInstance + PeripheralType + 'static + Send {
/// Interrupt for this peripheral.
type Interrupt: interrupt::typelevel::Interrupt;
/// Direct access to the register block.
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::egu::Egu;
}

macro_rules! impl_egu {
($type:ident, $pac_type:ident, $irq:ident) => {
impl crate::egu::SealedInstance for peripherals::$type {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::egu::Egu {
pac::$pac_type
}
}
impl crate::egu::Instance for peripherals::$type {
type Interrupt = crate::interrupt::typelevel::$irq;
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::egu::Egu {
pac::$pac_type
}
}
};
}
Expand Down
9 changes: 9 additions & 0 deletions embassy-nrf/src/i2s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,7 @@ impl State {
}

pub(crate) trait SealedInstance {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::i2s::I2s;
fn state() -> &'static State;
}
Expand All @@ -1169,11 +1170,15 @@ pub(crate) trait SealedInstance {
pub trait Instance: SealedInstance + PeripheralType + 'static + Send {
/// Interrupt for this peripheral.
type Interrupt: interrupt::typelevel::Interrupt;
/// Direct access to the register block.
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::i2s::I2s;
}

macro_rules! impl_i2s {
($type:ident, $pac_type:ident, $irq:ident) => {
impl crate::i2s::SealedInstance for peripherals::$type {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::i2s::I2s {
pac::$pac_type
}
Expand All @@ -1184,6 +1189,10 @@ macro_rules! impl_i2s {
}
impl crate::i2s::Instance for peripherals::$type {
type Interrupt = crate::interrupt::typelevel::$irq;
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::i2s::I2s {
pac::$pac_type
}
}
};
}
9 changes: 9 additions & 0 deletions embassy-nrf/src/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ impl State {
}

pub(crate) trait SealedInstance {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::ipc::Ipc;
fn state() -> &'static State;
}
Expand All @@ -350,11 +351,15 @@ pub(crate) trait SealedInstance {
pub trait Instance: PeripheralType + SealedInstance + 'static + Send {
/// Interrupt for this peripheral.
type Interrupt: interrupt::typelevel::Interrupt;
/// Direct access to the register block.
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::ipc::Ipc;
}

macro_rules! impl_ipc {
($type:ident, $pac_type:ident, $irq:ident) => {
impl crate::ipc::SealedInstance for peripherals::$type {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::ipc::Ipc {
pac::$pac_type
}
Expand All @@ -366,6 +371,10 @@ macro_rules! impl_ipc {
}
impl crate::ipc::Instance for peripherals::$type {
type Interrupt = crate::interrupt::typelevel::$irq;
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::ipc::Ipc {
pac::$pac_type
}
}
};
}
9 changes: 9 additions & 0 deletions embassy-nrf/src/pdm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ impl State {
}

pub(crate) trait SealedInstance {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> crate::pac::pdm::Pdm;
fn state() -> &'static State;
}
Expand All @@ -452,11 +453,15 @@ pub(crate) trait SealedInstance {
pub trait Instance: SealedInstance + PeripheralType + 'static + Send {
/// Interrupt for this peripheral
type Interrupt: interrupt::typelevel::Interrupt;
/// Direct access to the register block.
#[cfg(feature = "unstable-pac")]
fn regs() -> crate::pac::pdm::Pdm;
}

macro_rules! impl_pdm {
($type:ident, $pac_type:ident, $irq:ident) => {
impl crate::pdm::SealedInstance for peripherals::$type {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> crate::pac::pdm::Pdm {
pac::$pac_type
}
Expand All @@ -467,6 +472,10 @@ macro_rules! impl_pdm {
}
impl crate::pdm::Instance for peripherals::$type {
type Interrupt = crate::interrupt::typelevel::$irq;
#[cfg(feature = "unstable-pac")]
fn regs() -> crate::pac::pdm::Pdm {
pac::$pac_type
}
}
};
}
9 changes: 9 additions & 0 deletions embassy-nrf/src/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ impl<'a> Drop for SimplePwm<'a> {
}

pub(crate) trait SealedInstance {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::pwm::Pwm;
}

Expand All @@ -834,17 +835,25 @@ pub(crate) trait SealedInstance {
pub trait Instance: SealedInstance + PeripheralType + 'static {
/// Interrupt for this peripheral.
type Interrupt: interrupt::typelevel::Interrupt;
/// Direct access to the register block.
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::pwm::Pwm;
}

macro_rules! impl_pwm {
($type:ident, $pac_type:ident, $irq:ident) => {
impl crate::pwm::SealedInstance for peripherals::$type {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::pwm::Pwm {
pac::$pac_type
}
}
impl crate::pwm::Instance for peripherals::$type {
type Interrupt = crate::interrupt::typelevel::$irq;
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::pwm::Pwm {
pac::$pac_type
}
}
};
}
9 changes: 9 additions & 0 deletions embassy-nrf/src/qdec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ impl State {
}

pub(crate) trait SealedInstance {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::qdec::Qdec;
fn state() -> &'static State;
}
Expand All @@ -280,11 +281,15 @@ pub(crate) trait SealedInstance {
pub trait Instance: SealedInstance + PeripheralType + 'static + Send {
/// Interrupt for this peripheral.
type Interrupt: interrupt::typelevel::Interrupt;
/// Direct access to the register block.
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::qdec::Qdec;
}

macro_rules! impl_qdec {
($type:ident, $pac_type:ident, $irq:ident) => {
impl crate::qdec::SealedInstance for peripherals::$type {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::qdec::Qdec {
pac::$pac_type
}
Expand All @@ -295,6 +300,10 @@ macro_rules! impl_qdec {
}
impl crate::qdec::Instance for peripherals::$type {
type Interrupt = crate::interrupt::typelevel::$irq;
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::qdec::Qdec {
pac::$pac_type
}
}
};
}
9 changes: 9 additions & 0 deletions embassy-nrf/src/qspi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ impl State {
}

pub(crate) trait SealedInstance {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::qspi::Qspi;
fn state() -> &'static State;
}
Expand All @@ -660,11 +661,15 @@ pub(crate) trait SealedInstance {
pub trait Instance: SealedInstance + PeripheralType + 'static + Send {
/// Interrupt for this peripheral.
type Interrupt: interrupt::typelevel::Interrupt;
/// Direct access to the register block.
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::qspi::Qspi;
}

macro_rules! impl_qspi {
($type:ident, $pac_type:ident, $irq:ident) => {
impl crate::qspi::SealedInstance for peripherals::$type {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::qspi::Qspi {
pac::$pac_type
}
Expand All @@ -675,6 +680,10 @@ macro_rules! impl_qspi {
}
impl crate::qspi::Instance for peripherals::$type {
type Interrupt = crate::interrupt::typelevel::$irq;
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::qspi::Qspi {
pac::$pac_type
}
}
};
}
9 changes: 9 additions & 0 deletions embassy-nrf/src/radio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ impl State {
}

pub(crate) trait SealedInstance {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> crate::pac::radio::Radio;
fn state() -> &'static State;
}

macro_rules! impl_radio {
($type:ident, $pac_type:ident, $irq:ident) => {
impl crate::radio::SealedInstance for peripherals::$type {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> crate::pac::radio::Radio {
pac::$pac_type
}
Expand All @@ -88,6 +90,10 @@ macro_rules! impl_radio {
}
impl crate::radio::Instance for peripherals::$type {
type Interrupt = crate::interrupt::typelevel::$irq;
#[cfg(feature = "unstable-pac")]
fn regs() -> crate::pac::radio::Radio {
pac::$pac_type
}
}
};
}
Expand All @@ -97,4 +103,7 @@ macro_rules! impl_radio {
pub trait Instance: SealedInstance + PeripheralType + 'static + Send {
/// Interrupt for this peripheral.
type Interrupt: interrupt::typelevel::Interrupt;
/// Direct access to the register block.
#[cfg(feature = "unstable-pac")]
fn regs() -> crate::pac::radio::Radio;
}
9 changes: 9 additions & 0 deletions embassy-nrf/src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ impl InnerState {
}

pub(crate) trait SealedInstance {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::rng::Rng;
fn state() -> &'static State;
}
Expand All @@ -302,11 +303,15 @@ pub(crate) trait SealedInstance {
pub trait Instance: SealedInstance + PeripheralType + 'static + Send {
/// Interrupt for this peripheral.
type Interrupt: interrupt::typelevel::Interrupt;
/// Direct access to the register block.
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::rng::Rng;
}

macro_rules! impl_rng {
($type:ident, $pac_type:ident, $irq:ident) => {
impl crate::rng::SealedInstance for peripherals::$type {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> crate::pac::rng::Rng {
pac::$pac_type
}
Expand All @@ -317,6 +322,10 @@ macro_rules! impl_rng {
}
impl crate::rng::Instance for peripherals::$type {
type Interrupt = crate::interrupt::typelevel::$irq;
#[cfg(feature = "unstable-pac")]
fn regs() -> crate::pac::rng::Rng {
pac::$pac_type
}
}
};
}
10 changes: 10 additions & 0 deletions embassy-nrf/src/rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub enum CompareChannel {
}

pub(crate) trait SealedInstance {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::rtc::Rtc;
}

Expand All @@ -61,6 +62,9 @@ pub(crate) trait SealedInstance {
pub trait Instance: SealedInstance + PeripheralType + 'static + Send {
/// Interrupt for this peripheral.
type Interrupt: crate::interrupt::typelevel::Interrupt;
/// Direct access to the register block.
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::rtc::Rtc;

/// Unsafely create a peripheral instance.
///
Expand All @@ -74,6 +78,7 @@ pub trait Instance: SealedInstance + PeripheralType + 'static + Send {
macro_rules! impl_rtc {
($type:ident, $pac_type:ident, $irq:ident) => {
impl crate::rtc::SealedInstance for peripherals::$type {
#[cfg(not(feature = "unstable-pac"))]
#[inline]
fn regs() -> pac::rtc::Rtc {
unsafe { pac::rtc::Rtc::from_ptr(pac::$pac_type.as_ptr()) }
Expand All @@ -82,6 +87,11 @@ macro_rules! impl_rtc {

impl crate::rtc::Instance for peripherals::$type {
type Interrupt = crate::interrupt::typelevel::$irq;
#[cfg(feature = "unstable-pac")]
#[inline]
fn regs() -> pac::rtc::Rtc {
unsafe { pac::rtc::Rtc::from_ptr(pac::$pac_type.as_ptr()) }
}

unsafe fn steal() -> embassy_hal_internal::Peri<'static, Self> {
unsafe { peripherals::$type::steal() }
Expand Down
9 changes: 9 additions & 0 deletions embassy-nrf/src/spim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ impl State {
}

pub(crate) trait SealedInstance {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::spim::Spim;
fn state() -> &'static State;
}
Expand All @@ -510,11 +511,15 @@ pub(crate) trait SealedInstance {
pub trait Instance: SealedInstance + PeripheralType + 'static {
/// Interrupt for this peripheral.
type Interrupt: interrupt::typelevel::Interrupt;
/// Direct access to the register block.
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::spim::Spim;
}

macro_rules! impl_spim {
($type:ident, $pac_type:ident, $irq:ident) => {
impl crate::spim::SealedInstance for peripherals::$type {
#[cfg(not(feature = "unstable-pac"))]
fn regs() -> pac::spim::Spim {
pac::$pac_type
}
Expand All @@ -525,6 +530,10 @@ macro_rules! impl_spim {
}
impl crate::spim::Instance for peripherals::$type {
type Interrupt = crate::interrupt::typelevel::$irq;
#[cfg(feature = "unstable-pac")]
fn regs() -> pac::spim::Spim {
pac::$pac_type
}
}
};
}
Expand Down
Loading