Skip to content

Commit 68cfc87

Browse files
committed
bump stm32f1
1 parent 0588013 commit 68cfc87

File tree

11 files changed

+85
-91
lines changed

11 files changed

+85
-91
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ required-features = ["rt"]
2222
cortex-m = "0.6.0"
2323
nb = "0.1.2"
2424
cortex-m-rt = "0.6.8"
25-
stm32f1 = "0.7.0"
25+
stm32f1 = "0.8.0"
2626

2727
[dependencies.void]
2828
default-features = false

src/adc.rs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -283,89 +283,89 @@ macro_rules! adc_hal {
283283
fn setup_oneshot(&mut self) {
284284
self.rb.cr2.modify(|_, w| w.cont().clear_bit());
285285
self.rb.cr2.modify(|_, w| w.exttrig().set_bit());
286-
self.rb.cr2.modify(|_, w| unsafe { w.extsel().bits(0b111) });
286+
self.rb.cr2.modify(|_, w| w.extsel().bits(0b111) );
287287

288288
self.rb.cr1.modify(|_, w| w.scan().clear_bit());
289289
self.rb.cr1.modify(|_, w| w.discen().set_bit());
290290

291-
self.rb.sqr1.modify(|_, w| unsafe { w.l().bits(0b0) });
291+
self.rb.sqr1.modify(|_, w| w.l().bits(0b0) );
292292
}
293293

294294
fn set_chan_smps(&mut self, chan: u8) {
295295
match chan {
296296
0 => self
297297
.rb
298298
.smpr2
299-
.modify(|_, w| unsafe { w.smp0().bits(self.sample_time.into()) }),
299+
.modify(|_, w| w.smp0().bits(self.sample_time.into()) ),
300300
1 => self
301301
.rb
302302
.smpr2
303-
.modify(|_, w| unsafe { w.smp1().bits(self.sample_time.into()) }),
303+
.modify(|_, w| w.smp1().bits(self.sample_time.into()) ),
304304
2 => self
305305
.rb
306306
.smpr2
307-
.modify(|_, w| unsafe { w.smp2().bits(self.sample_time.into()) }),
307+
.modify(|_, w| w.smp2().bits(self.sample_time.into()) ),
308308
3 => self
309309
.rb
310310
.smpr2
311-
.modify(|_, w| unsafe { w.smp3().bits(self.sample_time.into()) }),
311+
.modify(|_, w| w.smp3().bits(self.sample_time.into()) ),
312312
4 => self
313313
.rb
314314
.smpr2
315-
.modify(|_, w| unsafe { w.smp4().bits(self.sample_time.into()) }),
315+
.modify(|_, w| w.smp4().bits(self.sample_time.into()) ),
316316
5 => self
317317
.rb
318318
.smpr2
319-
.modify(|_, w| unsafe { w.smp5().bits(self.sample_time.into()) }),
319+
.modify(|_, w| w.smp5().bits(self.sample_time.into()) ),
320320
6 => self
321321
.rb
322322
.smpr2
323-
.modify(|_, w| unsafe { w.smp6().bits(self.sample_time.into()) }),
323+
.modify(|_, w| w.smp6().bits(self.sample_time.into()) ),
324324
7 => self
325325
.rb
326326
.smpr2
327-
.modify(|_, w| unsafe { w.smp7().bits(self.sample_time.into()) }),
327+
.modify(|_, w| w.smp7().bits(self.sample_time.into()) ),
328328
8 => self
329329
.rb
330330
.smpr2
331-
.modify(|_, w| unsafe { w.smp8().bits(self.sample_time.into()) }),
331+
.modify(|_, w| w.smp8().bits(self.sample_time.into()) ),
332332
9 => self
333333
.rb
334334
.smpr2
335-
.modify(|_, w| unsafe { w.smp9().bits(self.sample_time.into()) }),
335+
.modify(|_, w| w.smp9().bits(self.sample_time.into()) ),
336336

337337
10 => self
338338
.rb
339339
.smpr1
340-
.modify(|_, w| unsafe { w.smp10().bits(self.sample_time.into()) }),
340+
.modify(|_, w| w.smp10().bits(self.sample_time.into()) ),
341341
11 => self
342342
.rb
343343
.smpr1
344-
.modify(|_, w| unsafe { w.smp11().bits(self.sample_time.into()) }),
344+
.modify(|_, w| w.smp11().bits(self.sample_time.into()) ),
345345
12 => self
346346
.rb
347347
.smpr1
348-
.modify(|_, w| unsafe { w.smp12().bits(self.sample_time.into()) }),
348+
.modify(|_, w| w.smp12().bits(self.sample_time.into()) ),
349349
13 => self
350350
.rb
351351
.smpr1
352-
.modify(|_, w| unsafe { w.smp13().bits(self.sample_time.into()) }),
352+
.modify(|_, w| w.smp13().bits(self.sample_time.into()) ),
353353
14 => self
354354
.rb
355355
.smpr1
356-
.modify(|_, w| unsafe { w.smp14().bits(self.sample_time.into()) }),
356+
.modify(|_, w| w.smp14().bits(self.sample_time.into()) ),
357357
15 => self
358358
.rb
359359
.smpr1
360-
.modify(|_, w| unsafe { w.smp15().bits(self.sample_time.into()) }),
360+
.modify(|_, w| w.smp15().bits(self.sample_time.into()) ),
361361
16 => self
362362
.rb
363363
.smpr1
364-
.modify(|_, w| unsafe { w.smp16().bits(self.sample_time.into()) }),
364+
.modify(|_, w| w.smp16().bits(self.sample_time.into()) ),
365365
17 => self
366366
.rb
367367
.smpr1
368-
.modify(|_, w| unsafe { w.smp17().bits(self.sample_time.into()) }),
368+
.modify(|_, w| w.smp17().bits(self.sample_time.into()) ),
369369
_ => unreachable!(),
370370
}
371371

@@ -462,13 +462,13 @@ impl Adc<ADC1> {
462462
// so use the following approximate settings
463463
// to support all ADC frequencies
464464
let sample_time = match self.clocks.adcclk().0 {
465-
0 ... 1_200_000 => AdcSampleTime::T_1,
466-
1_200_001 ... 1_500_000 => AdcSampleTime::T_7,
467-
1_500_001 ... 2_400_000 => AdcSampleTime::T_13,
468-
2_400_001 ... 3_100_000 => AdcSampleTime::T_28,
469-
3_100_001 ... 4_000_000 => AdcSampleTime::T_41,
470-
4_000_001 ... 5_000_000 => AdcSampleTime::T_55,
471-
5_000_001 ... 14_000_000 => AdcSampleTime::T_71,
465+
0 ..= 1_200_000 => AdcSampleTime::T_1,
466+
1_200_001 ..= 1_500_000 => AdcSampleTime::T_7,
467+
1_500_001 ..= 2_400_000 => AdcSampleTime::T_13,
468+
2_400_001 ..= 3_100_000 => AdcSampleTime::T_28,
469+
3_100_001 ..= 4_000_000 => AdcSampleTime::T_41,
470+
4_000_001 ..= 5_000_000 => AdcSampleTime::T_55,
471+
5_000_001 ..= 14_000_000 => AdcSampleTime::T_71,
472472
_ => AdcSampleTime::T_239,
473473
};
474474

@@ -598,8 +598,8 @@ where
598598
self.channel.ch().cr.modify(|_, w| { w
599599
.mem2mem() .clear_bit()
600600
.pl() .medium()
601-
.msize() .bit16()
602-
.psize() .bit16()
601+
.msize() .bits16()
602+
.psize() .bits16()
603603
.circ() .set_bit()
604604
.dir() .clear_bit()
605605
});
@@ -627,13 +627,13 @@ where
627627
self.channel.ch().cr.modify(|_, w| { w
628628
.mem2mem() .clear_bit()
629629
.pl() .medium()
630-
.msize() .bit16()
631-
.psize() .bit16()
630+
.msize() .bits16()
631+
.psize() .bits16()
632632
.circ() .clear_bit()
633633
.dir() .clear_bit()
634634
});
635635
self.start();
636636

637637
Transfer::w(buffer, self)
638638
}
639-
}
639+
}

