1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use card10_sys::*;
use core::ops::Sub;
pub trait Time {
fn time() -> Self;
fn set_time(&self);
}
#[derive(Clone, Copy, Debug)]
pub struct Seconds(pub u32);
impl From<MilliSeconds> for Seconds {
fn from(ms: MilliSeconds) -> Seconds {
Seconds((ms.0 / 1000) as u32)
}
}
impl Time for Seconds {
fn time() -> Self {
let s = unsafe { epic_rtc_get_seconds() };
Seconds(s)
}
fn set_time(&self) {
}
}
impl Sub for Seconds {
type Output = Seconds;
fn sub(self, rhs: Seconds) -> Self::Output {
Seconds(self.0 - rhs.0)
}
}
#[derive(Clone, Copy, Debug)]
pub struct MilliSeconds(pub u64);
impl From<Seconds> for MilliSeconds {
fn from(s: Seconds) -> MilliSeconds {
MilliSeconds(s.0 as u64 * 1000)
}
}
impl Time for MilliSeconds {
fn time() -> Self {
let ms = unsafe { epic_rtc_get_milliseconds() };
MilliSeconds(ms)
}
fn set_time(&self) {
}
}
impl Sub for MilliSeconds {
type Output = MilliSeconds;
fn sub(self, rhs: MilliSeconds) -> Self::Output {
MilliSeconds(self.0 - rhs.0)
}
}