Skip to content

Commit 2e44a4e

Browse files
bors[bot]newAM
andauthored
Merge #143
143: Update stm32f0 peripheral access crate from 0.13 to 0.14 r=therealprof a=newAM The clippy failures look like a pre-existing condition. I can clean those up in a separate PR if desired. Co-authored-by: Alex Martens <[email protected]>
2 parents 73b0fac + 3f26c12 commit 2e44a4e

File tree

4 files changed

+17
-30
lines changed

4 files changed

+17
-30
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313
- Move SPI busy polling to `check_send()`
1414
- Poll for SPI transaction completion before returning
1515
- Update `remap_pins()` and remove critical section
16+
- Updated `stm32f0` peripheral access crate from 0.13 to 0.14
1617

1718
### Added
1819

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bare-metal = { version = "1.0.0" }
3434
cast = { version = "0.2", default-features = false }
3535
cortex-m = "0.7"
3636
embedded-hal = { version = "0.2", features = ["unproven"] }
37-
stm32f0 = "0.13"
37+
stm32f0 = "0.14"
3838
nb = "1"
3939
void = { version = "1.0", default-features = false }
4040
stm32-usbd = { version = "0.6", optional = true }

src/pwm.rs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -318,18 +318,10 @@ macro_rules! pwm_2_channels {
318318
rcc.regs.$apbrstr.modify(|_, w| w.$timXrst().clear_bit());
319319

320320
if PINS::C1 {
321-
//NOTE(unsafe) 6 is a valid value to write to oc1m
322-
unsafe {
323-
tim.ccmr1_output()
324-
.modify(|_, w| w.oc1pe().set_bit().oc1m().bits(6));
325-
}
321+
tim.ccmr1_output().modify(|_, w| w.oc1pe().set_bit().oc1m().bits(6));
326322
}
327323
if PINS::C2 {
328-
//NOTE(unsafe) 6 is a valid value to write to oc1m
329-
unsafe {
330-
tim.ccmr1_output()
331-
.modify(|_, w| w.oc2pe().set_bit().oc1m().bits(6));
332-
}
324+
tim.ccmr1_output().modify(|_, w| w.oc2pe().set_bit().oc1m().bits(6));
333325
}
334326

335327
// If pclk is prescaled from hclk, the frequency fed into the timers is doubled
@@ -379,7 +371,7 @@ macro_rules! pwm_2_channels {
379371

380372
//NOTE(unsafe) atomic read with no side effects
381373
fn get_duty(&self) -> u16 {
382-
unsafe { (*$TIMX::ptr()).ccr1.read().ccr1().bits() as u16 }
374+
unsafe { (*$TIMX::ptr()).ccr1.read().ccr().bits() as u16 }
383375
}
384376

385377
//NOTE(unsafe) atomic read with no side effects
@@ -389,7 +381,7 @@ macro_rules! pwm_2_channels {
389381

390382
//NOTE(unsafe) atomic write with no side effects
391383
fn set_duty(&mut self, duty: u16) {
392-
unsafe { (*$TIMX::ptr()).ccr1.write(|w| w.ccr1().bits(duty.into())) }
384+
unsafe { (*$TIMX::ptr()).ccr1.write(|w| w.ccr().bits(duty.into())) }
393385
}
394386
}
395387

@@ -408,7 +400,7 @@ macro_rules! pwm_2_channels {
408400

409401
//NOTE(unsafe) atomic read with no side effects
410402
fn get_duty(&self) -> u16 {
411-
unsafe { (*$TIMX::ptr()).ccr2.read().ccr2().bits() as u16 }
403+
unsafe { (*$TIMX::ptr()).ccr2.read().ccr().bits() as u16 }
412404
}
413405

414406
//NOTE(unsafe) atomic read with no side effects
@@ -418,7 +410,7 @@ macro_rules! pwm_2_channels {
418410

419411
//NOTE(unsafe) atomic write with no side effects
420412
fn set_duty(&mut self, duty: u16) {
421-
unsafe { (*$TIMX::ptr()).ccr2.write(|w| w.ccr2().bits(duty.into())) }
413+
unsafe { (*$TIMX::ptr()).ccr2.write(|w| w.ccr().bits(duty.into())) }
422414
}
423415
}
424416
)+
@@ -440,11 +432,7 @@ macro_rules! pwm_1_channel {
440432
rcc.regs.$apbrstr.modify(|_, w| w.$timXrst().clear_bit());
441433

442434
if PINS::C1 {
443-
//NOTE(unsafe) 6 is a valid value to write to oc1m
444-
unsafe {
445-
tim.ccmr1_output()
446-
.modify(|_, w| w.oc1pe().set_bit().oc1m().bits(6));
447-
}
435+
tim.ccmr1_output().modify(|_, w| w.oc1pe().set_bit().oc1m().bits(6));
448436
}
449437

450438
// If pclk is prescaled from hclk, the frequency fed into the timers is doubled
@@ -524,11 +512,7 @@ macro_rules! pwm_1_channel_with_complementary_outputs {
524512
rcc.regs.$apbrstr.modify(|_, w| w.$timXrst().clear_bit());
525513

526514
if PINS::C1 {
527-
//NOTE(unsafe) 6 is a valid value to write to oc1m
528-
unsafe {
529-
tim.ccmr1_output()
530-
.modify(|_, w| w.oc1pe().set_bit().oc1m().bits(6));
531-
}
515+
tim.ccmr1_output().modify(|_, w| w.oc1pe().set_bit().oc1m().bits(6));
532516
}
533517

534518
// If pclk is prescaled from hclk, the frequency fed into the timers is doubled
@@ -579,7 +563,7 @@ macro_rules! pwm_1_channel_with_complementary_outputs {
579563

580564
//NOTE(unsafe) atomic read with no side effects
581565
fn get_duty(&self) -> u16 {
582-
unsafe { (*$TIMX::ptr()).ccr1.read().ccr1().bits() as u16 }
566+
unsafe { (*$TIMX::ptr()).ccr1.read().ccr().bits() as u16 }
583567
}
584568

585569
//NOTE(unsafe) atomic read with no side effects
@@ -589,7 +573,7 @@ macro_rules! pwm_1_channel_with_complementary_outputs {
589573

590574
//NOTE(unsafe) atomic write with no side effects
591575
fn set_duty(&mut self, duty: u16) {
592-
unsafe { (*$TIMX::ptr()).ccr1.write(|w| w.ccr1().bits(duty.into())) }
576+
unsafe { (*$TIMX::ptr()).ccr1.write(|w| w.ccr().bits(duty.into())) }
593577
}
594578
}
595579
)+

tools/check.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ def main():
2828

2929
crate_info = cargo_meta["packages"][0]
3030

31-
features = [""] + ["{},rt,stm32-usbd".format(x)
32-
for x in crate_info["features"].keys()
33-
if x != "device-selected" and x != "rt" and x != "stm32f030"]
31+
features = [
32+
"{},rt,stm32-usbd".format(x)
33+
for x in crate_info["features"].keys()
34+
if x != "device-selected" and x != "rt" and x != "stm32f030"
35+
]
3436

3537
if 'size_check' in sys.argv:
3638
cargo_cmd = ['cargo', 'build', '--release']

0 commit comments

Comments
 (0)