Skip to content

Commit

Permalink
qei pins
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Apr 17, 2023
1 parent adc4651 commit 6e71ac9
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 161 deletions.
148 changes: 148 additions & 0 deletions src/gpio/alt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2695,6 +2695,20 @@ pub mod tim1 {
PG5<1>,
],
}
use crate::pac::TIM1 as TIM;
use crate::pwm::{PinCh, C1, C2, C3, C4};
impl PinCh<C1> for TIM {
type Ch = Ch1;
}
impl PinCh<C2> for TIM {
type Ch = Ch2;
}
impl PinCh<C3> for TIM {
type Ch = Ch3;
}
impl PinCh<C4> for TIM {
type Ch = Ch4;
}
}

pub mod tim2 {
Expand Down Expand Up @@ -2723,6 +2737,20 @@ pub mod tim2 {
PA5<1>,
],
}
use crate::pac::TIM2 as TIM;
use crate::pwm::{PinCh, C1, C2, C3, C4};
impl PinCh<C1> for TIM {
type Ch = Ch1;
}
impl PinCh<C2> for TIM {
type Ch = Ch2;
}
impl PinCh<C3> for TIM {
type Ch = Ch3;
}
impl PinCh<C4> for TIM {
type Ch = Ch4;
}
}

pub mod tim3 {
Expand Down Expand Up @@ -2750,6 +2778,20 @@ pub mod tim3 {
PD2<2>,
],
}
use crate::pac::TIM3 as TIM;
use crate::pwm::{PinCh, C1, C2, C3, C4};
impl PinCh<C1> for TIM {
type Ch = Ch1;
}
impl PinCh<C2> for TIM {
type Ch = Ch2;
}
impl PinCh<C3> for TIM {
type Ch = Ch3;
}
impl PinCh<C4> for TIM {
type Ch = Ch4;
}
}

pub mod tim4 {
Expand All @@ -2775,6 +2817,20 @@ pub mod tim4 {
PE0<2>,
],
}
use crate::pac::TIM4 as TIM;
use crate::pwm::{PinCh, C1, C2, C3, C4};
impl PinCh<C1> for TIM {
type Ch = Ch1;
}
impl PinCh<C2> for TIM {
type Ch = Ch2;
}
impl PinCh<C3> for TIM {
type Ch = Ch3;
}
impl PinCh<C4> for TIM {
type Ch = Ch4;
}
}

pub mod tim5 {
Expand Down Expand Up @@ -2803,6 +2859,20 @@ pub mod tim5 {
PH8<2>,
],
}
use crate::pac::TIM5 as TIM;
use crate::pwm::{PinCh, C1, C2, C3, C4};
impl PinCh<C1> for TIM {
type Ch = Ch1;
}
impl PinCh<C2> for TIM {
type Ch = Ch2;
}
impl PinCh<C3> for TIM {
type Ch = Ch3;
}
impl PinCh<C4> for TIM {
type Ch = Ch4;
}
}

pub mod tim8 {
Expand Down Expand Up @@ -2911,6 +2981,20 @@ pub mod tim8 {
PI3<3>,
],
}
use crate::pac::TIM8 as TIM;
use crate::pwm::{PinCh, C1, C2, C3, C4};
impl PinCh<C1> for TIM {
type Ch = Ch1;
}
impl PinCh<C2> for TIM {
type Ch = Ch2;
}
impl PinCh<C3> for TIM {
type Ch = Ch3;
}
impl PinCh<C4> for TIM {
type Ch = Ch4;
}
}

pub mod tim12 {
Expand All @@ -2925,6 +3009,14 @@ pub mod tim12 {
PH9<2>,
],
}
use crate::pac::TIM12 as TIM;
use crate::pwm::{PinCh, C1, C2};
impl PinCh<C1> for TIM {
type Ch = Ch1;
}
impl PinCh<C2> for TIM {
type Ch = Ch2;
}
}

pub mod tim13 {
Expand All @@ -2935,6 +3027,11 @@ pub mod tim13 {
PF8<9>,
],
}
use crate::pac::TIM13 as TIM;
use crate::pwm::{PinCh, C1};
impl PinCh<C1> for TIM {
type Ch = Ch1;
}
}

pub mod tim14 {
Expand All @@ -2945,6 +3042,11 @@ pub mod tim14 {
PF9<9>,
],
}
use crate::pac::TIM14 as TIM;
use crate::pwm::{PinCh, C1};
impl PinCh<C1> for TIM {
type Ch = Ch1;
}
}

