aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Mueller <[email protected]>2025-09-22 00:43:02 +0200
committerRobin Mueller <[email protected]>2025-09-22 00:45:29 +0200
commitd1b55faace4b5059c726d94dd2d7f1ad3805ab48 (patch)
tree569ff71846b17f13a61504b6b88ebcd5ef184c16
parentf7c3005345df07bad5c42612fd73974bd569affb (diff)
code review changes
-rw-r--r--embassy-nrf/src/chips/nrf51.rs2
-rw-r--r--embassy-nrf/src/chips/nrf52805.rs4
-rw-r--r--embassy-nrf/src/chips/nrf52810.rs2
-rw-r--r--embassy-nrf/src/chips/nrf52811.rs2
-rw-r--r--embassy-nrf/src/chips/nrf52820.rs2
-rw-r--r--embassy-nrf/src/chips/nrf52832.rs2
-rw-r--r--embassy-nrf/src/chips/nrf52833.rs2
-rw-r--r--embassy-nrf/src/chips/nrf52840.rs2
-rw-r--r--embassy-nrf/src/chips/nrf5340_app.rs2
-rw-r--r--embassy-nrf/src/chips/nrf5340_net.rs2
-rw-r--r--embassy-nrf/src/chips/nrf9120.rs2
-rw-r--r--embassy-nrf/src/chips/nrf9160.rs2
-rw-r--r--embassy-nrf/src/rtc.rs15
13 files changed, 29 insertions, 12 deletions
diff --git a/embassy-nrf/src/chips/nrf51.rs b/embassy-nrf/src/chips/nrf51.rs
index 393af4e75..3976e8ff0 100644
--- a/embassy-nrf/src/chips/nrf51.rs
+++ b/embassy-nrf/src/chips/nrf51.rs
@@ -8,6 +8,7 @@ pub const FLASH_SIZE: usize = 128 * 1024;
8embassy_hal_internal::peripherals! { 8embassy_hal_internal::peripherals! {
9 // RTC 9 // RTC
10 RTC0, 10 RTC0,
11 #[cfg(not(feature = "time-driver-rtc1"))]
11 RTC1, 12 RTC1,
12 13
13 // WDT 14 // WDT
@@ -111,6 +112,7 @@ impl_timer!(TIMER2, TIMER2, TIMER2);
111impl_rng!(RNG, RNG, RNG); 112impl_rng!(RNG, RNG, RNG);
112 113
113impl_rtc!(RTC0, RTC0, RTC0); 114impl_rtc!(RTC0, RTC0, RTC0);
115#[cfg(not(feature = "time-driver-rtc1"))]
114impl_rtc!(RTC1, RTC1, RTC1); 116impl_rtc!(RTC1, RTC1, RTC1);
115 117
116impl_pin!(P0_00, 0, 0); 118impl_pin!(P0_00, 0, 0);
diff --git a/embassy-nrf/src/chips/nrf52805.rs b/embassy-nrf/src/chips/nrf52805.rs
index 427298a56..63ba6999a 100644
--- a/embassy-nrf/src/chips/nrf52805.rs
+++ b/embassy-nrf/src/chips/nrf52805.rs
@@ -12,6 +12,7 @@ pub const APPROTECT_MIN_BUILD_CODE: u8 = b'B';
12embassy_hal_internal::peripherals! { 12embassy_hal_internal::peripherals! {
13 // RTC 13 // RTC
14 RTC0, 14 RTC0,
15 #[cfg(not(feature="time-driver-rtc1"))]
15 RTC1, 16 RTC1,
16 17
17 // WDT 18 // WDT
@@ -157,6 +158,7 @@ impl_timer!(TIMER1, TIMER1, TIMER1);
157impl_timer!(TIMER2, TIMER2, TIMER2); 158impl_timer!(TIMER2, TIMER2, TIMER2);
158 159
159impl_rtc!(RTC0, RTC0, RTC0); 160impl_rtc!(RTC0, RTC0, RTC0);
161#[cfg(not(feature = "time-driver-rtc1"))]
160impl_rtc!(RTC1, RTC1, RTC1); 162impl_rtc!(RTC1, RTC1, RTC1);
161 163
162impl_pin!(P0_00, 0, 0); 164impl_pin!(P0_00, 0, 0);
@@ -237,12 +239,12 @@ embassy_hal_internal::interrupt_mod!(
237 TIMER0, 239 TIMER0,
238 TIMER1, 240 TIMER1,
239 TIMER2, 241 TIMER2,
240 RTC0,
241 TEMP, 242 TEMP,
242 RNG, 243 RNG,
243 ECB, 244 ECB,
244 AAR_CCM, 245 AAR_CCM,
245 WDT, 246 WDT,
247 RTC0,
246 RTC1, 248 RTC1,
247 QDEC, 249 QDEC,
248 EGU0_SWI0, 250 EGU0_SWI0,
diff --git a/embassy-nrf/src/chips/nrf52810.rs b/embassy-nrf/src/chips/nrf52810.rs
index c99b54265..7f744f9fb 100644
--- a/embassy-nrf/src/chips/nrf52810.rs
+++ b/embassy-nrf/src/chips/nrf52810.rs
@@ -12,6 +12,7 @@ pub const APPROTECT_MIN_BUILD_CODE: u8 = b'E';
12embassy_hal_internal::peripherals! { 12embassy_hal_internal::peripherals! {
13 // RTC 13 // RTC
14 RTC0, 14 RTC0,
15 #[cfg(not(feature="time-driver-rtc1"))]
15 RTC1, 16 RTC1,
16 17
17 // WDT 18 // WDT
@@ -167,6 +168,7 @@ impl_timer!(TIMER1, TIMER1, TIMER1);
167impl_timer!(TIMER2, TIMER2, TIMER2); 168impl_timer!(TIMER2, TIMER2, TIMER2);
168 169
169impl_rtc!(RTC0, RTC0, RTC0); 170impl_rtc!(RTC0, RTC0, RTC0);
171#[cfg(not(feature = "time-driver-rtc1"))]
170impl_rtc!(RTC1, RTC1, RTC1); 172impl_rtc!(RTC1, RTC1, RTC1);
171 173
172impl_pin!(P0_00, 0, 0); 174impl_pin!(P0_00, 0, 0);
diff --git a/embassy-nrf/src/chips/nrf52811.rs b/embassy-nrf/src/chips/nrf52811.rs
index 5f7a67f06..908167e31 100644
--- a/embassy-nrf/src/chips/nrf52811.rs
+++ b/embassy-nrf/src/chips/nrf52811.rs
@@ -12,6 +12,7 @@ pub const APPROTECT_MIN_BUILD_CODE: u8 = b'B';
12embassy_hal_internal::peripherals! { 12embassy_hal_internal::peripherals! {
13 // RTC 13 // RTC
14 RTC0, 14 RTC0,
15 #[cfg(not(feature="time-driver-rtc1"))]
15 RTC1, 16 RTC1,
16 17
17 // WDT 18 // WDT
@@ -169,6 +170,7 @@ impl_timer!(TIMER1, TIMER1, TIMER1);
169impl_timer!(TIMER2, TIMER2, TIMER2); 170impl_timer!(TIMER2, TIMER2, TIMER2);
170 171
171impl_rtc!(RTC0, RTC0, RTC0); 172impl_rtc!(RTC0, RTC0, RTC0);
173#[cfg(not(feature = "time-driver-rtc1"))]
172impl_rtc!(RTC1, RTC1, RTC1); 174impl_rtc!(RTC1, RTC1, RTC1);
173 175
174impl_pin!(P0_00, 0, 0); 176impl_pin!(P0_00, 0, 0);
diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs
index 1677fcf02..22360575b 100644
--- a/embassy-nrf/src/chips/nrf52820.rs
+++ b/embassy-nrf/src/chips/nrf52820.rs
@@ -15,6 +15,7 @@ embassy_hal_internal::peripherals! {
15 15
16 // RTC 16 // RTC
17 RTC0, 17 RTC0,
18 #[cfg(not(feature="time-driver-rtc1"))]
18 RTC1, 19 RTC1,
19 20
20 // WDT 21 // WDT
@@ -165,6 +166,7 @@ impl_timer!(TIMER2, TIMER2, TIMER2);
165impl_timer!(TIMER3, TIMER3, TIMER3, extended); 166impl_timer!(TIMER3, TIMER3, TIMER3, extended);
166 167
167impl_rtc!(RTC0, RTC0, RTC0); 168impl_rtc!(RTC0, RTC0, RTC0);
169#[cfg(not(feature = "time-driver-rtc1"))]
168impl_rtc!(RTC1, RTC1, RTC1); 170impl_rtc!(RTC1, RTC1, RTC1);
169 171
170impl_qdec!(QDEC, QDEC, QDEC); 172impl_qdec!(QDEC, QDEC, QDEC);
diff --git a/embassy-nrf/src/chips/nrf52832.rs b/embassy-nrf/src/chips/nrf52832.rs
index 6b735e218..1598df3fe 100644
--- a/embassy-nrf/src/chips/nrf52832.rs
+++ b/embassy-nrf/src/chips/nrf52832.rs
@@ -16,6 +16,7 @@ pub const APPROTECT_MIN_BUILD_CODE: u8 = b'G';
16embassy_hal_internal::peripherals! { 16embassy_hal_internal::peripherals! {
17 // RTC 17 // RTC
18 RTC0, 18 RTC0,
19 #[cfg(not(feature="time-driver-rtc1"))]
19 RTC1, 20 RTC1,
20 RTC2, 21 RTC2,
21 22
@@ -183,6 +184,7 @@ impl_twis!(TWISPI0, TWIS0, TWISPI0);
183impl_twis!(TWISPI1, TWIS1, TWISPI1); 184impl_twis!(TWISPI1, TWIS1, TWISPI1);
184 185
185impl_rtc!(RTC0, RTC0, RTC0); 186impl_rtc!(RTC0, RTC0, RTC0);
187#[cfg(not(feature = "time-driver-rtc1"))]
186impl_rtc!(RTC1, RTC1, RTC1); 188impl_rtc!(RTC1, RTC1, RTC1);
187impl_rtc!(RTC2, RTC2, RTC2); 189impl_rtc!(RTC2, RTC2, RTC2);
188 190
diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs
index b9c75f54b..6931fb064 100644
--- a/embassy-nrf/src/chips/nrf52833.rs
+++ b/embassy-nrf/src/chips/nrf52833.rs
@@ -15,6 +15,7 @@ embassy_hal_internal::peripherals! {
15 15
16 // RTC 16 // RTC
17 RTC0, 17 RTC0,
18 #[cfg(not(feature = "time-driver-rtc1"))]
18 RTC1, 19 RTC1,
19 RTC2, 20 RTC2,
20 21
@@ -224,6 +225,7 @@ impl_timer!(TIMER3, TIMER3, TIMER3, extended);
224impl_timer!(TIMER4, TIMER4, TIMER4, extended); 225impl_timer!(TIMER4, TIMER4, TIMER4, extended);
225 226
226impl_rtc!(RTC0, RTC0, RTC0); 227impl_rtc!(RTC0, RTC0, RTC0);
228#[cfg(not(feature = "time-driver-rtc1"))]
227impl_rtc!(RTC1, RTC1, RTC1); 229impl_rtc!(RTC1, RTC1, RTC1);
228impl_rtc!(RTC2, RTC2, RTC2); 230impl_rtc!(RTC2, RTC2, RTC2);
229 231
diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs
index ccfa1f747..5fa521aae 100644
--- a/embassy-nrf/src/chips/nrf52840.rs
+++ b/embassy-nrf/src/chips/nrf52840.rs
@@ -15,6 +15,7 @@ embassy_hal_internal::peripherals! {
15 15
16 // RTC 16 // RTC
17 RTC0, 17 RTC0,
18 #[cfg(not(feature = "time-driver-rtc1"))]
18 RTC1, 19 RTC1,
19 RTC2, 20 RTC2,
20 21
@@ -221,6 +222,7 @@ impl_timer!(TIMER3, TIMER3, TIMER3, extended);
221impl_timer!(TIMER4, TIMER4, TIMER4, extended); 222impl_timer!(TIMER4, TIMER4, TIMER4, extended);
222 223
223impl_rtc!(RTC0, RTC0, RTC0); 224impl_rtc!(RTC0, RTC0, RTC0);
225#[cfg(not(feature = "time-driver-rtc1"))]
224impl_rtc!(RTC1, RTC1, RTC1); 226impl_rtc!(RTC1, RTC1, RTC1);
225impl_rtc!(RTC2, RTC2, RTC2); 227impl_rtc!(RTC2, RTC2, RTC2);
226 228
diff --git a/embassy-nrf/src/chips/nrf5340_app.rs b/embassy-nrf/src/chips/nrf5340_app.rs
index eb429db21..730c9842d 100644
--- a/embassy-nrf/src/chips/nrf5340_app.rs
+++ b/embassy-nrf/src/chips/nrf5340_app.rs
@@ -168,6 +168,7 @@ embassy_hal_internal::peripherals! {
168 168
169 // RTC 169 // RTC
170 RTC0, 170 RTC0,
171 #[cfg(not(feature = "time-driver-rtc1"))]
171 RTC1, 172 RTC1,
172 173
173 // WDT 174 // WDT
@@ -370,6 +371,7 @@ impl_timer!(TIMER1, TIMER1, TIMER1);
370impl_timer!(TIMER2, TIMER2, TIMER2); 371impl_timer!(TIMER2, TIMER2, TIMER2);
371 372
372impl_rtc!(RTC0, RTC0, RTC0); 373impl_rtc!(RTC0, RTC0, RTC0);
374#[cfg(not(feature = "time-driver-rtc1"))]
373impl_rtc!(RTC1, RTC1, RTC1); 375impl_rtc!(RTC1, RTC1, RTC1);
374 376
375impl_qspi!(QSPI, QSPI, QSPI); 377impl_qspi!(QSPI, QSPI, QSPI);
diff --git a/embassy-nrf/src/chips/nrf5340_net.rs b/embassy-nrf/src/chips/nrf5340_net.rs
index a8de288a9..413afc5c5 100644
--- a/embassy-nrf/src/chips/nrf5340_net.rs
+++ b/embassy-nrf/src/chips/nrf5340_net.rs
@@ -59,6 +59,7 @@ pub const FLASH_SIZE: usize = 256 * 1024;
59embassy_hal_internal::peripherals! { 59embassy_hal_internal::peripherals! {
60 // RTC 60 // RTC
61 RTC0, 61 RTC0,
62 #[cfg(not(feature = "time-driver-rtc1"))]
62 RTC1, 63 RTC1,
63 64
64 // WDT 65 // WDT
@@ -219,6 +220,7 @@ impl_timer!(TIMER1, TIMER1, TIMER1);
219impl_timer!(TIMER2, TIMER2, TIMER2); 220impl_timer!(TIMER2, TIMER2, TIMER2);
220 221
221impl_rtc!(RTC0, RTC0, RTC0); 222impl_rtc!(RTC0, RTC0, RTC0);
223#[cfg(not(feature = "time-driver-rtc1"))]
222impl_rtc!(RTC1, RTC1, RTC1); 224impl_rtc!(RTC1, RTC1, RTC1);
223 225
224impl_rng!(RNG, RNG, RNG); 226impl_rng!(RNG, RNG, RNG);
diff --git a/embassy-nrf/src/chips/nrf9120.rs b/embassy-nrf/src/chips/nrf9120.rs
index 9008a23a8..5aee19d97 100644
--- a/embassy-nrf/src/chips/nrf9120.rs
+++ b/embassy-nrf/src/chips/nrf9120.rs
@@ -131,6 +131,7 @@ pub const FLASH_SIZE: usize = 1024 * 1024;
131embassy_hal_internal::peripherals! { 131embassy_hal_internal::peripherals! {
132 // RTC 132 // RTC
133 RTC0, 133 RTC0,
134 #[cfg(not(feature = "time-driver-rtc1"))]
134 RTC1, 135 RTC1,
135 136
136 // WDT 137 // WDT
@@ -277,6 +278,7 @@ impl_timer!(TIMER1, TIMER1, TIMER1);
277impl_timer!(TIMER2, TIMER2, TIMER2); 278impl_timer!(TIMER2, TIMER2, TIMER2);
278 279
279impl_rtc!(RTC0, RTC0, RTC0); 280impl_rtc!(RTC0, RTC0, RTC0);
281#[cfg(not(feature = "time-driver-rtc1"))]
280impl_rtc!(RTC1, RTC1, RTC1); 282impl_rtc!(RTC1, RTC1, RTC1);
281 283
282impl_pin!(P0_00, 0, 0); 284impl_pin!(P0_00, 0, 0);
diff --git a/embassy-nrf/src/chips/nrf9160.rs b/embassy-nrf/src/chips/nrf9160.rs
index dbb06d71a..64aec217c 100644
--- a/embassy-nrf/src/chips/nrf9160.rs
+++ b/embassy-nrf/src/chips/nrf9160.rs
@@ -131,6 +131,7 @@ pub const FLASH_SIZE: usize = 1024 * 1024;
131embassy_hal_internal::peripherals! { 131embassy_hal_internal::peripherals! {
132 // RTC 132 // RTC
133 RTC0, 133 RTC0,
134 #[cfg(not(feature = "time-driver-rtc1"))]
134 RTC1, 135 RTC1,
135 136
136 // WDT 137 // WDT
@@ -277,6 +278,7 @@ impl_timer!(TIMER1, TIMER1, TIMER1);
277impl_timer!(TIMER2, TIMER2, TIMER2); 278impl_timer!(TIMER2, TIMER2, TIMER2);
278 279
279impl_rtc!(RTC0, RTC0, RTC0); 280impl_rtc!(RTC0, RTC0, RTC0);
281#[cfg(not(feature = "time-driver-rtc1"))]
280impl_rtc!(RTC1, RTC1, RTC1); 282impl_rtc!(RTC1, RTC1, RTC1);
281 283
282impl_pin!(P0_00, 0, 0); 284impl_pin!(P0_00, 0, 0);
diff --git a/embassy-nrf/src/rtc.rs b/embassy-nrf/src/rtc.rs
index 5dd427fde..1a90d1e24 100644
--- a/embassy-nrf/src/rtc.rs
+++ b/embassy-nrf/src/rtc.rs
@@ -17,11 +17,6 @@ pub struct PrescalerOutOfRangeError(u32);
17#[cfg_attr(feature = "defmt", derive(defmt::Format))] 17#[cfg_attr(feature = "defmt", derive(defmt::Format))]
18pub struct CompareOutOfRangeError(u32); 18pub struct CompareOutOfRangeError(u32);
19 19
20/// Compare register is not implemented for RTC0.
21#[derive(Debug, PartialEq, Eq)]
22#[cfg_attr(feature = "defmt", derive(defmt::Format))]
23pub struct CompareRegNotImplementedError;
24
25/// Interrupts/Events that can be generated by the RTCn peripheral. 20/// Interrupts/Events that can be generated by the RTCn peripheral.
26#[derive(Debug, Copy, Clone, PartialEq, Eq)] 21#[derive(Debug, Copy, Clone, PartialEq, Eq)]
27#[cfg_attr(feature = "defmt", derive(defmt::Format))] 22#[cfg_attr(feature = "defmt", derive(defmt::Format))]
@@ -93,15 +88,12 @@ macro_rules! impl_rtc {
93} 88}
94 89
95/// nRF RTC driver. 90/// nRF RTC driver.
96///
97/// If the `time-driver-rtc1` feature is enabled, the creation of a driver with RTC1 will conflict
98/// with the time driver implementation.
99pub struct Rtc<'d, T: Instance>(Peri<'d, T>); 91pub struct Rtc<'d, T: Instance>(Peri<'d, T>);
100 92
101impl<'d, T: Instance> Rtc<'d, T> { 93impl<'d, T: Instance> Rtc<'d, T> {
102 /// Create a new `Rtc` driver. 94 /// Create a new `Rtc` driver.
103 /// 95 ///
104 /// fRTC = 32_768 / (`prescaler` + 1 ) 96 /// fRTC \[Hz\] = 32_768 / (`prescaler` + 1 )
105 pub fn new(rtc: Peri<'d, T>, prescaler: u32) -> Result<Self, PrescalerOutOfRangeError> { 97 pub fn new(rtc: Peri<'d, T>, prescaler: u32) -> Result<Self, PrescalerOutOfRangeError> {
106 if prescaler >= (1 << 12) { 98 if prescaler >= (1 << 12) {
107 return Err(PrescalerOutOfRangeError(prescaler)); 99 return Err(PrescalerOutOfRangeError(prescaler));
@@ -128,6 +120,7 @@ impl<'d, T: Instance> Rtc<'d, T> {
128 } 120 }
129 121
130 /// Direct access to the RTC registers. 122 /// Direct access to the RTC registers.
123 #[cfg(feature = "unstable-pac")]
131 #[inline] 124 #[inline]
132 pub fn regs(&mut self) -> pac::rtc::Rtc { 125 pub fn regs(&mut self) -> pac::rtc::Rtc {
133 T::regs() 126 T::regs()
@@ -145,7 +138,7 @@ impl<'d, T: Instance> Rtc<'d, T> {
145 T::regs().tasks_stop().write_value(1); 138 T::regs().tasks_stop().write_value(1);
146 } 139 }
147 140
148 /// Enables interrupts for the given [RtcInterrupt] source. 141 /// Enables interrupts for the given [Interrupt] source.
149 /// 142 ///
150 /// Optionally also enables the interrupt in the NVIC. 143 /// Optionally also enables the interrupt in the NVIC.
151 pub fn enable_interrupt(&mut self, int: Interrupt, enable_in_nvic: bool) { 144 pub fn enable_interrupt(&mut self, int: Interrupt, enable_in_nvic: bool) {
@@ -163,7 +156,7 @@ impl<'d, T: Instance> Rtc<'d, T> {
163 } 156 }
164 } 157 }
165 158
166 /// Disables interrupts for the given [RtcInterrupt] source. 159 /// Disables interrupts for the given [Interrupt] source.
167 /// 160 ///
168 /// Optionally also disables the interrupt in the NVIC. 161 /// Optionally also disables the interrupt in the NVIC.
169 pub fn disable_interrupt(&mut self, int: Interrupt, disable_in_nvic: bool) { 162 pub fn disable_interrupt(&mut self, int: Interrupt, disable_in_nvic: bool) {