Skip to content

Commit a25c5c4

Browse files
authored
Merge pull request #4686 from robamu/add-nrf-rtc-driver
add basic RTC driver for nRF
2 parents 7681825 + e9232bf commit a25c5c4

File tree

17 files changed

+391
-1
lines changed

17 files changed

+391
-1
lines changed

embassy-nrf/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
- changed: nrf54l: Disable glitch detection and enable DC/DC in init.
1212
- changed: Add embassy-net-driver-channel implementation for IEEE 802.15.4
13+
- changed: add persist() method for gpio and ppi
14+
- added: basic RTC driver
1315
- changed: add persist() method for gpio, gpiote, timer and ppi
1416
- changed: impl Drop for Timer
1517

embassy-nrf/src/chips/nrf51.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub const FLASH_SIZE: usize = 128 * 1024;
88
embassy_hal_internal::peripherals! {
99
// RTC
1010
RTC0,
11+
#[cfg(not(feature = "time-driver-rtc1"))]
1112
RTC1,
1213

1314
// WDT
@@ -110,6 +111,10 @@ impl_timer!(TIMER2, TIMER2, TIMER2);
110111

111112
impl_rng!(RNG, RNG, RNG);
112113

114+
impl_rtc!(RTC0, RTC0, RTC0);
115+
#[cfg(not(feature = "time-driver-rtc1"))]
116+
impl_rtc!(RTC1, RTC1, RTC1);
117+
113118
impl_pin!(P0_00, 0, 0);
114119
impl_pin!(P0_01, 0, 1);
115120
impl_pin!(P0_02, 0, 2);

embassy-nrf/src/chips/nrf52805.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub const APPROTECT_MIN_BUILD_CODE: u8 = b'B';
1212
embassy_hal_internal::peripherals! {
1313
// RTC
1414
RTC0,
15+
#[cfg(not(feature="time-driver-rtc1"))]
1516
RTC1,
1617

1718
// WDT
@@ -156,6 +157,10 @@ impl_timer!(TIMER0, TIMER0, TIMER0);
156157
impl_timer!(TIMER1, TIMER1, TIMER1);
157158
impl_timer!(TIMER2, TIMER2, TIMER2);
158159

160+
impl_rtc!(RTC0, RTC0, RTC0);
161+
#[cfg(not(feature = "time-driver-rtc1"))]
162+
impl_rtc!(RTC1, RTC1, RTC1);
163+
159164
impl_pin!(P0_00, 0, 0);
160165
impl_pin!(P0_01, 0, 1);
161166
impl_pin!(P0_02, 0, 2);
@@ -234,12 +239,12 @@ embassy_hal_internal::interrupt_mod!(
234239
TIMER0,
235240
TIMER1,
236241
TIMER2,
237-
RTC0,
238242
TEMP,
239243
RNG,
240244
ECB,
241245
AAR_CCM,
242246
WDT,
247+
RTC0,
243248
RTC1,
244249
QDEC,
245250
EGU0_SWI0,

embassy-nrf/src/chips/nrf52810.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub const APPROTECT_MIN_BUILD_CODE: u8 = b'E';
1212
embassy_hal_internal::peripherals! {
1313
// RTC
1414
RTC0,
15+
#[cfg(not(feature="time-driver-rtc1"))]
1516
RTC1,
1617

1718
// WDT
@@ -166,6 +167,10 @@ impl_timer!(TIMER0, TIMER0, TIMER0);
166167
impl_timer!(TIMER1, TIMER1, TIMER1);
167168
impl_timer!(TIMER2, TIMER2, TIMER2);
168169

170+
impl_rtc!(RTC0, RTC0, RTC0);
171+
#[cfg(not(feature = "time-driver-rtc1"))]
172+
impl_rtc!(RTC1, RTC1, RTC1);
173+
169174
impl_pin!(P0_00, 0, 0);
170175
impl_pin!(P0_01, 0, 1);
171176
impl_pin!(P0_02, 0, 2);

embassy-nrf/src/chips/nrf52811.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub const APPROTECT_MIN_BUILD_CODE: u8 = b'B';
1212
embassy_hal_internal::peripherals! {
1313
// RTC
1414
RTC0,
15+
#[cfg(not(feature="time-driver-rtc1"))]
1516
RTC1,
1617

1718
// WDT
@@ -168,6 +169,10 @@ impl_timer!(TIMER0, TIMER0, TIMER0);
168169
impl_timer!(TIMER1, TIMER1, TIMER1);
169170
impl_timer!(TIMER2, TIMER2, TIMER2);
170171

172+
impl_rtc!(RTC0, RTC0, RTC0);
173+
#[cfg(not(feature = "time-driver-rtc1"))]
174+
impl_rtc!(RTC1, RTC1, RTC1);
175+
171176
impl_pin!(P0_00, 0, 0);
172177
impl_pin!(P0_01, 0, 1);
173178
impl_pin!(P0_02, 0, 2);

embassy-nrf/src/chips/nrf52820.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ embassy_hal_internal::peripherals! {
1515

1616
// RTC
1717
RTC0,
18+
#[cfg(not(feature="time-driver-rtc1"))]
1819
RTC1,
1920

2021
// WDT
@@ -164,6 +165,10 @@ impl_timer!(TIMER1, TIMER1, TIMER1);
164165
impl_timer!(TIMER2, TIMER2, TIMER2);
165166
impl_timer!(TIMER3, TIMER3, TIMER3, extended);
166167

168+
impl_rtc!(RTC0, RTC0, RTC0);
169+
#[cfg(not(feature = "time-driver-rtc1"))]
170+
impl_rtc!(RTC1, RTC1, RTC1);
171+
167172
impl_qdec!(QDEC, QDEC, QDEC);
168173

169174
impl_rng!(RNG, RNG, RNG);

embassy-nrf/src/chips/nrf52832.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub const APPROTECT_MIN_BUILD_CODE: u8 = b'G';
1616
embassy_hal_internal::peripherals! {
1717
// RTC
1818
RTC0,
19+
#[cfg(not(feature="time-driver-rtc1"))]
1920
RTC1,
2021
RTC2,
2122

@@ -182,6 +183,11 @@ impl_twim!(TWISPI1, TWIM1, TWISPI1);
182183
impl_twis!(TWISPI0, TWIS0, TWISPI0);
183184
impl_twis!(TWISPI1, TWIS1, TWISPI1);
184185

186+
impl_rtc!(RTC0, RTC0, RTC0);
187+
#[cfg(not(feature = "time-driver-rtc1"))]
188+
impl_rtc!(RTC1, RTC1, RTC1);
189+
impl_rtc!(RTC2, RTC2, RTC2);
190+
185191
impl_pwm!(PWM0, PWM0, PWM0);
186192
impl_pwm!(PWM1, PWM1, PWM1);
187193
impl_pwm!(PWM2, PWM2, PWM2);

embassy-nrf/src/chips/nrf52833.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ embassy_hal_internal::peripherals! {
1515

1616
// RTC
1717
RTC0,
18+
#[cfg(not(feature = "time-driver-rtc1"))]
1819
RTC1,
1920
RTC2,
2021

@@ -223,6 +224,11 @@ impl_timer!(TIMER2, TIMER2, TIMER2);
223224
impl_timer!(TIMER3, TIMER3, TIMER3, extended);
224225
impl_timer!(TIMER4, TIMER4, TIMER4, extended);
225226

227+
impl_rtc!(RTC0, RTC0, RTC0);
228+
#[cfg(not(feature = "time-driver-rtc1"))]
229+
impl_rtc!(RTC1, RTC1, RTC1);
230+
impl_rtc!(RTC2, RTC2, RTC2);
231+
226232
impl_pin!(P0_00, 0, 0);
227233
impl_pin!(P0_01, 0, 1);
228234
impl_pin!(P0_02, 0, 2);

embassy-nrf/src/chips/nrf52840.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ embassy_hal_internal::peripherals! {
1515

1616
// RTC
1717
RTC0,
18+
#[cfg(not(feature = "time-driver-rtc1"))]
1819
RTC1,
1920
RTC2,
2021

@@ -220,6 +221,11 @@ impl_timer!(TIMER2, TIMER2, TIMER2);
220221
impl_timer!(TIMER3, TIMER3, TIMER3, extended);
221222
impl_timer!(TIMER4, TIMER4, TIMER4, extended);
222223

224+
impl_rtc!(RTC0, RTC0, RTC0);
225+
#[cfg(not(feature = "time-driver-rtc1"))]
226+
impl_rtc!(RTC1, RTC1, RTC1);
227+
impl_rtc!(RTC2, RTC2, RTC2);
228+
223229
impl_qspi!(QSPI, QSPI, QSPI);
224230

225231
impl_pdm!(PDM, PDM, PDM);

embassy-nrf/src/chips/nrf5340_app.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ embassy_hal_internal::peripherals! {
168168

169169
// RTC
170170
RTC0,
171+
#[cfg(not(feature = "time-driver-rtc1"))]
171172
RTC1,
172173

173174
// WDT
@@ -369,6 +370,10 @@ impl_timer!(TIMER0, TIMER0, TIMER0);
369370
impl_timer!(TIMER1, TIMER1, TIMER1);
370371
impl_timer!(TIMER2, TIMER2, TIMER2);
371372

373+
impl_rtc!(RTC0, RTC0, RTC0);
374+
#[cfg(not(feature = "time-driver-rtc1"))]
375+
impl_rtc!(RTC1, RTC1, RTC1);
376+
372377
impl_qspi!(QSPI, QSPI, QSPI);
373378

374379
impl_pdm!(PDM0, PDM0, PDM0);

0 commit comments

Comments
 (0)