diff options
| author | Dion Dokter <[email protected]> | 2021-10-12 11:43:57 +0200 |
|---|---|---|
| committer | Dion Dokter <[email protected]> | 2021-10-12 11:55:38 +0200 |
| commit | 2c2c284482ee57595ad4eef542f4867f6f87bf12 (patch) | |
| tree | 68a5fac20355ad7451a4e10d82f396573942e7f8 /embassy-nrf | |
| parent | 995cd01cbcb2470b9ecdd953daae0cfb3aaa2e99 (diff) | |
Undoing unnecessary changes
Diffstat (limited to 'embassy-nrf')
| -rw-r--r-- | embassy-nrf/src/buffered_uarte.rs | 5 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf9160.rs | 75 | ||||
| -rw-r--r-- | embassy-nrf/src/gpio.rs | 9 | ||||
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 48 | ||||
| -rw-r--r-- | embassy-nrf/src/lib.rs | 6 | ||||
| -rw-r--r-- | embassy-nrf/src/ppi.rs | 20 | ||||
| -rw-r--r-- | embassy-nrf/src/pwm.rs | 9 | ||||
| -rw-r--r-- | embassy-nrf/src/saadc.rs | 3 | ||||
| -rw-r--r-- | embassy-nrf/src/spim.rs | 11 | ||||
| -rw-r--r-- | embassy-nrf/src/time_driver.rs | 16 | ||||
| -rw-r--r-- | embassy-nrf/src/timer.rs | 11 | ||||
| -rw-r--r-- | embassy-nrf/src/twim.rs | 9 | ||||
| -rw-r--r-- | embassy-nrf/src/uarte.rs | 11 | ||||
| -rw-r--r-- | embassy-nrf/src/wdt.rs | 8 |
14 files changed, 90 insertions, 151 deletions
diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index e999cb721..cd08875cd 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs | |||
| @@ -14,13 +14,14 @@ use embassy_hal_common::{low_power_wait_until, unborrow}; | |||
| 14 | 14 | ||
| 15 | use crate::gpio::sealed::Pin as _; | 15 | use crate::gpio::sealed::Pin as _; |
| 16 | use crate::gpio::{OptionalPin as GpioOptionalPin, Pin as GpioPin}; | 16 | use crate::gpio::{OptionalPin as GpioOptionalPin, Pin as GpioPin}; |
| 17 | use crate::pac; | ||
| 17 | use crate::ppi::{AnyConfigurableChannel, ConfigurableChannel, Event, Ppi, Task}; | 18 | use crate::ppi::{AnyConfigurableChannel, ConfigurableChannel, Event, Ppi, Task}; |
| 18 | use crate::timer::Instance as TimerInstance; | 19 | use crate::timer::Instance as TimerInstance; |
| 19 | use crate::timer::{Frequency, Timer}; | 20 | use crate::timer::{Frequency, Timer}; |
| 20 | use crate::uarte::{uarte0, Config, Instance as UarteInstance}; | 21 | use crate::uarte::{Config, Instance as UarteInstance}; |
| 21 | 22 | ||
| 22 | // Re-export SVD variants to allow user to directly set values | 23 | // Re-export SVD variants to allow user to directly set values |
| 23 | pub use uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Parity}; | 24 | pub use pac::uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Parity}; |
| 24 | 25 | ||
| 25 | #[derive(Copy, Clone, Debug, PartialEq)] | 26 | #[derive(Copy, Clone, Debug, PartialEq)] |
| 26 | enum RxState { | 27 | enum RxState { |
diff --git a/embassy-nrf/src/chips/nrf9160.rs b/embassy-nrf/src/chips/nrf9160.rs index 1086c73c1..42053d081 100644 --- a/embassy-nrf/src/chips/nrf9160.rs +++ b/embassy-nrf/src/chips/nrf9160.rs | |||
| @@ -1,7 +1,32 @@ | |||
| 1 | pub use nrf9160_pac as pac; | 1 | #[allow(unused_imports)] |
| 2 | pub mod pac { | ||
| 3 | // The nRF9160 has a secure and non-secure (NS) mode. | ||
| 4 | // For now we only support the NS mode, but those peripherals have `_ns` appended to them. | ||
| 5 | // To avoid cfg spam, weŕe going to rename the ones we use here. | ||
| 6 | #[rustfmt::skip] | ||
| 7 | pub(crate) use nrf9160_pac::{ | ||
| 8 | p0_ns as p0, | ||
| 9 | pwm0_ns as pwm0, | ||
| 10 | rtc0_ns as rtc0, | ||
| 11 | spim0_ns as spim0, | ||
| 12 | timer0_ns as timer0, | ||
| 13 | twim0_ns as twim0, | ||
| 14 | uarte0_ns as uarte0, | ||
| 15 | DPPIC_NS as PPI, | ||
| 16 | GPIOTE1_NS as GPIOTE, | ||
| 17 | P0_NS as P0, | ||
| 18 | RTC1_NS as RTC1, | ||
| 19 | WDT_NS as WDT, | ||
| 20 | saadc_ns as saadc, | ||
| 21 | SAADC_NS as SAADC, | ||
| 22 | CLOCK_NS as CLOCK, | ||
| 23 | }; | ||
| 24 | |||
| 25 | pub use nrf9160_pac::*; | ||
| 26 | } | ||
| 2 | 27 | ||
| 3 | /// The maximum buffer size that the EasyDMA can send/recv in one operation. | 28 | /// The maximum buffer size that the EasyDMA can send/recv in one operation. |
| 4 | pub const EASY_DMA_SIZE: usize = (1 << 12) - 1; | 29 | pub const EASY_DMA_SIZE: usize = (1 << 13) - 1; |
| 5 | pub const FORCE_COPY_BUFFER_SIZE: usize = 1024; | 30 | pub const FORCE_COPY_BUFFER_SIZE: usize = 1024; |
| 6 | 31 | ||
| 7 | embassy_hal_common::peripherals! { | 32 | embassy_hal_common::peripherals! { |
| @@ -12,23 +37,11 @@ embassy_hal_common::peripherals! { | |||
| 12 | // WDT | 37 | // WDT |
| 13 | WDT, | 38 | WDT, |
| 14 | 39 | ||
| 15 | // UARTE | 40 | // UARTE, TWI & SPI |
| 16 | UARTE0, | 41 | UARTETWISPI0, |
| 17 | UARTE1, | 42 | UARTETWISPI1, |
| 18 | UARTE2, | 43 | UARTETWISPI2, |
| 19 | UARTE3, | 44 | UARTETWISPI3, |
| 20 | |||
| 21 | // TWI | ||
| 22 | TWI0, | ||
| 23 | TWI1, | ||
| 24 | TWI2, | ||
| 25 | TWI3, | ||
| 26 | |||
| 27 | // SPI | ||
| 28 | SPI0, | ||
| 29 | SPI1, | ||
| 30 | SPI2, | ||
| 31 | SPI3, | ||
| 32 | 45 | ||
| 33 | // SAADC | 46 | // SAADC |
| 34 | SAADC, | 47 | SAADC, |
| @@ -114,20 +127,20 @@ embassy_hal_common::peripherals! { | |||
| 114 | P0_31, | 127 | P0_31, |
| 115 | } | 128 | } |
| 116 | 129 | ||
| 117 | impl_uarte!(UARTE0, UARTE0_NS, UARTE0_SPIM0_SPIS0_TWIM0_TWIS0); | 130 | impl_uarte!(UARTETWISPI0, UARTE0_NS, UARTE0_SPIM0_SPIS0_TWIM0_TWIS0); |
| 118 | impl_uarte!(UARTE1, UARTE1_NS, UARTE1_SPIM1_SPIS1_TWIM1_TWIS1); | 131 | impl_uarte!(UARTETWISPI1, UARTE1_NS, UARTE1_SPIM1_SPIS1_TWIM1_TWIS1); |
| 119 | impl_uarte!(UARTE2, UARTE2_NS, UARTE2_SPIM2_SPIS2_TWIM2_TWIS2); | 132 | impl_uarte!(UARTETWISPI2, UARTE2_NS, UARTE2_SPIM2_SPIS2_TWIM2_TWIS2); |
| 120 | impl_uarte!(UARTE3, UARTE3_NS, UARTE3_SPIM3_SPIS3_TWIM3_TWIS3); | 133 | impl_uarte!(UARTETWISPI3, UARTE3_NS, UARTE3_SPIM3_SPIS3_TWIM3_TWIS3); |
| 121 | 134 | ||
| 122 | impl_spim!(SPI0, SPIM0_NS, UARTE0_SPIM0_SPIS0_TWIM0_TWIS0); | 135 | impl_spim!(UARTETWISPI0, SPIM0_NS, UARTE0_SPIM0_SPIS0_TWIM0_TWIS0); |
| 123 | impl_spim!(SPI1, SPIM1_NS, UARTE1_SPIM1_SPIS1_TWIM1_TWIS1); | 136 | impl_spim!(UARTETWISPI1, SPIM1_NS, UARTE1_SPIM1_SPIS1_TWIM1_TWIS1); |
| 124 | impl_spim!(SPI2, SPIM2_NS, UARTE2_SPIM2_SPIS2_TWIM2_TWIS2); | 137 | impl_spim!(UARTETWISPI2, SPIM2_NS, UARTE2_SPIM2_SPIS2_TWIM2_TWIS2); |
| 125 | impl_spim!(SPI3, SPIM3_NS, UARTE3_SPIM3_SPIS3_TWIM3_TWIS3); | 138 | impl_spim!(UARTETWISPI3, SPIM3_NS, UARTE3_SPIM3_SPIS3_TWIM3_TWIS3); |
| 126 | 139 | ||
| 127 | impl_twim!(TWI0, TWIM0_NS, UARTE0_SPIM0_SPIS0_TWIM0_TWIS0); | 140 | impl_twim!(UARTETWISPI0, TWIM0_NS, UARTE0_SPIM0_SPIS0_TWIM0_TWIS0); |
| 128 | impl_twim!(TWI1, TWIM1_NS, UARTE1_SPIM1_SPIS1_TWIM1_TWIS1); | 141 | impl_twim!(UARTETWISPI1, TWIM1_NS, UARTE1_SPIM1_SPIS1_TWIM1_TWIS1); |
| 129 | impl_twim!(TWI2, TWIM2_NS, UARTE2_SPIM2_SPIS2_TWIM2_TWIS2); | 142 | impl_twim!(UARTETWISPI2, TWIM2_NS, UARTE2_SPIM2_SPIS2_TWIM2_TWIS2); |
| 130 | impl_twim!(TWI3, TWIM3_NS, UARTE3_SPIM3_SPIS3_TWIM3_TWIS3); | 143 | impl_twim!(UARTETWISPI3, TWIM3_NS, UARTE3_SPIM3_SPIS3_TWIM3_TWIS3); |
| 131 | 144 | ||
| 132 | impl_pwm!(PWM0, PWM0_NS, PWM0); | 145 | impl_pwm!(PWM0, PWM0_NS, PWM0); |
| 133 | impl_pwm!(PWM1, PWM1_NS, PWM1); | 146 | impl_pwm!(PWM1, PWM1_NS, PWM1); |
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index 4cb1d36b9..be0fac2b0 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs | |||
| @@ -10,18 +10,14 @@ use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin}; | |||
| 10 | use gpio::pin_cnf::DRIVE_A; | 10 | use gpio::pin_cnf::DRIVE_A; |
| 11 | 11 | ||
| 12 | use crate::pac; | 12 | use crate::pac; |
| 13 | |||
| 14 | #[cfg(not(feature = "nrf9160"))] | ||
| 15 | use crate::pac::p0 as gpio; | 13 | use crate::pac::p0 as gpio; |
| 16 | #[cfg(feature = "nrf9160")] | ||
| 17 | use crate::pac::p0_ns as gpio; | ||
| 18 | 14 | ||
| 19 | use self::sealed::Pin as _; | 15 | use self::sealed::Pin as _; |
| 20 | 16 | ||
| 21 | /// A GPIO port with up to 32 pins. | 17 | /// A GPIO port with up to 32 pins. |
| 22 | #[derive(Debug, Eq, PartialEq)] | 18 | #[derive(Debug, Eq, PartialEq)] |
| 23 | pub enum Port { | 19 | pub enum Port { |
| 24 | /// Port 0, available on all nRF52 and nRF51 MCUs. | 20 | /// Port 0, available on nRF9160 and all nRF52 and nRF51 MCUs. |
| 25 | Port0, | 21 | Port0, |
| 26 | 22 | ||
| 27 | /// Port 1, only available on some nRF52 MCUs. | 23 | /// Port 1, only available on some nRF52 MCUs. |
| @@ -303,10 +299,7 @@ pub(crate) mod sealed { | |||
| 303 | fn block(&self) -> &gpio::RegisterBlock { | 299 | fn block(&self) -> &gpio::RegisterBlock { |
| 304 | unsafe { | 300 | unsafe { |
| 305 | match self.pin_port() / 32 { | 301 | match self.pin_port() / 32 { |
| 306 | #[cfg(not(feature = "nrf9160"))] | ||
| 307 | 0 => &*pac::P0::ptr(), | 302 | 0 => &*pac::P0::ptr(), |
| 308 | #[cfg(feature = "nrf9160")] | ||
| 309 | 0 => &*pac::P0_NS::ptr(), | ||
| 310 | #[cfg(any(feature = "nrf52833", feature = "nrf52840"))] | 303 | #[cfg(any(feature = "nrf52833", feature = "nrf52840"))] |
| 311 | 1 => &*pac::P1::ptr(), | 304 | 1 => &*pac::P1::ptr(), |
| 312 | _ => unreachable_unchecked(), | 305 | _ => unreachable_unchecked(), |
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 6cf9c9a39..bab49cebb 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -22,18 +22,6 @@ pub const PIN_COUNT: usize = 48; | |||
| 22 | #[cfg(not(any(feature = "nrf52833", feature = "nrf52840")))] | 22 | #[cfg(not(any(feature = "nrf52833", feature = "nrf52840")))] |
| 23 | pub const PIN_COUNT: usize = 32; | 23 | pub const PIN_COUNT: usize = 32; |
| 24 | 24 | ||
| 25 | #[cfg(not(feature = "nrf9160"))] | ||
| 26 | pub(crate) use pac::P0; | ||
| 27 | #[cfg(feature = "nrf9160")] | ||
| 28 | pub(crate) use pac::P0_NS as P0; | ||
| 29 | #[cfg(not(feature = "nrf9160"))] | ||
| 30 | pub(crate) use pac::P1; | ||
| 31 | |||
| 32 | #[cfg(not(feature = "nrf9160"))] | ||
| 33 | pub(crate) use pac::GPIOTE; | ||
| 34 | #[cfg(feature = "nrf9160")] | ||
| 35 | pub(crate) use pac::GPIOTE1_NS as GPIOTE; | ||
| 36 | |||
| 37 | const NEW_AW: AtomicWaker = AtomicWaker::new(); | 25 | const NEW_AW: AtomicWaker = AtomicWaker::new(); |
| 38 | static CHANNEL_WAKERS: [AtomicWaker; CHANNEL_COUNT] = [NEW_AW; CHANNEL_COUNT]; | 26 | static CHANNEL_WAKERS: [AtomicWaker; CHANNEL_COUNT] = [NEW_AW; CHANNEL_COUNT]; |
| 39 | static PORT_WAKERS: [AtomicWaker; PIN_COUNT] = [NEW_AW; PIN_COUNT]; | 27 | static PORT_WAKERS: [AtomicWaker; PIN_COUNT] = [NEW_AW; PIN_COUNT]; |
| @@ -54,9 +42,9 @@ pub enum OutputChannelPolarity { | |||
| 54 | 42 | ||
| 55 | pub(crate) fn init(irq_prio: crate::interrupt::Priority) { | 43 | pub(crate) fn init(irq_prio: crate::interrupt::Priority) { |
| 56 | #[cfg(any(feature = "nrf52833", feature = "nrf52840"))] | 44 | #[cfg(any(feature = "nrf52833", feature = "nrf52840"))] |
| 57 | let ports = unsafe { &[&*P0::ptr(), &*P1::ptr()] }; | 45 | let ports = unsafe { &[&*pac::P0::ptr(), &*pac::P1::ptr()] }; |
| 58 | #[cfg(not(any(feature = "nrf52833", feature = "nrf52840")))] | 46 | #[cfg(not(any(feature = "nrf52833", feature = "nrf52840")))] |
| 59 | let ports = unsafe { &[&*P0::ptr()] }; | 47 | let ports = unsafe { &[&*pac::P0::ptr()] }; |
| 60 | 48 | ||
| 61 | for &p in ports { | 49 | for &p in ports { |
| 62 | // Enable latched detection | 50 | // Enable latched detection |
| @@ -76,7 +64,7 @@ pub(crate) fn init(irq_prio: crate::interrupt::Priority) { | |||
| 76 | irq.set_priority(irq_prio); | 64 | irq.set_priority(irq_prio); |
| 77 | irq.enable(); | 65 | irq.enable(); |
| 78 | 66 | ||
| 79 | let g = unsafe { &*GPIOTE::ptr() }; | 67 | let g = unsafe { &*pac::GPIOTE::ptr() }; |
| 80 | g.events_port.write(|w| w); | 68 | g.events_port.write(|w| w); |
| 81 | g.intenset.write(|w| w.port().set()); | 69 | g.intenset.write(|w| w.port().set()); |
| 82 | } | 70 | } |
| @@ -94,7 +82,7 @@ fn GPIOTE1() { | |||
| 94 | } | 82 | } |
| 95 | 83 | ||
| 96 | unsafe fn handle_gpiote_interrupt() { | 84 | unsafe fn handle_gpiote_interrupt() { |
| 97 | let g = &*GPIOTE::ptr(); | 85 | let g = &*pac::GPIOTE::ptr(); |
| 98 | 86 | ||
| 99 | for i in 0..CHANNEL_COUNT { | 87 | for i in 0..CHANNEL_COUNT { |
| 100 | if g.events_in[i].read().bits() != 0 { | 88 | if g.events_in[i].read().bits() != 0 { |
| @@ -107,9 +95,9 @@ unsafe fn handle_gpiote_interrupt() { | |||
| 107 | g.events_port.write(|w| w); | 95 | g.events_port.write(|w| w); |
| 108 | 96 | ||
| 109 | #[cfg(any(feature = "nrf52833", feature = "nrf52840"))] | 97 | #[cfg(any(feature = "nrf52833", feature = "nrf52840"))] |
| 110 | let ports = &[&*P0::ptr(), &*P1::ptr()]; | 98 | let ports = &[&*pac::P0::ptr(), &*pac::P1::ptr()]; |
| 111 | #[cfg(not(any(feature = "nrf52833", feature = "nrf52840")))] | 99 | #[cfg(not(any(feature = "nrf52833", feature = "nrf52840")))] |
| 112 | let ports = &[&*P0::ptr()]; | 100 | let ports = &[&*pac::P0::ptr()]; |
| 113 | 101 | ||
| 114 | for (port, &p) in ports.iter().enumerate() { | 102 | for (port, &p) in ports.iter().enumerate() { |
| 115 | let bits = p.latch.read().bits(); | 103 | let bits = p.latch.read().bits(); |
| @@ -146,7 +134,7 @@ pub struct InputChannel<'d, C: Channel, T: GpioPin> { | |||
| 146 | 134 | ||
| 147 | impl<'d, C: Channel, T: GpioPin> Drop for InputChannel<'d, C, T> { | 135 | impl<'d, C: Channel, T: GpioPin> Drop for InputChannel<'d, C, T> { |
| 148 | fn drop(&mut self) { | 136 | fn drop(&mut self) { |
| 149 | let g = unsafe { &*GPIOTE::ptr() }; | 137 | let g = unsafe { &*pac::GPIOTE::ptr() }; |
| 150 | let num = self.ch.number(); | 138 | let num = self.ch.number(); |
| 151 | g.config[num].write(|w| w.mode().disabled()); | 139 | g.config[num].write(|w| w.mode().disabled()); |
| 152 | g.intenclr.write(|w| unsafe { w.bits(1 << num) }); | 140 | g.intenclr.write(|w| unsafe { w.bits(1 << num) }); |
| @@ -155,7 +143,7 @@ impl<'d, C: Channel, T: GpioPin> Drop for InputChannel<'d, C, T> { | |||
| 155 | 143 | ||
| 156 | impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> { | 144 | impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> { |
| 157 | pub fn new(ch: C, pin: Input<'d, T>, polarity: InputChannelPolarity) -> Self { | 145 | pub fn new(ch: C, pin: Input<'d, T>, polarity: InputChannelPolarity) -> Self { |
| 158 | let g = unsafe { &*GPIOTE::ptr() }; | 146 | let g = unsafe { &*pac::GPIOTE::ptr() }; |
| 159 | let num = ch.number(); | 147 | let num = ch.number(); |
| 160 | 148 | ||
| 161 | g.config[num].write(|w| { | 149 | g.config[num].write(|w| { |
| @@ -179,7 +167,7 @@ impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> { | |||
| 179 | } | 167 | } |
| 180 | 168 | ||
| 181 | pub async fn wait(&self) { | 169 | pub async fn wait(&self) { |
| 182 | let g = unsafe { &*GPIOTE::ptr() }; | 170 | let g = unsafe { &*pac::GPIOTE::ptr() }; |
| 183 | let num = self.ch.number(); | 171 | let num = self.ch.number(); |
| 184 | 172 | ||
| 185 | // Enable interrupt | 173 | // Enable interrupt |
| @@ -200,7 +188,7 @@ impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> { | |||
| 200 | 188 | ||
| 201 | /// Returns the IN event, for use with PPI. | 189 | /// Returns the IN event, for use with PPI. |
| 202 | pub fn event_in(&self) -> Event { | 190 | pub fn event_in(&self) -> Event { |
| 203 | let g = unsafe { &*GPIOTE::ptr() }; | 191 | let g = unsafe { &*pac::GPIOTE::ptr() }; |
| 204 | Event::from_reg(&g.events_in[self.ch.number()]) | 192 | Event::from_reg(&g.events_in[self.ch.number()]) |
| 205 | } | 193 | } |
| 206 | } | 194 | } |
| @@ -225,7 +213,7 @@ pub struct OutputChannel<'d, C: Channel, T: GpioPin> { | |||
| 225 | 213 | ||
| 226 | impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> { | 214 | impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> { |
| 227 | fn drop(&mut self) { | 215 | fn drop(&mut self) { |
| 228 | let g = unsafe { &*GPIOTE::ptr() }; | 216 | let g = unsafe { &*pac::GPIOTE::ptr() }; |
| 229 | let num = self.ch.number(); | 217 | let num = self.ch.number(); |
| 230 | g.config[num].write(|w| w.mode().disabled()); | 218 | g.config[num].write(|w| w.mode().disabled()); |
| 231 | g.intenclr.write(|w| unsafe { w.bits(1 << num) }); | 219 | g.intenclr.write(|w| unsafe { w.bits(1 << num) }); |
| @@ -234,7 +222,7 @@ impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> { | |||
| 234 | 222 | ||
| 235 | impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> { | 223 | impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> { |
| 236 | pub fn new(ch: C, pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self { | 224 | pub fn new(ch: C, pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self { |
| 237 | let g = unsafe { &*GPIOTE::ptr() }; | 225 | let g = unsafe { &*pac::GPIOTE::ptr() }; |
| 238 | let num = ch.number(); | 226 | let num = ch.number(); |
| 239 | 227 | ||
| 240 | g.config[num].write(|w| { | 228 | g.config[num].write(|w| { |
| @@ -261,41 +249,41 @@ impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> { | |||
| 261 | 249 | ||
| 262 | /// Triggers `task out` (as configured with task_out_polarity, defaults to Toggle). | 250 | /// Triggers `task out` (as configured with task_out_polarity, defaults to Toggle). |
| 263 | pub fn out(&self) { | 251 | pub fn out(&self) { |
| 264 | let g = unsafe { &*GPIOTE::ptr() }; | 252 | let g = unsafe { &*pac::GPIOTE::ptr() }; |
| 265 | g.tasks_out[self.ch.number()].write(|w| unsafe { w.bits(1) }); | 253 | g.tasks_out[self.ch.number()].write(|w| unsafe { w.bits(1) }); |
| 266 | } | 254 | } |
| 267 | 255 | ||
| 268 | /// Triggers `task set` (set associated pin high). | 256 | /// Triggers `task set` (set associated pin high). |
| 269 | #[cfg(not(feature = "nrf51"))] | 257 | #[cfg(not(feature = "nrf51"))] |
| 270 | pub fn set(&self) { | 258 | pub fn set(&self) { |
| 271 | let g = unsafe { &*GPIOTE::ptr() }; | 259 | let g = unsafe { &*pac::GPIOTE::ptr() }; |
| 272 | g.tasks_set[self.ch.number()].write(|w| unsafe { w.bits(1) }); | 260 | g.tasks_set[self.ch.number()].write(|w| unsafe { w.bits(1) }); |
| 273 | } | 261 | } |
| 274 | 262 | ||
| 275 | /// Triggers `task clear` (set associated pin low). | 263 | /// Triggers `task clear` (set associated pin low). |
| 276 | #[cfg(not(feature = "nrf51"))] | 264 | #[cfg(not(feature = "nrf51"))] |
| 277 | pub fn clear(&self) { | 265 | pub fn clear(&self) { |
| 278 | let g = unsafe { &*GPIOTE::ptr() }; | 266 | let g = unsafe { &*pac::GPIOTE::ptr() }; |
| 279 | g.tasks_clr[self.ch.number()].write(|w| unsafe { w.bits(1) }); | 267 | g.tasks_clr[self.ch.number()].write(|w| unsafe { w.bits(1) }); |
| 280 | } | 268 | } |
| 281 | 269 | ||
| 282 | /// Returns the OUT task, for use with PPI. | 270 | /// Returns the OUT task, for use with PPI. |
| 283 | pub fn task_out(&self) -> Task { | 271 | pub fn task_out(&self) -> Task { |
| 284 | let g = unsafe { &*GPIOTE::ptr() }; | 272 | let g = unsafe { &*pac::GPIOTE::ptr() }; |
| 285 | Task::from_reg(&g.tasks_out[self.ch.number()]) | 273 | Task::from_reg(&g.tasks_out[self.ch.number()]) |
| 286 | } | 274 | } |
| 287 | 275 | ||
| 288 | /// Returns the CLR task, for use with PPI. | 276 | /// Returns the CLR task, for use with PPI. |
| 289 | #[cfg(not(feature = "nrf51"))] | 277 | #[cfg(not(feature = "nrf51"))] |
| 290 | pub fn task_clr(&self) -> Task { | 278 | pub fn task_clr(&self) -> Task { |
| 291 | let g = unsafe { &*GPIOTE::ptr() }; | 279 | let g = unsafe { &*pac::GPIOTE::ptr() }; |
| 292 | Task::from_reg(&g.tasks_clr[self.ch.number()]) | 280 | Task::from_reg(&g.tasks_clr[self.ch.number()]) |
| 293 | } | 281 | } |
| 294 | 282 | ||
| 295 | /// Returns the SET task, for use with PPI. | 283 | /// Returns the SET task, for use with PPI. |
| 296 | #[cfg(not(feature = "nrf51"))] | 284 | #[cfg(not(feature = "nrf51"))] |
| 297 | pub fn task_set(&self) -> Task { | 285 | pub fn task_set(&self) -> Task { |
| 298 | let g = unsafe { &*GPIOTE::ptr() }; | 286 | let g = unsafe { &*pac::GPIOTE::ptr() }; |
| 299 | Task::from_reg(&g.tasks_set[self.ch.number()]) | 287 | Task::from_reg(&g.tasks_set[self.ch.number()]) |
| 300 | } | 288 | } |
| 301 | } | 289 | } |
diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index 2ee04708d..00c719a17 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs | |||
| @@ -77,12 +77,8 @@ pub use chip::pac; | |||
| 77 | #[cfg(not(feature = "unstable-pac"))] | 77 | #[cfg(not(feature = "unstable-pac"))] |
| 78 | pub(crate) use chip::pac; | 78 | pub(crate) use chip::pac; |
| 79 | 79 | ||
| 80 | pub use chip::{peripherals, Peripherals}; | ||
| 81 | |||
| 82 | #[cfg(not(feature = "nrf9160"))] | ||
| 83 | use crate::pac::CLOCK; | 80 | use crate::pac::CLOCK; |
| 84 | #[cfg(feature = "nrf9160")] | 81 | pub use chip::{peripherals, Peripherals}; |
| 85 | use crate::pac::CLOCK_NS as CLOCK; | ||
| 86 | 82 | ||
| 87 | pub mod interrupt { | 83 | pub mod interrupt { |
| 88 | pub use crate::chip::irqs::*; | 84 | pub use crate::chip::irqs::*; |
diff --git a/embassy-nrf/src/ppi.rs b/embassy-nrf/src/ppi.rs index db5387b8e..f5e06c69f 100644 --- a/embassy-nrf/src/ppi.rs +++ b/embassy-nrf/src/ppi.rs | |||
| @@ -11,18 +11,12 @@ | |||
| 11 | //! On nRF52 devices, there is also a fork task endpoint, where the user can configure one more task | 11 | //! On nRF52 devices, there is also a fork task endpoint, where the user can configure one more task |
| 12 | //! to be triggered by the same event, even fixed PPI channels have a configurable fork task. | 12 | //! to be triggered by the same event, even fixed PPI channels have a configurable fork task. |
| 13 | 13 | ||
| 14 | use crate::{pac, peripherals}; | ||
| 14 | use core::marker::PhantomData; | 15 | use core::marker::PhantomData; |
| 15 | use core::ptr::NonNull; | 16 | use core::ptr::NonNull; |
| 16 | use embassy::util::Unborrow; | 17 | use embassy::util::Unborrow; |
| 17 | use embassy_hal_common::{unborrow, unsafe_impl_unborrow}; | 18 | use embassy_hal_common::{unborrow, unsafe_impl_unborrow}; |
| 18 | 19 | ||
| 19 | use crate::{pac, peripherals}; | ||
| 20 | |||
| 21 | #[cfg(feature = "nrf9160")] | ||
| 22 | pub(crate) use pac::DPPIC_NS as PPI; | ||
| 23 | #[cfg(not(feature = "nrf9160"))] | ||
| 24 | pub(crate) use pac::PPI; | ||
| 25 | |||
| 26 | // ====================== | 20 | // ====================== |
| 27 | // driver | 21 | // driver |
| 28 | 22 | ||
| @@ -47,14 +41,14 @@ impl<'d, C: Channel> Ppi<'d, C> { | |||
| 47 | 41 | ||
| 48 | /// Enables the channel. | 42 | /// Enables the channel. |
| 49 | pub fn enable(&mut self) { | 43 | pub fn enable(&mut self) { |
| 50 | let r = unsafe { &*PPI::ptr() }; | 44 | let r = unsafe { &*pac::PPI::ptr() }; |
| 51 | r.chenset | 45 | r.chenset |
| 52 | .write(|w| unsafe { w.bits(1 << self.ch.number()) }); | 46 | .write(|w| unsafe { w.bits(1 << self.ch.number()) }); |
| 53 | } | 47 | } |
| 54 | 48 | ||
| 55 | /// Disables the channel. | 49 | /// Disables the channel. |
| 56 | pub fn disable(&mut self) { | 50 | pub fn disable(&mut self) { |
| 57 | let r = unsafe { &*PPI::ptr() }; | 51 | let r = unsafe { &*pac::PPI::ptr() }; |
| 58 | r.chenclr | 52 | r.chenclr |
| 59 | .write(|w| unsafe { w.bits(1 << self.ch.number()) }); | 53 | .write(|w| unsafe { w.bits(1 << self.ch.number()) }); |
| 60 | } | 54 | } |
| @@ -63,7 +57,7 @@ impl<'d, C: Channel> Ppi<'d, C> { | |||
| 63 | /// Sets the fork task that must be triggered when the configured event occurs. The user must | 57 | /// Sets the fork task that must be triggered when the configured event occurs. The user must |
| 64 | /// provide a reference to the task. | 58 | /// provide a reference to the task. |
| 65 | pub fn set_fork_task(&mut self, task: Task) { | 59 | pub fn set_fork_task(&mut self, task: Task) { |
| 66 | let r = unsafe { &*PPI::ptr() }; | 60 | let r = unsafe { &*pac::PPI::ptr() }; |
| 67 | r.fork[self.ch.number()] | 61 | r.fork[self.ch.number()] |
| 68 | .tep | 62 | .tep |
| 69 | .write(|w| unsafe { w.bits(task.0.as_ptr() as u32) }) | 63 | .write(|w| unsafe { w.bits(task.0.as_ptr() as u32) }) |
| @@ -72,7 +66,7 @@ impl<'d, C: Channel> Ppi<'d, C> { | |||
| 72 | #[cfg(not(any(feature = "nrf51", feature = "nrf9160")))] | 66 | #[cfg(not(any(feature = "nrf51", feature = "nrf9160")))] |
| 73 | /// Clear the fork task endpoint. Previously set task will no longer be triggered. | 67 | /// Clear the fork task endpoint. Previously set task will no longer be triggered. |
| 74 | pub fn clear_fork_task(&mut self) { | 68 | pub fn clear_fork_task(&mut self) { |
| 75 | let r = unsafe { &*PPI::ptr() }; | 69 | let r = unsafe { &*pac::PPI::ptr() }; |
| 76 | r.fork[self.ch.number()].tep.write(|w| unsafe { w.bits(0) }) | 70 | r.fork[self.ch.number()].tep.write(|w| unsafe { w.bits(0) }) |
| 77 | } | 71 | } |
| 78 | 72 | ||
| @@ -100,7 +94,7 @@ impl<'d, C: Channel> Drop for Ppi<'d, C> { | |||
| 100 | impl<'d, C: ConfigurableChannel> Ppi<'d, C> { | 94 | impl<'d, C: ConfigurableChannel> Ppi<'d, C> { |
| 101 | /// Sets the task to be triggered when the configured event occurs. | 95 | /// Sets the task to be triggered when the configured event occurs. |
| 102 | pub fn set_task(&mut self, task: Task) { | 96 | pub fn set_task(&mut self, task: Task) { |
| 103 | let r = unsafe { &*PPI::ptr() }; | 97 | let r = unsafe { &*pac::PPI::ptr() }; |
| 104 | r.ch[self.ch.number()] | 98 | r.ch[self.ch.number()] |
| 105 | .tep | 99 | .tep |
| 106 | .write(|w| unsafe { w.bits(task.0.as_ptr() as u32) }) | 100 | .write(|w| unsafe { w.bits(task.0.as_ptr() as u32) }) |
| @@ -108,7 +102,7 @@ impl<'d, C: ConfigurableChannel> Ppi<'d, C> { | |||
| 108 | 102 | ||
| 109 | /// Sets the event that will trigger the chosen task(s). | 103 | /// Sets the event that will trigger the chosen task(s). |
| 110 | pub fn set_event(&mut self, event: Event) { | 104 | pub fn set_event(&mut self, event: Event) { |
| 111 | let r = unsafe { &*PPI::ptr() }; | 105 | let r = unsafe { &*pac::PPI::ptr() }; |
| 112 | r.ch[self.ch.number()] | 106 | r.ch[self.ch.number()] |
| 113 | .eep | 107 | .eep |
| 114 | .write(|w| unsafe { w.bits(event.0.as_ptr() as u32) }) | 108 | .write(|w| unsafe { w.bits(event.0.as_ptr() as u32) }) |
diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs index 1bafb1d48..5e996e882 100644 --- a/embassy-nrf/src/pwm.rs +++ b/embassy-nrf/src/pwm.rs | |||
| @@ -11,11 +11,6 @@ use crate::gpio::OptionalPin as GpioOptionalPin; | |||
| 11 | use crate::interrupt::Interrupt; | 11 | use crate::interrupt::Interrupt; |
| 12 | use crate::pac; | 12 | use crate::pac; |
| 13 | 13 | ||
| 14 | #[cfg(not(feature = "nrf9160"))] | ||
| 15 | pub(crate) use pac::pwm0; | ||
| 16 | #[cfg(feature = "nrf9160")] | ||
| 17 | pub(crate) use pac::pwm0_ns as pwm0; | ||
| 18 | |||
| 19 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] | 14 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] |
| 20 | pub enum Prescaler { | 15 | pub enum Prescaler { |
| 21 | Div1, | 16 | Div1, |
| @@ -208,7 +203,7 @@ pub(crate) mod sealed { | |||
| 208 | } | 203 | } |
| 209 | 204 | ||
| 210 | pub trait Instance { | 205 | pub trait Instance { |
| 211 | fn regs() -> &'static pwm0::RegisterBlock; | 206 | fn regs() -> &'static pac::pwm0::RegisterBlock; |
| 212 | fn state() -> &'static State; | 207 | fn state() -> &'static State; |
| 213 | } | 208 | } |
| 214 | } | 209 | } |
| @@ -220,7 +215,7 @@ pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static { | |||
| 220 | macro_rules! impl_pwm { | 215 | macro_rules! impl_pwm { |
| 221 | ($type:ident, $pac_type:ident, $irq:ident) => { | 216 | ($type:ident, $pac_type:ident, $irq:ident) => { |
| 222 | impl crate::pwm::sealed::Instance for peripherals::$type { | 217 | impl crate::pwm::sealed::Instance for peripherals::$type { |
| 223 | fn regs() -> &'static crate::pwm::pwm0::RegisterBlock { | 218 | fn regs() -> &'static pac::pwm0::RegisterBlock { |
| 224 | unsafe { &*pac::$pac_type::ptr() } | 219 | unsafe { &*pac::$pac_type::ptr() } |
| 225 | } | 220 | } |
| 226 | fn state() -> &'static crate::pwm::sealed::State { | 221 | fn state() -> &'static crate::pwm::sealed::State { |
diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs index b1d8faac8..2ce7ef16d 100644 --- a/embassy-nrf/src/saadc.rs +++ b/embassy-nrf/src/saadc.rs | |||
| @@ -12,10 +12,7 @@ use futures::future::poll_fn; | |||
| 12 | use crate::interrupt; | 12 | use crate::interrupt; |
| 13 | use crate::{pac, peripherals}; | 13 | use crate::{pac, peripherals}; |
| 14 | 14 | ||
| 15 | #[cfg(not(feature = "nrf9160"))] | ||
| 16 | use pac::{saadc, SAADC}; | 15 | use pac::{saadc, SAADC}; |
| 17 | #[cfg(feature = "nrf9160")] | ||
| 18 | use pac::{saadc_ns as saadc, SAADC_NS as SAADC}; | ||
| 19 | 16 | ||
| 20 | pub use saadc::{ | 17 | pub use saadc::{ |
| 21 | ch::{ | 18 | ch::{ |
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index f40da54e5..e88fb460c 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs | |||
| @@ -17,13 +17,8 @@ use crate::gpio::{OptionalPin, Pin as GpioPin}; | |||
| 17 | use crate::interrupt::Interrupt; | 17 | use crate::interrupt::Interrupt; |
| 18 | use crate::{pac, util::slice_in_ram_or}; | 18 | use crate::{pac, util::slice_in_ram_or}; |
| 19 | 19 | ||
| 20 | #[cfg(not(feature = "nrf9160"))] | ||
| 21 | pub(crate) use pac::spim0; | ||
| 22 | #[cfg(feature = "nrf9160")] | ||
| 23 | pub(crate) use pac::spim0_ns as spim0; | ||
| 24 | |||
| 25 | pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3}; | 20 | pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3}; |
| 26 | pub use spim0::frequency::FREQUENCY_A as Frequency; | 21 | pub use pac::spim0::frequency::FREQUENCY_A as Frequency; |
| 27 | 22 | ||
| 28 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 23 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 29 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 24 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| @@ -381,7 +376,7 @@ pub(crate) mod sealed { | |||
| 381 | } | 376 | } |
| 382 | 377 | ||
| 383 | pub trait Instance { | 378 | pub trait Instance { |
| 384 | fn regs() -> &'static spim0::RegisterBlock; | 379 | fn regs() -> &'static pac::spim0::RegisterBlock; |
| 385 | fn state() -> &'static State; | 380 | fn state() -> &'static State; |
| 386 | } | 381 | } |
| 387 | } | 382 | } |
| @@ -393,7 +388,7 @@ pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static { | |||
| 393 | macro_rules! impl_spim { | 388 | macro_rules! impl_spim { |
| 394 | ($type:ident, $pac_type:ident, $irq:ident) => { | 389 | ($type:ident, $pac_type:ident, $irq:ident) => { |
| 395 | impl crate::spim::sealed::Instance for peripherals::$type { | 390 | impl crate::spim::sealed::Instance for peripherals::$type { |
| 396 | fn regs() -> &'static crate::spim::spim0::RegisterBlock { | 391 | fn regs() -> &'static pac::spim0::RegisterBlock { |
| 397 | unsafe { &*pac::$pac_type::ptr() } | 392 | unsafe { &*pac::$pac_type::ptr() } |
| 398 | } | 393 | } |
| 399 | fn state() -> &'static crate::spim::sealed::State { | 394 | fn state() -> &'static crate::spim::sealed::State { |
diff --git a/embassy-nrf/src/time_driver.rs b/embassy-nrf/src/time_driver.rs index 4c2438a00..19356c2d2 100644 --- a/embassy-nrf/src/time_driver.rs +++ b/embassy-nrf/src/time_driver.rs | |||
| @@ -9,20 +9,8 @@ use embassy::time::driver::{AlarmHandle, Driver}; | |||
| 9 | use crate::interrupt; | 9 | use crate::interrupt; |
| 10 | use crate::pac; | 10 | use crate::pac; |
| 11 | 11 | ||
| 12 | #[cfg(not(feature = "nrf9160"))] | 12 | fn rtc() -> &'static pac::rtc0::RegisterBlock { |
| 13 | pub(crate) use pac::rtc0; | 13 | unsafe { &*pac::RTC1::ptr() } |
| 14 | #[cfg(feature = "nrf9160")] | ||
| 15 | pub(crate) use pac::rtc0_ns as rtc0; | ||
| 16 | |||
| 17 | fn rtc() -> &'static rtc0::RegisterBlock { | ||
| 18 | #[cfg(not(feature = "nrf9160"))] | ||
| 19 | unsafe { | ||
| 20 | &*pac::RTC1::ptr() | ||
| 21 | } | ||
| 22 | #[cfg(feature = "nrf9160")] | ||
| 23 | unsafe { | ||
| 24 | &*pac::RTC1_NS::ptr() | ||
| 25 | } | ||
| 26 | } | 14 | } |
| 27 | 15 | ||
| 28 | // RTC timekeeping works with something we call "periods", which are time intervals | 16 | // RTC timekeeping works with something we call "periods", which are time intervals |
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs index 066609ec6..5690ff0d8 100644 --- a/embassy-nrf/src/timer.rs +++ b/embassy-nrf/src/timer.rs | |||
| @@ -15,11 +15,6 @@ use crate::pac; | |||
| 15 | use crate::ppi::Event; | 15 | use crate::ppi::Event; |
| 16 | use crate::ppi::Task; | 16 | use crate::ppi::Task; |
| 17 | 17 | ||
| 18 | #[cfg(not(feature = "nrf9160"))] | ||
| 19 | pub(crate) use pac::timer0; | ||
| 20 | #[cfg(feature = "nrf9160")] | ||
| 21 | pub(crate) use pac::timer0_ns as timer0; | ||
| 22 | |||
| 23 | pub(crate) mod sealed { | 18 | pub(crate) mod sealed { |
| 24 | 19 | ||
| 25 | use super::*; | 20 | use super::*; |
| @@ -27,7 +22,7 @@ pub(crate) mod sealed { | |||
| 27 | pub trait Instance { | 22 | pub trait Instance { |
| 28 | /// The number of CC registers this instance has. | 23 | /// The number of CC registers this instance has. |
| 29 | const CCS: usize; | 24 | const CCS: usize; |
| 30 | fn regs() -> &'static timer0::RegisterBlock; | 25 | fn regs() -> &'static pac::timer0::RegisterBlock; |
| 31 | /// Storage for the waker for CC register `n`. | 26 | /// Storage for the waker for CC register `n`. |
| 32 | fn waker(n: usize) -> &'static AtomicWaker; | 27 | fn waker(n: usize) -> &'static AtomicWaker; |
| 33 | } | 28 | } |
| @@ -45,8 +40,8 @@ macro_rules! impl_timer { | |||
| 45 | ($type:ident, $pac_type:ident, $irq:ident, $ccs:literal) => { | 40 | ($type:ident, $pac_type:ident, $irq:ident, $ccs:literal) => { |
| 46 | impl crate::timer::sealed::Instance for peripherals::$type { | 41 | impl crate::timer::sealed::Instance for peripherals::$type { |
| 47 | const CCS: usize = $ccs; | 42 | const CCS: usize = $ccs; |
| 48 | fn regs() -> &'static crate::timer::timer0::RegisterBlock { | 43 | fn regs() -> &'static pac::timer0::RegisterBlock { |
| 49 | unsafe { &*(pac::$pac_type::ptr() as *const crate::timer::timer0::RegisterBlock) } | 44 | unsafe { &*(pac::$pac_type::ptr() as *const pac::timer0::RegisterBlock) } |
| 50 | } | 45 | } |
| 51 | fn waker(n: usize) -> &'static ::embassy::waitqueue::AtomicWaker { | 46 | fn waker(n: usize) -> &'static ::embassy::waitqueue::AtomicWaker { |
| 52 | use ::embassy::waitqueue::AtomicWaker; | 47 | use ::embassy::waitqueue::AtomicWaker; |
diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index 8dcfb4143..8173f66b0 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs | |||
| @@ -24,11 +24,6 @@ use crate::gpio::Pin as GpioPin; | |||
| 24 | use crate::pac; | 24 | use crate::pac; |
| 25 | use crate::util::{slice_in_ram, slice_in_ram_or}; | 25 | use crate::util::{slice_in_ram, slice_in_ram_or}; |
| 26 | 26 | ||
| 27 | #[cfg(not(feature = "nrf9160"))] | ||
| 28 | pub(crate) use pac::twim0; | ||
| 29 | #[cfg(feature = "nrf9160")] | ||
| 30 | pub(crate) use pac::twim0_ns as twim0; | ||
| 31 | |||
| 32 | pub enum Frequency { | 27 | pub enum Frequency { |
| 33 | #[doc = "26738688: 100 kbps"] | 28 | #[doc = "26738688: 100 kbps"] |
| 34 | K100 = 26738688, | 29 | K100 = 26738688, |
| @@ -726,7 +721,7 @@ pub(crate) mod sealed { | |||
| 726 | } | 721 | } |
| 727 | 722 | ||
| 728 | pub trait Instance { | 723 | pub trait Instance { |
| 729 | fn regs() -> &'static twim0::RegisterBlock; | 724 | fn regs() -> &'static pac::twim0::RegisterBlock; |
| 730 | fn state() -> &'static State; | 725 | fn state() -> &'static State; |
| 731 | } | 726 | } |
| 732 | } | 727 | } |
| @@ -738,7 +733,7 @@ pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static { | |||
| 738 | macro_rules! impl_twim { | 733 | macro_rules! impl_twim { |
| 739 | ($type:ident, $pac_type:ident, $irq:ident) => { | 734 | ($type:ident, $pac_type:ident, $irq:ident) => { |
| 740 | impl crate::twim::sealed::Instance for peripherals::$type { | 735 | impl crate::twim::sealed::Instance for peripherals::$type { |
| 741 | fn regs() -> &'static crate::twim::twim0::RegisterBlock { | 736 | fn regs() -> &'static pac::twim0::RegisterBlock { |
| 742 | unsafe { &*pac::$pac_type::ptr() } | 737 | unsafe { &*pac::$pac_type::ptr() } |
| 743 | } | 738 | } |
| 744 | fn state() -> &'static crate::twim::sealed::State { | 739 | fn state() -> &'static crate::twim::sealed::State { |
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 286e324b0..320426060 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs | |||
| @@ -22,13 +22,8 @@ use crate::ppi::{AnyConfigurableChannel, ConfigurableChannel, Event, Ppi, Task}; | |||
| 22 | use crate::timer::Instance as TimerInstance; | 22 | use crate::timer::Instance as TimerInstance; |
| 23 | use crate::timer::{Frequency, Timer}; | 23 | use crate::timer::{Frequency, Timer}; |
| 24 | 24 | ||
| 25 | #[cfg(not(feature = "nrf9160"))] | ||
| 26 | pub(crate) use pac::uarte0; | ||
| 27 | #[cfg(feature = "nrf9160")] | ||
| 28 | pub(crate) use pac::uarte0_ns as uarte0; | ||
| 29 | |||
| 30 | // Re-export SVD variants to allow user to directly set values. | 25 | // Re-export SVD variants to allow user to directly set values. |
| 31 | pub use uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Parity}; | 26 | pub use pac::uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Parity}; |
| 32 | 27 | ||
| 33 | #[non_exhaustive] | 28 | #[non_exhaustive] |
| 34 | pub struct Config { | 29 | pub struct Config { |
| @@ -463,7 +458,7 @@ pub(crate) mod sealed { | |||
| 463 | } | 458 | } |
| 464 | 459 | ||
| 465 | pub trait Instance { | 460 | pub trait Instance { |
| 466 | fn regs() -> &'static uarte0::RegisterBlock; | 461 | fn regs() -> &'static pac::uarte0::RegisterBlock; |
| 467 | fn state() -> &'static State; | 462 | fn state() -> &'static State; |
| 468 | } | 463 | } |
| 469 | } | 464 | } |
| @@ -475,7 +470,7 @@ pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static + Send | |||
| 475 | macro_rules! impl_uarte { | 470 | macro_rules! impl_uarte { |
| 476 | ($type:ident, $pac_type:ident, $irq:ident) => { | 471 | ($type:ident, $pac_type:ident, $irq:ident) => { |
| 477 | impl crate::uarte::sealed::Instance for peripherals::$type { | 472 | impl crate::uarte::sealed::Instance for peripherals::$type { |
| 478 | fn regs() -> &'static crate::uarte::uarte0::RegisterBlock { | 473 | fn regs() -> &'static pac::uarte0::RegisterBlock { |
| 479 | unsafe { &*pac::$pac_type::ptr() } | 474 | unsafe { &*pac::$pac_type::ptr() } |
| 480 | } | 475 | } |
| 481 | fn state() -> &'static crate::uarte::sealed::State { | 476 | fn state() -> &'static crate::uarte::sealed::State { |
diff --git a/embassy-nrf/src/wdt.rs b/embassy-nrf/src/wdt.rs index 98ddd71af..eddfa7582 100644 --- a/embassy-nrf/src/wdt.rs +++ b/embassy-nrf/src/wdt.rs | |||
| @@ -3,13 +3,7 @@ | |||
| 3 | //! This HAL implements a basic watchdog timer with 1..=8 handles. | 3 | //! This HAL implements a basic watchdog timer with 1..=8 handles. |
| 4 | //! Once the watchdog has been started, it cannot be stopped. | 4 | //! Once the watchdog has been started, it cannot be stopped. |
| 5 | 5 | ||
| 6 | use crate::pac; | 6 | use crate::pac::WDT; |
| 7 | |||
| 8 | #[cfg(not(feature = "nrf9160"))] | ||
| 9 | pub(crate) use pac::WDT; | ||
| 10 | #[cfg(feature = "nrf9160")] | ||
| 11 | pub(crate) use pac::WDT_NS as WDT; | ||
| 12 | |||
| 13 | use crate::peripherals; | 7 | use crate::peripherals; |
| 14 | 8 | ||
| 15 | const MIN_TICKS: u32 = 15; | 9 | const MIN_TICKS: u32 = 15; |
