File tree Expand file tree Collapse file tree 7 files changed +25
-8
lines changed Expand file tree Collapse file tree 7 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,8 @@ pub struct CalibrationFactor(pub u8);
113
113
impl Adc {
114
114
pub fn new ( adc : ADC , rcc : & mut Rcc ) -> Self {
115
115
// Enable ADC clocks
116
- rcc. rb . apbenr2 . modify ( |_, w| w. adcen ( ) . set_bit ( ) ) ;
116
+ rcc. enable_adc ( ) ;
117
+
117
118
adc. cr . modify ( |_, w| w. advregen ( ) . set_bit ( ) ) ;
118
119
119
120
Self {
Original file line number Diff line number Diff line change @@ -31,11 +31,7 @@ pub trait CrcExt {
31
31
32
32
impl CrcExt for CRC {
33
33
fn constrain ( self , rcc : & mut Rcc ) -> Config {
34
- // Enable power to CRC unit
35
- rcc. rb . ahbenr . modify ( |_, w| w. crcen ( ) . set_bit ( ) ) ;
36
- // Reset CRC unit
37
- rcc. rb . ahbrstr . modify ( |_, w| w. crcrst ( ) . set_bit ( ) ) ;
38
- rcc. rb . ahbrstr . modify ( |_, w| w. crcrst ( ) . clear_bit ( ) ) ;
34
+ rcc. enable_crc ( ) ;
39
35
40
36
// Default values
41
37
Config {
Original file line number Diff line number Diff line change @@ -189,7 +189,7 @@ impl WriteErase for UnlockedFlash {
189
189
190
190
let mut chunks = aligned_data. chunks_exact ( mem:: size_of :: < Self :: NativeType > ( ) ) ;
191
191
192
- while let Some ( exact_chunk) = chunks. next ( ) {
192
+ for exact_chunk in & mut chunks {
193
193
// Write chunks
194
194
let native = & [ Self :: NativeType :: from_ne_bytes (
195
195
exact_chunk. try_into ( ) . unwrap ( ) ,
Original file line number Diff line number Diff line change @@ -177,30 +177,35 @@ macro_rules! gpio {
177
177
_mode: PhantomData <MODE >,
178
178
}
179
179
180
+ #[ allow( clippy:: from_over_into) ]
180
181
impl Into <$PXi<Input <PullDown >>> for $PXi<DefaultMode > {
181
182
fn into( self ) -> $PXi<Input <PullDown >> {
182
183
self . into_pull_down_input( )
183
184
}
184
185
}
185
186
187
+ #[ allow( clippy:: from_over_into) ]
186
188
impl Into <$PXi<Input <PullUp >>> for $PXi<DefaultMode > {
187
189
fn into( self ) -> $PXi<Input <PullUp >> {
188
190
self . into_pull_up_input( )
189
191
}
190
192
}
191
193
194
+ #[ allow( clippy:: from_over_into) ]
192
195
impl Into <$PXi<Input <Floating >>> for $PXi<DefaultMode > {
193
196
fn into( self ) -> $PXi<Input <Floating >> {
194
197
self . into_floating_input( )
195
198
}
196
199
}
197
200
201
+ #[ allow( clippy:: from_over_into) ]
198
202
impl Into <$PXi<Output <OpenDrain >>> for $PXi<DefaultMode > {
199
203
fn into( self ) -> $PXi<Output <OpenDrain >> {
200
204
self . into_open_drain_output( )
201
205
}
202
206
}
203
207
208
+ #[ allow( clippy:: from_over_into) ]
204
209
impl Into <$PXi<Output <PushPull >>> for $PXi<DefaultMode > {
205
210
fn into( self ) -> $PXi<Output <PushPull >> {
206
211
self . into_push_pull_output( )
Original file line number Diff line number Diff line change @@ -315,6 +315,16 @@ impl Rcc {
315
315
pub ( crate ) fn enable_power_control ( & self ) {
316
316
self . rb . apbenr1 . modify ( |_, w| w. pwren ( ) . set_bit ( ) ) ;
317
317
}
318
+
319
+ pub ( crate ) fn enable_adc ( & self ) {
320
+ self . rb . apbenr2 . modify ( |_, w| w. adcen ( ) . set_bit ( ) ) ;
321
+ }
322
+
323
+ pub ( crate ) fn enable_crc ( & self ) {
324
+ self . rb . ahbenr . modify ( |_, w| w. crcen ( ) . set_bit ( ) ) ;
325
+ self . rb . ahbrstr . modify ( |_, w| w. crcrst ( ) . set_bit ( ) ) ;
326
+ self . rb . ahbrstr . modify ( |_, w| w. crcrst ( ) . clear_bit ( ) ) ;
327
+ }
318
328
}
319
329
320
330
/// Extension trait that constrains the `RCC` peripheral
Original file line number Diff line number Diff line change @@ -326,7 +326,6 @@ macro_rules! uart_shared {
326
326
} ) ;
327
327
}
328
328
}
329
-
330
329
}
331
330
}
332
331
Original file line number Diff line number Diff line change @@ -217,6 +217,12 @@ impl Add for MicroSecond {
217
217
}
218
218
}
219
219
220
+ impl From < Second > for MicroSecond {
221
+ fn from ( period : Second ) -> MicroSecond {
222
+ MicroSecond ( period. 0 * 1_000_000 )
223
+ }
224
+ }
225
+
220
226
impl From < Hertz > for MicroSecond {
221
227
fn from ( freq : Hertz ) -> MicroSecond {
222
228
assert ! ( freq. 0 <= 1_000_000 ) ;
You can’t perform that action at this time.
0 commit comments