Skip to content

Commit 69aaa71

Browse files
committed
It became cumbersome to convert from Types back to u32, so we now use the types as a guard on ::new but we store the values as u32 for easier use.
1 parent 251eae6 commit 69aaa71

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/datetime.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,38 +82,38 @@ impl U32Ext for u32 {
8282

8383
#[derive(Clone,Copy,Debug)]
8484
pub struct Time {
85-
pub hours: Hour,
86-
pub minutes: Minute,
87-
pub seconds: Second,
85+
pub hours: u32,
86+
pub minutes: u32,
87+
pub seconds: u32,
8888
pub daylight_savings: bool
8989
}
9090

9191
impl Time {
9292
pub fn new(hours: Hour, minutes: Minute, seconds: Second, daylight_savings: bool) -> Self {
9393
Self {
94-
hours: hours,
95-
minutes: minutes,
96-
seconds: seconds,
94+
hours: hours.0,
95+
minutes: minutes.0,
96+
seconds: seconds.0,
9797
daylight_savings: daylight_savings
9898
}
9999
}
100100
}
101101

102102
#[derive(Clone,Copy, Debug)]
103103
pub struct Date {
104-
pub day: Day,
105-
pub date: DateInMonth,
106-
pub month: Month,
107-
pub year: Year,
104+
pub day: u32,
105+
pub date: u32,
106+
pub month: u32,
107+
pub year: u32,
108108
}
109109

110110
impl Date {
111111
pub fn new(day: Day, date: DateInMonth, month: Month, year: Year) -> Self {
112112
Self {
113-
day: day,
114-
date: date,
115-
month: month,
116-
year: year
113+
day: day.0,
114+
date: date.0,
115+
month: month.0,
116+
year: year.0
117117
}
118118
}
119119
}

src/rtc.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ impl Rtc {
8787
init_mode(&self.rtc, true);
8888
{
8989

90-
let (ht, hu) = byte_to_bcd2(time.hours.into());
91-
let (mnt, mnu) = byte_to_bcd2(time.minutes.into());
92-
let (st, su) = byte_to_bcd2(time.seconds.into());
90+
let (ht, hu) = byte_to_bcd2(time.hours as u8);
91+
let (mnt, mnu) = byte_to_bcd2(time.minutes as u8);
92+
let (st, su) = byte_to_bcd2(time.seconds as u8);
9393
self.rtc.tr.write(|w| unsafe {
9494
w.ht().bits(ht)
9595
.hu().bits(hu)
@@ -133,9 +133,9 @@ impl Rtc {
133133
{
134134
init_mode(&self.rtc, true);
135135
{
136-
let (dt, du) = byte_to_bcd2(date.date.into());
137-
let (mt, mu) = byte_to_bcd2(date.month.into());
138-
let yr: u16 = date.year.into();
136+
let (dt, du) = byte_to_bcd2(date.date as u8);
137+
let (mt, mu) = byte_to_bcd2(date.month as u8);
138+
let yr = date.year as u16;
139139
let yr_offset = (yr - 1970_u16) as u8;
140140
let (yt, yu) = byte_to_bcd2(yr_offset);
141141

@@ -146,7 +146,7 @@ impl Rtc {
146146
.mu().bits(mu)
147147
.yt().bits(yt)
148148
.yu().bits(yu)
149-
.wdu().bits(date.day.into())
149+
.wdu().bits(date.day as u8)
150150
});
151151

152152

0 commit comments

Comments
 (0)