pub mod tim15 {
Expand Down Expand Up @@ -2973,6 +3075,14 @@ pub mod tim15 {
PE6<4>,
],
}
use crate::pac::TIM15 as TIM;
use crate::pwm::{PinCh, C1, C2};
impl PinCh<C1> for TIM {
type Ch = Ch1;
}
impl PinCh<C2> for TIM {
type Ch = Ch2;
}
}

pub mod tim16 {
Expand All @@ -2991,6 +3101,11 @@ pub mod tim16 {
PF8<1>,
],
}
use crate::pac::TIM16 as TIM;
use crate::pwm::{PinCh, C1};
impl PinCh<C1> for TIM {
type Ch = Ch1;
}
}

pub mod tim17 {
Expand All @@ -3009,6 +3124,11 @@ pub mod tim17 {
PF9<1>,
],
}
use crate::pac::TIM17 as TIM;
use crate::pwm::{PinCh, C1};
impl PinCh<C1> for TIM {
type Ch = Ch1;
}
}

#[cfg(feature = "gpio-h72")]
Expand Down Expand Up @@ -3039,6 +3159,20 @@ pub mod tim23 {
PG3<13>,
],
}
use crate::pac::TIM23 as TIM;
use crate::pwm::{PinCh, C1, C2, C3, C4};
impl PinCh<C1> for TIM {
type Ch = Ch1;
}
impl PinCh<C2> for TIM {
type Ch = Ch2;
}
impl PinCh<C3> for TIM {
type Ch = Ch3;
}
impl PinCh<C4> for TIM {
type Ch = Ch4;
}
}

#[cfg(feature = "gpio-h72")]
Expand All @@ -3062,6 +3196,20 @@ pub mod tim24 {
PG2<14>,
],
}
use crate::pac::TIM24 as TIM;
use crate::pwm::{PinCh, C1, C2, C3, C4};
impl PinCh<C1> for TIM {
type Ch = Ch1;
}
impl PinCh<C2> for TIM {
type Ch = Ch2;
}
impl PinCh<C3> for TIM {
type Ch = Ch3;
}
impl PinCh<C4> for TIM {
type Ch = Ch4;
}
}

#[cfg(any(feature = "gpio-h72", feature = "gpio-h747"))]
Expand Down
2 changes: 1 addition & 1 deletion src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl<I2C: Instance> I2c<I2C> {
prec: I2C::Rec,
clocks: &CoreClocks,
) -> Self {
let _pins = (pins.0.into(), pins.1.into());
let _pins: (I2C::Scl, I2C::Sda) = (pins.0.into(), pins.1.into());
Self::new_unchecked(i2c, frequency, prec, clocks)
}
/// Create and initialise a new I2C peripheral.
Expand Down
20 changes: 12 additions & 8 deletions src/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
//! ```rust
//! let gpioa = ..; // Set up and split GPIOA
//! let pins = (
//! gpioa.pa8.into_alternate_af1(),
//! gpioa.pa9.into_alternate_af1(),
//! gpioa.pa10.into_alternate_af1(),
//! gpioa.pa11.into_alternate_af1(),
//! gpioa.pa8.into_alternate(),
//! gpioa.pa9.into_alternate(),
//! gpioa.pa10.into_alternate(),
//! gpioa.pa11.into_alternate(),
//! );
//! ```
//!
Expand Down Expand Up @@ -56,10 +56,10 @@
//! ```rust
//! let gpioa = ..; // Set up and split GPIOA
//! let pins = (
//! gpioa.pa8.into_alternate_af1(),
//! gpioa.pa9.into_alternate_af1(),
//! gpioa.pa10.into_alternate_af1(),
//! gpioa.pa11.into_alternate_af1(),
//! gpioa.pa8.into_alternate(),
//! gpioa.pa9.into_alternate(),
//! gpioa.pa10.into_alternate(),
//! gpioa.pa11.into_alternate(),
//! );
//! ```
//!
Expand Down Expand Up @@ -203,6 +203,10 @@ pub trait FaultPins<TIM> {
const INPUT: BreakInput;
}

pub trait PinCh<const C: u8> {
type Ch;
}

/// Channel wrapper
pub struct Ch<const C: u8>;
impl<const C: u8> Ch<C> {
Expand Down
Loading

0 comments on commit 6e71ac9

Please sign in to comment.