src/gpio.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ macro_rules! gpio {
199199
/// Put the pin in an active state. The caller
200200
/// must enforce that the pin is really in this
201201
/// state in the hardware.
202+
#[allow(dead_code)]
202203
pub(crate) unsafe fn activate(self) -> $PXi<Input<Floating>> {
203204
$PXi { _mode: PhantomData }
204205
}

src/pwm.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -309,33 +309,33 @@ macro_rules! hal {
309309
apb.rstr().modify(|_, w| w.$timXrst().clear_bit());
310310

311311
if PINS::C1 {
312-
tim.ccmr1_output
313-
.modify(|_, w| unsafe { w.oc1pe().set_bit().oc1m().bits(6) });
312+
tim.ccmr1_output()
313+
.modify(|_, w| w.oc1pe().set_bit().oc1m().pwm_mode1() );
314314
}
315315

316316
if PINS::C2 {
317-
tim.ccmr1_output
318-
.modify(|_, w| unsafe { w.oc2pe().set_bit().oc2m().bits(6) });
317+
tim.ccmr1_output()
318+
.modify(|_, w| w.oc2pe().set_bit().oc2m().pwm_mode1() );
319319
}
320320

321321
if PINS::C3 {
322-
tim.ccmr2_output
323-
.modify(|_, w| unsafe { w.oc3pe().set_bit().oc3m().bits(6) });
322+
tim.ccmr2_output()
323+
.modify(|_, w| w.oc3pe().set_bit().oc3m().pwm_mode1() );
324324
}
325325

326326
if PINS::C4 {
327-
tim.ccmr2_output
328-
.modify(|_, w| unsafe { w.oc4pe().set_bit().oc4m().bits(6) });
327+
tim.ccmr2_output()
328+
.modify(|_, w| w.oc4pe().set_bit().oc4m().pwm_mode1() );
329329
}
330330
let clk = $TIMX::get_clk(&clocks).0;
331331
let freq = freq.0;
332332
let ticks = clk / freq;
333333
let psc = u16(ticks / (1 << 16)).unwrap();
334-
tim.psc.write(|w| unsafe { w.psc().bits(psc) });
334+
tim.psc.write(|w| w.psc().bits(psc) );
335335
let arr = u16(ticks / u32(psc + 1)).unwrap();
336-
tim.arr.write(|w| { w.arr().bits(arr) });
336+
tim.arr.write(|w| w.arr().bits(arr));
337337

338-
tim.cr1.write(|w| unsafe {
338+
tim.cr1.write(|w|
339339
w.cms()
340340
.bits(0b00)
341341
.dir()
@@ -344,7 +344,7 @@ macro_rules! hal {
344344
.clear_bit()
345345
.cen()
346346
.set_bit()
347-
});
347+
);
348348

349349
unsafe { mem::uninitialized() }
350350
}

src/pwm_input.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,7 @@ macro_rules! hal {
211211

212212
// Define the direction of the channel (input/output)
213213
// and the used input
214-
// 01: CC1 channel is configured as input, IC1 is mapped on TI1.
215-
// 10: CC1 channel is configured as input, IC1 is mapped on TI2.
216-
tim.ccmr1_output.modify( |_,w| unsafe {w.cc1s().bits(0b01)});
217-
218-
// 01: CC2 channel is configured as input, IC2 is mapped on TI2
219-
// 10: CC2 channel is configured as input, IC2 is mapped on TI1
220-
tim.ccmr1_output.modify( |_,w| unsafe {w.cc2s().bits(0b10)});
214+
tim.ccmr1_input().modify( |_,w| w.cc1s().ti1().cc2s().ti1());
221215

222216
tim.dier.write(|w| w.cc1ie().set_bit());
223217

@@ -236,25 +230,25 @@ macro_rules! hal {
236230
let max_freq = if freq > 5 {freq/5} else {1};
237231
let (arr,presc) = compute_arr_presc(max_freq, $TIMX::get_clk(&clocks).0);
238232
tim.arr.write(|w| w.arr().bits(arr));
239-
tim.psc.write(|w| unsafe {w.psc().bits(presc)});
233+
tim.psc.write(|w| w.psc().bits(presc) );
240234

241235
},
242236
DutyCycle(f) => {
243237
let freq = f.into().0;
244238
let max_freq = if freq > 2 {freq/2 + freq/4 + freq/8} else {1};
245239
let (arr,presc) = compute_arr_presc(max_freq, $TIMX::get_clk(&clocks).0);
246240
tim.arr.write(|w| w.arr().bits(arr));
247-
tim.psc.write(|w| unsafe {w.psc().bits(presc)});
241+
tim.psc.write(|w| w.psc().bits(presc) );
248242
},
249243
RawFrequency(f) => {
250244
let freq = f.into().0;
251245
let (arr,presc) = compute_arr_presc(freq, $TIMX::get_clk(&clocks).0);
252246
tim.arr.write(|w| w.arr().bits(arr));
253-
tim.psc.write(|w| unsafe {w.psc().bits(presc)});
247+
tim.psc.write(|w| w.psc().bits(presc) );
254248
}
255249
RawValues{arr, presc} => {
256250
tim.arr.write(|w| w.arr().bits(arr));
257-
tim.psc.write(|w| unsafe {w.psc().bits(presc)});
251+
tim.psc.write(|w| w.psc().bits(presc) );
258252

259253
}
260254
}

src/qei.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ macro_rules! hal {
7878
apb.rstr().modify(|_, w| w.$timXrst().clear_bit());
7979

8080
// Configure TxC1 and TxC2 as captures
81-
tim.ccmr1_output
82-
.write(|w| unsafe { w.bits({ (0b01 << 0) | (0b01 << 8) }) });
81+
tim.ccmr1_input().write(|w| w.cc1s().ti1().cc2s().ti2());
8382

8483
// enable and configure to capture on rising edge
8584
tim.ccer.write(|w| {

src/rcc.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ impl CFGR {
194194
0 => unreachable!(),
195195
1 => 0b0111,
196196
2 => 0b1000,
197-
3...5 => 0b1001,
198-
6...11 => 0b1010,
199-
12...39 => 0b1011,
200-
40...95 => 0b1100,
201-
96...191 => 0b1101,
202-
192...383 => 0b1110,
197+
3..=5 => 0b1001,
198+
6..=11 => 0b1010,
199+
12..=39 => 0b1011,
200+
40..=95 => 0b1100,
201+
96..=191 => 0b1101,
202+
192..=383 => 0b1110,
203203
_ => 0b1111,
204204
})
205205
.unwrap_or(0b0111);
@@ -218,8 +218,8 @@ impl CFGR {
218218
0 => unreachable!(),
219219
1 => 0b011,
220220
2 => 0b100,
221-
3...5 => 0b101,
222-
6...11 => 0b110,
221+
3..=5 => 0b101,
222+
6..=11 => 0b110,
223223
_ => 0b111,
224224
})
225225
.unwrap_or(0b011);
@@ -235,8 +235,8 @@ impl CFGR {
235235
0 => unreachable!(),
236236
1 => 0b011,
237237
2 => 0b100,
238-
3...5 => 0b101,
239-
6...11 => 0b110,
238+
3..=5 => 0b101,
239+
6..=11 => 0b110,
240240
_ => 0b111,
241241
})
242242
.unwrap_or(0b011);
@@ -272,9 +272,9 @@ impl CFGR {
272272
let apre_bits = self
273273
.adcclk
274274
.map(|adcclk| match pclk2 / adcclk {
275-
0...2 => 0b00,
276-
3...4 => 0b01,
277-
5...7 => 0b10,
275+
0..=2 => 0b00,
276+
3..=4 => 0b01,
277+
5..=7 => 0b10,
278278
_ => 0b11,
279279
})
280280
.unwrap_or(0b11);
@@ -297,12 +297,12 @@ impl CFGR {
297297
if let Some(pllmul_bits) = pllmul_bits {
298298
// enable PLL and wait for it to be ready
299299

300-
rcc.cfgr.modify(|_, w| unsafe {
300+
rcc.cfgr.modify(|_, w|
301301
w.pllmul()
302302
.bits(pllmul_bits)
303303
.pllsrc()
304304
.bit(if self.hse.is_some() { true } else { false })
305-
});
305+
);
306306

307307
rcc.cr.modify(|_, w| w.pllon().set_bit());
308308

src/rtc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ impl Rtc {
8888
// See section 18.3.5 for explanation
8989
let alarm_value = seconds - 1;
9090
self.perform_write(|s| {
91-
s.regs.alrh.write(|w| unsafe{w.alrh().bits((alarm_value >> 16) as u16)});
92-
s.regs.alrl.write(|w| unsafe{w.alrl().bits(alarm_value as u16)});
91+
s.regs.alrh.write(|w| w.alrh().bits((alarm_value >> 16) as u16) );
92+
s.regs.alrl.write(|w| w.alrl().bits(alarm_value as u16) );
9393
});
9494

9595
self.clear_alarm_flag();

0 commit comments

Comments
 (0)