Skip to content

Commit 981212a

Browse files
bors[bot]burrbull
andauthored
Merge #342
342: RccBus r=therealprof a=burrbull Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
2 parents 9775f61 + 9606227 commit 981212a

File tree

10 files changed

+326
-190
lines changed

10 files changed

+326
-190
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Added
1111

12+
- `RccBus` & `GetBusFreq` traits. `AHBx`, `APBx` structures.
1213
- Filler `NoPin` type
1314
- Add inherent impl of `PwmPin` methods on `PwmChannel`s.
1415
- `Serial:tx` and `Serial::rx` that take only 1 pin

src/i2c.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,19 +250,11 @@ pub enum Error {
250250
ARBITRATION,
251251
}
252252

253-
mod private {
254-
pub trait Sealed {}
255-
}
256-
257-
pub trait Instance: private::Sealed + Deref<Target = i2c1::RegisterBlock> + Enable + Reset {}
253+
pub trait Instance: crate::Sealed + Deref<Target = i2c1::RegisterBlock> + Enable + Reset {}
258254

259-
impl private::Sealed for I2C1 {}
260255
impl Instance for I2C1 {}
261-
impl private::Sealed for I2C2 {}
262256
impl Instance for I2C2 {}
263257

264-
#[cfg(feature = "i2c3")]
265-
impl private::Sealed for I2C3 {}
266258
#[cfg(feature = "i2c3")]
267259
impl Instance for I2C3 {}
268260

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,8 @@ pub mod time;
175175
pub mod timer;
176176
#[cfg(feature = "device-selected")]
177177
pub mod watchdog;
178+
179+
mod sealed {
180+
pub trait Sealed {}
181+
}
182+
pub(crate) use sealed::Sealed;

src/pwm.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ macro_rules! pwm_pin {
190190
}
191191

