Skip to content

Commit

Permalink
Rename Lap->Elapsed
Browse files Browse the repository at this point in the history
  • Loading branch information
nickray committed May 2, 2021
1 parent 5c70be5 commit 7558669
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Add INPUTMUX and PINT peripherals
- Add example using PINT + INPUTMUX to make an external interrupt on a pin

## [v0.2.1] - 2021-05-02
Fix the "lap" naming

## [v0.2.0] - 2021-05-02
Bump lpc55-pac and cipher
Replace homegrown "time" with embedded-time
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lpc55-hal"
version = "0.2.0"
version = "0.2.1"
edition = "2018"
description = "Hardware Abstraction Layer (HAL) for the NXP LPC55S6x ARM Cortex-33 microcontrollers"
repository = "https://github.com/nickray/lpc55-hal"
Expand Down
4 changes: 2 additions & 2 deletions examples/ctimer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use cortex_m_semihosting::heprintln;
use lpc55_hal as hal;
use hal::prelude::*;

use hal::drivers::timer::Lap;
use hal::drivers::timer::Elapsed;

#[macro_use(block)]
extern crate nb;
Expand Down Expand Up @@ -41,7 +41,7 @@ fn main() -> ! {
loop {
cdriver.start(1_000_000.microseconds());
dbg!(c * 1_000_000);
dbg!(cdriver.lap().0);
dbg!(cdriver.elapsed().0);
c += 1;
block!(cdriver.wait()).unwrap(); // blocks for 1 second
}
Expand Down
4 changes: 2 additions & 2 deletions examples/measure_frequency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use lpc55_hal as hal;
use hal::{
drivers::{
Timer,
timer::Lap,
timer::Elapsed,
},
prelude::*,
};
Expand Down Expand Up @@ -54,7 +54,7 @@ fn main() -> ! {

delay_cycles(10_000_000);

let us = timer.lap().0;
let us = timer.elapsed().0;
timer.cancel().ok();

heprintln!("{} MHz", 10_000_000 / us).ok();
Expand Down
8 changes: 4 additions & 4 deletions src/drivers/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use crate::{

/// Return the current time elapsed for the timer.
/// If the timer has not started or stopped, this unit may not be accurate.
pub trait Lap <Unit>{
fn lap(&self) -> Unit;
pub trait Elapsed: timer::CountDown {
fn elapsed(&self) -> Self::Time;
}

pub struct Timer<TIMER>
Expand All @@ -40,9 +40,9 @@ where TIMER: Ctimer<init_state::Enabled> {

type TimeUnits = Microseconds;

impl <TIMER> Lap<TimeUnits> for Timer<TIMER>
impl <TIMER> Elapsed for Timer<TIMER>
where TIMER: Ctimer<init_state::Enabled> {
fn lap(&self) -> TimeUnits{
fn elapsed(&self) -> Microseconds {
Microseconds(self.timer.tc.read().bits())
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/drivers/touch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
Pin,
pins,
timer,
timer::Lap,
timer::Elapsed,
},
peripherals::{
ctimer,
Expand Down Expand Up @@ -416,7 +416,7 @@ pub fn profile_touch_sensing(touch_sensor: &mut TouchSensor<impl PinId, impl Pin
times: &mut [u32],
){

let start = delay_timer.lap().0;
let start = delay_timer.elapsed().0;
let results = touch_sensor.get_results();

delay_timer.start(300_000.microseconds());
Expand All @@ -426,7 +426,7 @@ pub fn profile_touch_sensing(touch_sensor: &mut TouchSensor<impl PinId, impl Pin
for i in 0 .. 125 {
if results[i] != 0 {
if times[i] == 0 {
times[i] = delay_timer.lap().0 - start;
times[i] = delay_timer.elapsed().0 - start;
copy[i] = results[i];
}
}
Expand Down

0 comments on commit 7558669

Please sign in to comment.