@@ -42,7 +42,7 @@ impl Rtc {
42
42
enable ( bdcr) ;
43
43
result. set_24h_fmt ( ) ;
44
44
45
- result. regs . prer . modify ( |_, w| unsafe {
45
+ result. regs . prer . modify ( |_, w| {
46
46
w. prediv_s ( ) . bits ( prediv_s) ;
47
47
w. prediv_a ( ) . bits ( prediv_a)
48
48
} ) ;
@@ -99,7 +99,7 @@ impl Rtcc for Rtc {
99
99
let ( ht, hu) = bcd2_encode ( time. hour ( ) ) ?;
100
100
let ( mnt, mnu) = bcd2_encode ( time. minute ( ) ) ?;
101
101
let ( st, su) = bcd2_encode ( time. second ( ) ) ?;
102
- self . regs . tr . write ( |w| unsafe {
102
+ self . regs . tr . write ( |w| {
103
103
w. ht ( ) . bits ( ht) ;
104
104
w. hu ( ) . bits ( hu) ;
105
105
w. mnt ( ) . bits ( mnt) ;
@@ -117,10 +117,7 @@ impl Rtcc for Rtc {
117
117
return Err ( Error :: InvalidInputData ) ;
118
118
}
119
119
let ( st, su) = bcd2_encode ( seconds as u32 ) ?;
120
- self . modify ( |regs| {
121
- regs. tr
122
- . modify ( |_, w| unsafe { w. st ( ) . bits ( st) . su ( ) . bits ( su) } )
123
- } ) ;
120
+ self . modify ( |regs| regs. tr . modify ( |_, w| w. st ( ) . bits ( st) . su ( ) . bits ( su) ) ) ;
124
121
125
122
Ok ( ( ) )
126
123
}
@@ -130,10 +127,7 @@ impl Rtcc for Rtc {
130
127
return Err ( Error :: InvalidInputData ) ;
131
128
}
132
129
let ( mnt, mnu) = bcd2_encode ( minutes as u32 ) ?;
133
- self . modify ( |regs| {
134
- regs. tr
135
- . modify ( |_, w| unsafe { w. mnt ( ) . bits ( mnt) . mnu ( ) . bits ( mnu) } )
136
- } ) ;
130
+ self . modify ( |regs| regs. tr . modify ( |_, w| w. mnt ( ) . bits ( mnt) . mnu ( ) . bits ( mnu) ) ) ;
137
131
138
132
Ok ( ( ) )
139
133
}
@@ -145,9 +139,7 @@ impl Rtcc for Rtc {
145
139
Hours :: AM ( _h) | Hours :: PM ( _h) => self . set_12h_fmt ( ) ,
146
140
}
147
141
148
- self . regs
149
- . tr
150
- . modify ( |_, w| unsafe { w. ht ( ) . bits ( ht) . hu ( ) . bits ( hu) } ) ;
142
+ self . regs . tr . modify ( |_, w| w. ht ( ) . bits ( ht) . hu ( ) . bits ( hu) ) ;
151
143
152
144
Ok ( ( ) )
153
145
}
@@ -166,10 +158,7 @@ impl Rtcc for Rtc {
166
158
return Err ( Error :: InvalidInputData ) ;
167
159
}
168
160
let ( dt, du) = bcd2_encode ( day as u32 ) ?;
169
- self . modify ( |regs| {
170
- regs. dr
171
- . modify ( |_, w| unsafe { w. dt ( ) . bits ( dt) . du ( ) . bits ( du) } )
172
- } ) ;
161
+ self . modify ( |regs| regs. dr . modify ( |_, w| w. dt ( ) . bits ( dt) . du ( ) . bits ( du) ) ) ;
173
162
174
163
Ok ( ( ) )
175
164
}
@@ -179,10 +168,7 @@ impl Rtcc for Rtc {
179
168
return Err ( Error :: InvalidInputData ) ;
180
169
}
181
170
let ( mt, mu) = bcd2_encode ( month as u32 ) ?;
182
- self . modify ( |regs| {
183
- regs. dr
184
- . modify ( |_, w| unsafe { w. mt ( ) . bit ( mt > 0 ) . mu ( ) . bits ( mu) } )
185
- } ) ;
171
+ self . modify ( |regs| regs. dr . modify ( |_, w| w. mt ( ) . bit ( mt > 0 ) . mu ( ) . bits ( mu) ) ) ;
186
172
187
173
Ok ( ( ) )
188
174
}
@@ -192,10 +178,7 @@ impl Rtcc for Rtc {
192
178
return Err ( Error :: InvalidInputData ) ;
193
179
}
194
180
let ( yt, yu) = bcd2_encode ( year as u32 ) ?;
195
- self . modify ( |regs| {
196
- regs. dr
197
- . modify ( |_, w| unsafe { w. yt ( ) . bits ( yt) . yu ( ) . bits ( yu) } )
198
- } ) ;
181
+ self . modify ( |regs| regs. dr . modify ( |_, w| w. yt ( ) . bits ( yt) . yu ( ) . bits ( yu) ) ) ;
199
182
200
183
Ok ( ( ) )
201
184
}
@@ -211,7 +194,7 @@ impl Rtcc for Rtc {
211
194
let ( mt, mu) = bcd2_encode ( date. month ( ) ) ?;
212
195
let ( dt, du) = bcd2_encode ( date. day ( ) ) ?;
213
196
214
- self . regs . dr . write ( |w| unsafe {
197
+ self . regs . dr . write ( |w| {
215
198
w. dt ( ) . bits ( dt) ;
216
199
w. du ( ) . bits ( du) ;
217
200
w. mt ( ) . bit ( mt > 0 ) ;
@@ -237,7 +220,7 @@ impl Rtcc for Rtc {
237
220
let ( mnt, mnu) = bcd2_encode ( date. minute ( ) ) ?;
238
221
let ( st, su) = bcd2_encode ( date. second ( ) ) ?;
239
222
240
- self . regs . dr . write ( |w| unsafe {
223
+ self . regs . dr . write ( |w| {
241
224
w. dt ( ) . bits ( dt) ;
242
225
w. du ( ) . bits ( du) ;
243
226
w. mt ( ) . bit ( mt > 0 ) ;
@@ -246,7 +229,7 @@ impl Rtcc for Rtc {
246
229
w. yu ( ) . bits ( yu)
247
230
} ) ;
248
231
249
- self . regs . tr . write ( |w| unsafe {
232
+ self . regs . tr . write ( |w| {
250
233
w. ht ( ) . bits ( ht) ;
251
234
w. hu ( ) . bits ( hu) ;
252
235
w. mnt ( ) . bits ( mnt) ;
0 commit comments