192192
macro_rules! pwm_all_channels {
193-
($($TIMX:ident: ($timX:ident, $pclk:ident, $ppre:ident),)+) => {
193+
($($TIMX:ident: ($timX:ident),)+) => {
194194
$(
195195
impl Timer<$TIMX> {
196196
pub fn pwm<P, PINS, T>(self, _pins: PINS, freq: T) -> PINS::Channels
@@ -257,7 +257,7 @@ macro_rules! pwm_all_channels {
257257
}
258258

259259
macro_rules! pwm_2_channels {
260-
($($TIMX:ty: ($timX:ident, $pclk:ident, $ppre:ident),)+) => {
260+
($($TIMX:ty: ($timX:ident),)+) => {
261261
$(
262262
impl Timer<$TIMX> {
263263
pub fn pwm<P, PINS, T>(self, _pins: PINS, freq: T) -> PINS::Channels
@@ -312,7 +312,7 @@ macro_rules! pwm_2_channels {
312312
}
313313

314314
macro_rules! pwm_1_channel {
315-
($($TIMX:ty: ($timX:ident, $pclk:ident, $ppre:ident),)+) => {
315+
($($TIMX:ty: ($timX:ident),)+) => {
316316
$(
317317
impl Timer<$TIMX> {
318318
pub fn pwm<P, PINS, T>(self, _pins: PINS, freq: T) -> PINS::Channels
@@ -420,7 +420,7 @@ macro_rules! pwm_pin_tim5 {
420420

421421
#[cfg(feature = "stm32f410")]
422422
macro_rules! pwm_tim5_f410 {
423-
($($TIMX:ty: ($timX:ident, $pclk:ident, $ppre:ident),)+) => {
423+
($($TIMX:ty: ($timX:ident),)+) => {
424424
$(
425425
impl Timer<$TIMX> {
426426
pub fn pwm<P, PINS, T>(self, _pins: PINS, freq: T) -> PINS::Channels
@@ -484,11 +484,11 @@ macro_rules! pwm_tim5_f410 {
484484
};
485485
}
486486

487-
pwm_all_channels!(TIM1: (tim1, pclk2, ppre2),);
487+
pwm_all_channels!(TIM1: (tim1),);
488488

489-
pwm_2_channels!(TIM9: (tim9, pclk2, ppre2),);
489+
pwm_2_channels!(TIM9: (tim9),);
490490

491-
pwm_1_channel!(TIM11: (tim11, pclk2, ppre2),);
491+
pwm_1_channel!(TIM11: (tim11),);
492492

493493
#[cfg(any(
494494
feature = "stm32f401",
@@ -508,12 +508,7 @@ pwm_1_channel!(TIM11: (tim11, pclk2, ppre2),);
508508
feature = "stm32f469",
509509
feature = "stm32f479"
510510
))]
511-
pwm_all_channels!(
512-
TIM2: (tim2, pclk1, ppre1),
513-
TIM3: (tim3, pclk1, ppre1),
514-
TIM4: (tim4, pclk1, ppre1),
515-
TIM5: (tim5, pclk1, ppre1),
516-
);
511+
pwm_all_channels!(TIM2: (tim2), TIM3: (tim3), TIM4: (tim4), TIM5: (tim5),);
517512

518513
#[cfg(any(
519514
feature = "stm32f401",
@@ -533,7 +528,7 @@ pwm_all_channels!(
533528
feature = "stm32f469",
534529
feature = "stm32f479"
535530
))]
536-
pwm_1_channel!(TIM10: (tim10, pclk2, ppre2),);
531+
pwm_1_channel!(TIM10: (tim10),);
537532

538533
#[cfg(any(
539534
feature = "stm32f405",
@@ -551,7 +546,7 @@ pwm_1_channel!(TIM10: (tim10, pclk2, ppre2),);
551546
feature = "stm32f469",
552547
feature = "stm32f479"
553548
))]
554-
pwm_all_channels!(TIM8: (tim8, pclk2, ppre2),);
549+
pwm_all_channels!(TIM8: (tim8),);
555550

556551
#[cfg(any(
557552
feature = "stm32f405",
@@ -569,7 +564,7 @@ pwm_all_channels!(TIM8: (tim8, pclk2, ppre2),);
569564
feature = "stm32f469",
570565
feature = "stm32f479"
571566
))]
572-
pwm_2_channels!(TIM12: (tim12, pclk1, ppre1),);
567+
pwm_2_channels!(TIM12: (tim12),);
573568

574569
#[cfg(any(
575570
feature = "stm32f405",
@@ -587,7 +582,7 @@ pwm_2_channels!(TIM12: (tim12, pclk1, ppre1),);
587582
feature = "stm32f469",
588583
feature = "stm32f479"
589584
))]
590-
pwm_1_channel!(TIM13: (tim13, pclk1, ppre1), TIM14: (tim14, pclk1, ppre1),);
585+
pwm_1_channel!(TIM13: (tim13), TIM14: (tim14),);
591586

592587
#[cfg(feature = "stm32f410")]
593-
pwm_tim5_f410!(TIM5: (tim5, pclk1, ppre1),);
588+
pwm_tim5_f410!(TIM5: (tim5),);

src/qei.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,7 @@ impl<TIM: Instance, PINS> hal::Qei for Qei<TIM, PINS> {
5757
}
5858
}
5959

60-
mod sealed {
61-
pub trait Sealed {}
62-
}
63-
64-
pub trait Instance: sealed::Sealed {
60+
pub trait Instance: crate::Sealed {
6561
type Count;
6662

6763
fn setup_clocks();
@@ -73,7 +69,6 @@ pub trait Instance: sealed::Sealed {
7369
macro_rules! hal {
7470
($($TIM:ty: ($tim:ident, $bits:ident),)+) => {
7571
$(
76-
impl sealed::Sealed for $TIM {}
7772
impl Instance for $TIM {
7873
type Count = $bits;
7974

0 commit comments

Comments
 (0)