Skip to content

Commit 2fb6eb0

Browse files
bors[bot]refugeesus
andcommitted
Merge tock#1127
1127: Launchxl Alarm Bug: Fix issue of board main.rs calling wrong rtc r=alevy a=refugeesus Alarm will not call correctly otherwise ### Pull Request Overview This pull request fixes a bug where the kernel will seem to run correctly but no Alarm callback is called because launchxl main.rs implements Platform { ... alarm: ...} with the wrong rtc, breaking the AlarmDriver. ### Testing Strategy Tested by running blink application which uses alarm for toggling the LED's ### Formatting - [ ] Ran `make formatall`. Co-authored-by: Robert Keith <robertfkeith@me.com>
2 parents a68a19e + e4d08fa commit 2fb6eb0

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

boards/launchxl/src/main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ extern crate cc26xx;
1212
#[macro_use(debug, debug_gpio, static_init)]
1313
extern crate kernel;
1414

15-
use cc26xx::aon;
16-
use cc26xx::prcm;
15+
use cc26x2::aon;
16+
use cc26x2::prcm;
1717

1818
#[macro_use]
1919
pub mod io;
@@ -42,7 +42,7 @@ pub struct Platform {
4242
button: &'static capsules::button::Button<'static, cc26xx::gpio::GPIOPin>,
4343
alarm: &'static capsules::alarm::AlarmDriver<
4444
'static,
45-
capsules::virtual_alarm::VirtualMuxAlarm<'static, cc26xx::rtc::Rtc>,
45+
capsules::virtual_alarm::VirtualMuxAlarm<'static, cc26x2::rtc::Rtc>,
4646
>,
4747
rng: &'static capsules::rng::SimpleRng<'static, cc26xx::trng::Trng>,
4848
}
@@ -69,7 +69,7 @@ pub unsafe fn reset_handler() {
6969
cc26x2::init();
7070

7171
// Setup AON event defaults
72-
aon::AON_EVENT.setup();
72+
aon::AON.setup();
7373

7474
// Power on peripherals (eg. GPIO)
7575
prcm::Power::enable_domain(prcm::PowerDomain::Peripherals);
@@ -179,23 +179,23 @@ pub unsafe fn reset_handler() {
179179
pin.set_client(gpio);
180180
}
181181

182-
let rtc = &cc26xx::rtc::RTC;
182+
let rtc = &cc26x2::rtc::RTC;
183183
rtc.start();
184184

185185
let mux_alarm = static_init!(
186-
capsules::virtual_alarm::MuxAlarm<'static, cc26xx::rtc::Rtc>,
187-
capsules::virtual_alarm::MuxAlarm::new(&cc26xx::rtc::RTC)
186+
capsules::virtual_alarm::MuxAlarm<'static, cc26x2::rtc::Rtc>,
187+
capsules::virtual_alarm::MuxAlarm::new(&cc26x2::rtc::RTC)
188188
);
189189
rtc.set_client(mux_alarm);
190190

191191
let virtual_alarm1 = static_init!(
192-
capsules::virtual_alarm::VirtualMuxAlarm<'static, cc26xx::rtc::Rtc>,
192+
capsules::virtual_alarm::VirtualMuxAlarm<'static, cc26x2::rtc::Rtc>,
193193
capsules::virtual_alarm::VirtualMuxAlarm::new(mux_alarm)
194194
);
195195
let alarm = static_init!(
196196
capsules::alarm::AlarmDriver<
197197
'static,
198-
capsules::virtual_alarm::VirtualMuxAlarm<'static, cc26xx::rtc::Rtc>,
198+
capsules::virtual_alarm::VirtualMuxAlarm<'static, cc26x2::rtc::Rtc>,
199199
>,
200200
capsules::alarm::AlarmDriver::new(virtual_alarm1, kernel::Grant::create())
201201
);

chips/cc26x2/Cargo.lock

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chips/cc26x2/src/rtc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! RTC driver
22
3-
use core::cell::Cell;
3+
use kernel::common::cells::OptionalCell;
44
use kernel::common::registers::{ReadOnly, ReadWrite};
55
use kernel::common::StaticRef;
66
use kernel::hil::time::{self, Alarm, Frequency, Time};
@@ -62,7 +62,7 @@ const RTC_BASE: StaticRef<RtcRegisters> =
6262

6363
pub struct Rtc {
6464
registers: StaticRef<RtcRegisters>,
65-
callback: Cell<Option<&'static time::Client>>,
65+
callback: OptionalCell<&'static time::Client>,
6666
}
6767

6868
pub static mut RTC: Rtc = Rtc::new();
@@ -71,7 +71,7 @@ impl Rtc {
7171
const fn new() -> Rtc {
7272
Rtc {
7373
registers: RTC_BASE,
74-
callback: Cell::new(None),
74+
callback: OptionalCell::empty(),
7575
}
7676
}
7777

@@ -129,11 +129,11 @@ impl Rtc {
129129

130130
regs.sync.get();
131131

132-
self.callback.get().map(|cb| cb.fired());
132+
self.callback.map(|cb| cb.fired());
133133
}
134134

135135
pub fn set_client(&self, client: &'static time::Client) {
136-
self.callback.set(Some(client));
136+
self.callback.set(client);
137137
}
138138

139139
pub fn set_upd_en(&self, value: bool) {

0 commit comments

Comments
 (0)