Skip to content

Commit 9977521

Browse files
authored
Merge pull request #22 from FluenTech/unsigned
Change all time-related struct inner types to unsigned
2 parents 522c03d + 7faf5b7 commit 9977521

File tree

8 files changed

+412
-306
lines changed

8 files changed

+412
-306
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44

55
### Added
66

7+
- `Instant::duration_until()` with order checking
8+
- Order checking to `Instant::duration_since()`
9+
- Bounds checking on `Instant` impls of Add/Sub
710
- Changelog back to v0.5.0 release
811

912
### Changed
1013

14+
- All time-type inner types from signed to unsigned
15+
- `Instant::duration_since()` return type to `Result`
1116
- Refactor `examples/nrf52_dk`
1217

1318
[unreleased]: https://github.com/FluenTech/embedded-time/compare/v0.5.2...HEAD

examples/nrf52_dk/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate panic_rtt;
55

66
use cortex_m::mutex::CriticalSectionMutex as Mutex;
77
use cortex_m_rt::entry;
8-
use embedded_time::{self as time, Clock, Instant, Period, TimeInt};
8+
use embedded_time::{self as time, traits::*, Clock, Instant, Period};
99
use mutex_trait::Mutex as _;
1010

1111
pub mod nrf52 {
@@ -40,8 +40,8 @@ pub mod nrf52 {
4040
pub struct SysClock;
4141

4242
impl time::Clock for SysClock {
43-
type Rep = i64;
44-
const PERIOD: Period = Period::new(1, 16_000_000);
43+
type Rep = u64;
44+
const PERIOD: Period = <Period>::new(1, 16_000_000);
4545

4646
fn now() -> Instant<Self> {
4747
let ticks = (&CLOCK64).lock(|clock| match clock {
@@ -156,12 +156,12 @@ where
156156
led2.set_high()?;
157157
led3.set_high()?;
158158
led4.set_low()?;
159-
SysClock::delay(250.milliseconds());
159+
SysClock::delay(250_u32.milliseconds());
160160

161161
led1.set_high()?;
162162
led2.set_low()?;
163163
led3.set_low()?;
164164
led4.set_high()?;
165-
SysClock::delay(250.milliseconds());
165+
SysClock::delay(250_u32.milliseconds());
166166
}
167167
}

0 commit comments

Comments
 (0)