Skip to content

Commit

Permalink
Rename rtc methods
Browse files Browse the repository at this point in the history
  • Loading branch information
thalesfragoso committed Aug 20, 2019
1 parent 8eed700 commit 1b6a080
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Change timer/pwm init API
- Remove `set_low` and `set_high` for pins in Alternate output mode
- Renames `set_seconds` and `seconds` methods on RTC to `set_time` and `current_time`, respectively

### Changed

- DMA traits now require AsSlice instead of AsRef
- Add `micros_since` and `reset` methods to timer
- Add `select_frequency` method to rtc
- Add `select_frequency` method to RTC

### Changed

Expand Down
2 changes: 1 addition & 1 deletion examples/blinky_rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn main() -> ! {
let mut led_on = false;
loop {
// Set the current time to 0
rtc.set_seconds(0);
rtc.set_time(0);
// Trigger the alarm in 5 seconds
rtc.set_alarm(5);
block!(rtc.wait_alarm()).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ fn main() -> ! {
let rtc = Rtc::rtc(p.RTC, &mut backup_domain);

loop {
hprintln!("time: {}", rtc.seconds()).unwrap();
hprintln!("time: {}", rtc.current_time()).unwrap();
}
}
5 changes: 2 additions & 3 deletions src/rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub struct Rtc {
regs: RTC,
}


impl Rtc {
/**
Initialises the RTC. The `BackupDomain` struct is created by
Expand Down Expand Up @@ -88,7 +87,7 @@ impl Rtc {
}

/// Set the current rtc counter value to the specified amount
pub fn set_seconds(&mut self, seconds: u32) {
pub fn set_time(&mut self, seconds: u32) {
self.perform_write(|s| {
s.regs.cnth.write(|w| unsafe{w.bits(seconds >> 16)});
s.regs.cntl.write(|w| unsafe{w.bits(seconds as u16 as u32)});
Expand Down Expand Up @@ -129,7 +128,7 @@ impl Rtc {
}

/// Reads the current counter
pub fn seconds(&self) -> u32 {
pub fn current_time(&self) -> u32 {
// Wait for the APB1 interface to be ready
while self.regs.crl.read().rsf().bit() == false {}

Expand Down
4 changes: 2 additions & 2 deletions src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl CountDownTimer<SYST> {
/// it is very easy to lose an update event.
pub fn micros_since(&self) -> u32 {
let reload_value = SYST::get_reload();
let timer_clock = u64(self.clocks.sysclk().0);
let timer_clock = u64(self.clk.0);
let ticks = u64(reload_value - SYST::get_current());

// It is safe to make this cast since the maximum ticks is (2^24 - 1) and the minimum sysclk
Expand Down Expand Up @@ -198,7 +198,7 @@ macro_rules! hal {
/// *NOTE:* This method is not a very good candidate to keep track of time, because
/// it is very easy to lose an update event.
pub fn micros_since(&self) -> u32 {
let timer_clock = $TIMX::get_clk(&self.clocks).0;
let timer_clock = self.clk.0;
let psc = u32(self.tim.psc.read().psc().bits());

// freq_divider is always bigger than 0, since (psc + 1) is always less than
Expand Down

0 comments on commit 1b6a080

Please sign in to comment.