Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launchxl Alarm Bug: Fix issue of board main.rs calling wrong rtc #1127

Merged
merged 1 commit into from
Jul 19, 2018
Merged
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
18 changes: 9 additions & 9 deletions boards/launchxl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ extern crate cc26xx;
#[macro_use(debug, debug_gpio, static_init)]
extern crate kernel;

use cc26xx::aon;
use cc26xx::prcm;
use cc26x2::aon;
use cc26x2::prcm;

#[macro_use]
pub mod io;
Expand Down Expand Up @@ -42,7 +42,7 @@ pub struct Platform {
button: &'static capsules::button::Button<'static, cc26xx::gpio::GPIOPin>,
alarm: &'static capsules::alarm::AlarmDriver<
'static,
capsules::virtual_alarm::VirtualMuxAlarm<'static, cc26xx::rtc::Rtc>,
capsules::virtual_alarm::VirtualMuxAlarm<'static, cc26x2::rtc::Rtc>,
>,
rng: &'static capsules::rng::SimpleRng<'static, cc26xx::trng::Trng>,
}
Expand All @@ -69,7 +69,7 @@ pub unsafe fn reset_handler() {
cc26x2::init();

// Setup AON event defaults
aon::AON_EVENT.setup();
aon::AON.setup();

// Power on peripherals (eg. GPIO)
prcm::Power::enable_domain(prcm::PowerDomain::Peripherals);
Expand Down Expand Up @@ -179,23 +179,23 @@ pub unsafe fn reset_handler() {
pin.set_client(gpio);
}

let rtc = &cc26xx::rtc::RTC;
let rtc = &cc26x2::rtc::RTC;
rtc.start();

let mux_alarm = static_init!(
capsules::virtual_alarm::MuxAlarm<'static, cc26xx::rtc::Rtc>,
capsules::virtual_alarm::MuxAlarm::new(&cc26xx::rtc::RTC)
capsules::virtual_alarm::MuxAlarm<'static, cc26x2::rtc::Rtc>,
capsules::virtual_alarm::MuxAlarm::new(&cc26x2::rtc::RTC)
);
rtc.set_client(mux_alarm);

let virtual_alarm1 = static_init!(
capsules::virtual_alarm::VirtualMuxAlarm<'static, cc26xx::rtc::Rtc>,
capsules::virtual_alarm::VirtualMuxAlarm<'static, cc26x2::rtc::Rtc>,
capsules::virtual_alarm::VirtualMuxAlarm::new(mux_alarm)
);
let alarm = static_init!(
capsules::alarm::AlarmDriver<
'static,
capsules::virtual_alarm::VirtualMuxAlarm<'static, cc26xx::rtc::Rtc>,
capsules::virtual_alarm::VirtualMuxAlarm<'static, cc26x2::rtc::Rtc>,
>,
capsules::alarm::AlarmDriver::new(virtual_alarm1, kernel::Grant::create())
);
Expand Down
9 changes: 7 additions & 2 deletions chips/cc26x2/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions chips/cc26x2/src/rtc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! RTC driver

use core::cell::Cell;
use kernel::common::cells::OptionalCell;
use kernel::common::registers::{ReadOnly, ReadWrite};
use kernel::common::StaticRef;
use kernel::hil::time::{self, Alarm, Frequency, Time};
Expand Down Expand Up @@ -62,7 +62,7 @@ const RTC_BASE: StaticRef<RtcRegisters> =

pub struct Rtc {
registers: StaticRef<RtcRegisters>,
callback: Cell<Option<&'static time::Client>>,
callback: OptionalCell<&'static time::Client>,
}

pub static mut RTC: Rtc = Rtc::new();
Expand All @@ -71,7 +71,7 @@ impl Rtc {
const fn new() -> Rtc {
Rtc {
registers: RTC_BASE,
callback: Cell::new(None),
callback: OptionalCell::empty(),
}
}

Expand Down Expand Up @@ -129,11 +129,11 @@ impl Rtc {

regs.sync.get();

self.callback.get().map(|cb| cb.fired());
self.callback.map(|cb| cb.fired());
}

pub fn set_client(&self, client: &'static time::Client) {
self.callback.set(Some(client));
self.callback.set(client);
}

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