From 3678333a74c60b672fa2e38b8fada65e3481a699 Mon Sep 17 00:00:00 2001 From: Zhouqi Jiang Date: Thu, 19 Dec 2024 15:07:21 +0800 Subject: [PATCH] gpio: rearrange Pad into Alternate and other structures Simplify inner structures into `Inner` struct. Now struct Pad is split into Disabled, Input, Output and Alternate structures to make code clearer. Signed-off-by: Zhouqi Jiang --- bouffalo-hal/src/gpio.rs | 103 +---- bouffalo-hal/src/gpio/alternate.rs | 99 +++++ bouffalo-hal/src/gpio/convert.rs | 23 +- bouffalo-hal/src/gpio/disabled.rs | 81 ++-- bouffalo-hal/src/gpio/input.rs | 85 ++-- bouffalo-hal/src/gpio/output.rs | 85 ++-- bouffalo-hal/src/i2c.rs | 88 ++-- bouffalo-hal/src/pwm.rs | 398 +++++++++--------- bouffalo-hal/src/spi.rs | 133 +++--- bouffalo-hal/src/uart/pad.rs | 188 ++++----- .../peripherals/sdcard-gpt-demo/src/main.rs | 8 +- 11 files changed, 668 insertions(+), 623 deletions(-) create mode 100644 bouffalo-hal/src/gpio/alternate.rs diff --git a/bouffalo-hal/src/gpio.rs b/bouffalo-hal/src/gpio.rs index fce8e86..640e8a8 100644 --- a/bouffalo-hal/src/gpio.rs +++ b/bouffalo-hal/src/gpio.rs @@ -119,6 +119,7 @@ //! # } //! ``` +mod alternate; mod convert; mod disabled; mod gpio_group; @@ -129,6 +130,7 @@ mod pad_v1; mod pad_v2; mod typestate; +pub use alternate::Alternate; pub use convert::{IntoPad, IntoPadv2}; pub use disabled::Disabled; pub use gpio_group::Pads; @@ -137,105 +139,12 @@ pub use output::Output; pub use typestate::*; pub use {pad_v1::Padv1, pad_v2::Padv2}; -use crate::glb; -use core::ops::Deref; - cfg_if::cfg_if! { if #[cfg(feature = "glb-v1")] { - pub use crate::glb::v1; + pub(crate) use pad_v1::Padv1 as Inner; } else if #[cfg(feature = "glb-v2")] { - pub use crate::glb::v2; - } -} - -/// Individual GPIO pad. -pub struct Pad { - #[cfg(feature = "glb-v1")] - inner: pad_v1::Padv1, - #[cfg(feature = "glb-v2")] - inner: pad_v2::Padv2, - #[cfg(not(any(feature = "glb-v1", feature = "glb-v2")))] - inner: pad_dummy::PadDummy, -} - -// TODO: #[doc(cfg(feature = "glb-v2"))] once feature(doc_cfg) is stablized -#[cfg(any(doc, feature = "glb-v2"))] -impl, const N: usize, M> Pad { - /// Configures the pin to operate as a SPI pin. - #[inline] - pub fn into_spi(self) -> Pad> { - Pad { - inner: self.inner.into_spi(), - } - } - /// Configures the pin to operate as a SDH pin. - #[inline] - pub fn into_sdh(self) -> Pad { - Pad { - inner: self.inner.into_sdh(), - } - } - /// Configures the pin to operate as UART signal. - #[inline] - pub fn into_uart(self) -> Pad { - Pad { - inner: self.inner.into_uart(), - } - } - /// Configures the pin to operate as multi-media cluster UART signal. - #[inline] - pub fn into_mm_uart(self) -> Pad { - Pad { - inner: self.inner.into_mm_uart(), - } - } - /// Configures the pin to operate as a pull up Pulse Width Modulation signal pin. - #[inline] - pub fn into_pull_up_pwm(self) -> Pad> { - Pad { - inner: self.inner.into_pull_up_pwm(), - } - } - /// Configures the pin to operate as a pull down Pulse Width Modulation signal pin. - #[inline] - pub fn into_pull_down_pwm(self) -> Pad> { - Pad { - inner: self.inner.into_pull_down_pwm(), - } - } - /// Configures the pin to operate as floating Pulse Width Modulation signal pin. - #[inline] - pub fn into_floating_pwm(self) -> Pad> { - Pad { - inner: self.inner.into_floating_pwm(), - } - } - /// Configures the pin to operate as an Inter-Integrated Circuit signal pin. - #[inline] - pub fn into_i2c(self) -> Pad> { - Pad { - inner: self.inner.into_i2c(), - } - } - /// Configures the pin to operate as D0 core JTAG. - #[inline] - pub fn into_jtag_d0(self) -> Pad { - Pad { - inner: self.inner.into_jtag_d0(), - } - } - /// Configures the pin to operate as M0 core JTAG. - #[inline] - pub fn into_jtag_m0(self) -> Pad { - Pad { - inner: self.inner.into_jtag_m0(), - } - } - /// Configures the pin to operate as LP core JTAG. - #[inline] - pub fn into_jtag_lp(self) -> Pad { - Pad { - inner: self.inner.into_jtag_lp(), - } + pub(crate) use pad_v2::Padv2 as Inner; + } else { + pub(crate) use pad_dummy::PadDummy as Inner; } } diff --git a/bouffalo-hal/src/gpio/alternate.rs b/bouffalo-hal/src/gpio/alternate.rs new file mode 100644 index 0000000..51ee7e4 --- /dev/null +++ b/bouffalo-hal/src/gpio/alternate.rs @@ -0,0 +1,99 @@ +use super::{ + convert::{IntoPad, IntoPadv2}, + input::Input, + output::Output, + typestate::{self, Floating, PullDown, PullUp}, +}; +use crate::glb::RegisterBlock; +use core::ops::Deref; + +/// GPIO pad with alternate mode. +pub struct Alternate { + inner: super::Inner, +} + +impl, const N: usize, M> IntoPad + for Alternate +{ + #[inline] + fn into_pull_up_output(self) -> Output { + self.inner.into_pull_up_output().into() + } + #[inline] + fn into_pull_down_output(self) -> Output { + self.inner.into_pull_down_output().into() + } + #[inline] + fn into_floating_output(self) -> Output { + self.inner.into_floating_output().into() + } + #[inline] + fn into_pull_up_input(self) -> Input { + self.inner.into_pull_up_input().into() + } + #[inline] + fn into_pull_down_input(self) -> Input { + self.inner.into_pull_down_input().into() + } + #[inline] + fn into_floating_input(self) -> Input { + self.inner.into_floating_input().into() + } +} + +#[cfg(any(doc, feature = "glb-v2"))] +impl, const N: usize, M> IntoPadv2 + for Alternate +{ + #[inline] + fn into_spi(self) -> Alternate> { + self.inner.into_spi().into() + } + #[inline] + fn into_sdh(self) -> Alternate { + self.inner.into_sdh().into() + } + #[inline] + fn into_uart(self) -> Alternate { + self.inner.into_uart().into() + } + #[inline] + fn into_mm_uart(self) -> Alternate { + self.inner.into_mm_uart().into() + } + #[inline] + fn into_pull_up_pwm(self) -> Alternate> { + self.inner.into_pull_up_pwm().into() + } + #[inline] + fn into_pull_down_pwm(self) -> Alternate> { + self.inner.into_pull_down_pwm().into() + } + #[inline] + fn into_floating_pwm(self) -> Alternate> { + self.inner.into_floating_pwm().into() + } + #[inline] + fn into_i2c(self) -> Alternate> { + self.inner.into_i2c().into() + } + #[inline] + fn into_jtag_d0(self) -> Alternate { + self.inner.into_jtag_d0().into() + } + #[inline] + fn into_jtag_m0(self) -> Alternate { + self.inner.into_jtag_m0().into() + } + #[inline] + fn into_jtag_lp(self) -> Alternate { + self.inner.into_jtag_lp().into() + } +} + +impl From> for Alternate { + #[inline] + fn from(inner: super::Inner) -> Self { + Self { inner } + } +} diff --git a/bouffalo-hal/src/gpio/convert.rs b/bouffalo-hal/src/gpio/convert.rs index 42af30e..ea029cb 100644 --- a/bouffalo-hal/src/gpio/convert.rs +++ b/bouffalo-hal/src/gpio/convert.rs @@ -1,4 +1,5 @@ use super::{ + alternate::Alternate, input::Input, output::Output, typestate::{Floating, PullDown, PullUp}, @@ -23,25 +24,25 @@ pub trait IntoPad { /// Trait for GLBv2 pad mode conversations. pub trait IntoPadv2 { /// Configures the pin to operate as a SPI pin. - fn into_spi(self) -> super::Pad>; + fn into_spi(self) -> Alternate>; /// Configures the pin to operate as a SDH pin. - fn into_sdh(self) -> super::Pad; + fn into_sdh(self) -> Alternate; /// Configures the pin to operate as UART signal. - fn into_uart(self) -> super::Pad; + fn into_uart(self) -> Alternate; /// Configures the pin to operate as multi-media cluster UART signal. - fn into_mm_uart(self) -> super::Pad; + fn into_mm_uart(self) -> Alternate; /// Configures the pin to operate as a pull up Pulse Width Modulation signal pin. - fn into_pull_up_pwm(self) -> super::Pad>; + fn into_pull_up_pwm(self) -> Alternate>; /// Configures the pin to operate as a pull down Pulse Width Modulation signal pin. - fn into_pull_down_pwm(self) -> super::Pad>; + fn into_pull_down_pwm(self) -> Alternate>; /// Configures the pin to operate as floating Pulse Width Modulation signal pin. - fn into_floating_pwm(self) -> super::Pad>; + fn into_floating_pwm(self) -> Alternate>; /// Configures the pin to operate as an Inter-Integrated Circuit signal pin. - fn into_i2c(self) -> super::Pad>; + fn into_i2c(self) -> Alternate>; /// Configures the pin to operate as D0 core JTAG. - fn into_jtag_d0(self) -> super::Pad; + fn into_jtag_d0(self) -> Alternate; /// Configures the pin to operate as M0 core JTAG. - fn into_jtag_m0(self) -> super::Pad; + fn into_jtag_m0(self) -> Alternate; /// Configures the pin to operate as LP core JTAG. - fn into_jtag_lp(self) -> super::Pad; + fn into_jtag_lp(self) -> Alternate; } diff --git a/bouffalo-hal/src/gpio/disabled.rs b/bouffalo-hal/src/gpio/disabled.rs index c4761b3..bcd6b3f 100644 --- a/bouffalo-hal/src/gpio/disabled.rs +++ b/bouffalo-hal/src/gpio/disabled.rs @@ -1,4 +1,5 @@ use super::{ + alternate::Alternate, convert::{IntoPad, IntoPadv2}, input::Input, output::Output, @@ -9,12 +10,7 @@ use core::ops::Deref; /// GPIO pad which is disabled. pub struct Disabled { - #[cfg(feature = "glb-v1")] - inner: super::pad_v1::Padv1, - #[cfg(feature = "glb-v2")] - inner: super::pad_v2::Padv2, - #[cfg(not(any(feature = "glb-v1", feature = "glb-v2")))] - inner: super::pad_dummy::PadDummy, + inner: super::Inner, } impl, const N: usize> IntoPad for Disabled { @@ -47,69 +43,54 @@ impl, const N: usize> IntoPad for Dis #[cfg(any(doc, feature = "glb-v2"))] impl, const N: usize> IntoPadv2 for Disabled { #[inline] - fn into_spi(self) -> super::Pad> { - super::Pad { - inner: self.inner.into_spi(), - } + fn into_spi(self) -> Alternate> { + self.inner.into_spi().into() } #[inline] - fn into_sdh(self) -> super::Pad { - super::Pad { - inner: self.inner.into_sdh(), - } + fn into_sdh(self) -> Alternate { + self.inner.into_sdh().into() } #[inline] - fn into_uart(self) -> super::Pad { - super::Pad { - inner: self.inner.into_uart(), - } + fn into_uart(self) -> Alternate { + self.inner.into_uart().into() } #[inline] - fn into_mm_uart(self) -> super::Pad { - super::Pad { - inner: self.inner.into_mm_uart(), - } + fn into_mm_uart(self) -> Alternate { + self.inner.into_mm_uart().into() } #[inline] - fn into_pull_up_pwm(self) -> super::Pad> { - super::Pad { - inner: self.inner.into_pull_up_pwm(), - } + fn into_pull_up_pwm(self) -> Alternate> { + self.inner.into_pull_up_pwm().into() } #[inline] - fn into_pull_down_pwm(self) -> super::Pad> { - super::Pad { - inner: self.inner.into_pull_down_pwm(), - } + fn into_pull_down_pwm(self) -> Alternate> { + self.inner.into_pull_down_pwm().into() } #[inline] - fn into_floating_pwm(self) -> super::Pad> { - super::Pad { - inner: self.inner.into_floating_pwm(), - } + fn into_floating_pwm(self) -> Alternate> { + self.inner.into_floating_pwm().into() } #[inline] - fn into_i2c(self) -> super::Pad> { - super::Pad { - inner: self.inner.into_i2c(), - } + fn into_i2c(self) -> Alternate> { + self.inner.into_i2c().into() } #[inline] - fn into_jtag_d0(self) -> super::Pad { - super::Pad { - inner: self.inner.into_jtag_d0(), - } + fn into_jtag_d0(self) -> Alternate { + self.inner.into_jtag_d0().into() } #[inline] - fn into_jtag_m0(self) -> super::Pad { - super::Pad { - inner: self.inner.into_jtag_m0(), - } + fn into_jtag_m0(self) -> Alternate { + self.inner.into_jtag_m0().into() } #[inline] - fn into_jtag_lp(self) -> super::Pad { - super::Pad { - inner: self.inner.into_jtag_lp(), - } + fn into_jtag_lp(self) -> Alternate { + self.inner.into_jtag_lp().into() + } +} + +impl From> for Disabled { + #[inline] + fn from(inner: super::Inner) -> Self { + Self { inner } } } diff --git a/bouffalo-hal/src/gpio/input.rs b/bouffalo-hal/src/gpio/input.rs index 7783cf4..f57d49b 100644 --- a/bouffalo-hal/src/gpio/input.rs +++ b/bouffalo-hal/src/gpio/input.rs @@ -1,5 +1,6 @@ use super::{ - convert::IntoPad, + alternate::Alternate, + convert::{IntoPad, IntoPadv2}, output::Output, typestate::{self, Floating, PullDown, PullUp}, }; @@ -9,12 +10,7 @@ use embedded_hal::digital::{ErrorType, InputPin}; /// GPIO pad in input mode. pub struct Input { - #[cfg(feature = "glb-v1")] - inner: super::pad_v1::Padv1>, - #[cfg(feature = "glb-v2")] - inner: super::pad_v2::Padv2>, - #[cfg(not(any(feature = "glb-v1", feature = "glb-v2")))] - inner: super::pad_dummy::PadDummy>, + inner: super::Inner>, } impl, const N: usize, M> Input { @@ -77,6 +73,54 @@ impl, const N: usize, M> IntoPad for } } +#[cfg(any(doc, feature = "glb-v2"))] +impl, const N: usize, M> IntoPadv2 for Input { + #[inline] + fn into_spi(self) -> Alternate> { + self.inner.into_spi().into() + } + #[inline] + fn into_sdh(self) -> Alternate { + self.inner.into_sdh().into() + } + #[inline] + fn into_uart(self) -> Alternate { + self.inner.into_uart().into() + } + #[inline] + fn into_mm_uart(self) -> Alternate { + self.inner.into_mm_uart().into() + } + #[inline] + fn into_pull_up_pwm(self) -> Alternate> { + self.inner.into_pull_up_pwm().into() + } + #[inline] + fn into_pull_down_pwm(self) -> Alternate> { + self.inner.into_pull_down_pwm().into() + } + #[inline] + fn into_floating_pwm(self) -> Alternate> { + self.inner.into_floating_pwm().into() + } + #[inline] + fn into_i2c(self) -> Alternate> { + self.inner.into_i2c().into() + } + #[inline] + fn into_jtag_d0(self) -> Alternate { + self.inner.into_jtag_d0().into() + } + #[inline] + fn into_jtag_m0(self) -> Alternate { + self.inner.into_jtag_m0().into() + } + #[inline] + fn into_jtag_lp(self) -> Alternate { + self.inner.into_jtag_lp().into() + } +} + impl ErrorType for Input { type Error = core::convert::Infallible; } @@ -92,32 +136,9 @@ impl, const N: usize, M> InputPin for In } } -#[cfg(feature = "glb-v1")] -impl From>> - for Input -{ - #[inline] - fn from(inner: super::pad_v1::Padv1>) -> Self { - Self { inner } - } -} - -#[cfg(feature = "glb-v2")] -impl From>> - for Input -{ - #[inline] - fn from(inner: super::pad_v2::Padv2>) -> Self { - Self { inner } - } -} - -#[cfg(not(any(feature = "glb-v1", feature = "glb-v2")))] -impl From>> - for Input -{ +impl From>> for Input { #[inline] - fn from(inner: super::pad_dummy::PadDummy>) -> Self { + fn from(inner: super::Inner>) -> Self { Self { inner } } } diff --git a/bouffalo-hal/src/gpio/output.rs b/bouffalo-hal/src/gpio/output.rs index 40dc548..8da4985 100644 --- a/bouffalo-hal/src/gpio/output.rs +++ b/bouffalo-hal/src/gpio/output.rs @@ -1,5 +1,6 @@ use super::{ - convert::IntoPad, + alternate::Alternate, + convert::{IntoPad, IntoPadv2}, input::Input, typestate::{self, Floating, PullDown, PullUp}, }; @@ -9,12 +10,7 @@ use embedded_hal::digital::{ErrorType, OutputPin}; /// GPIO pad in output mode. pub struct Output { - #[cfg(feature = "glb-v1")] - inner: super::pad_v1::Padv1>, - #[cfg(feature = "glb-v2")] - inner: super::pad_v2::Padv2>, - #[cfg(not(any(feature = "glb-v1", feature = "glb-v2")))] - inner: super::pad_dummy::PadDummy>, + inner: super::Inner>, } impl, const N: usize, M> Output { @@ -57,6 +53,56 @@ impl, const N: usize, M> IntoPad for } } +#[cfg(any(doc, feature = "glb-v2"))] +impl, const N: usize, M> IntoPadv2 + for Output +{ + #[inline] + fn into_spi(self) -> Alternate> { + self.inner.into_spi().into() + } + #[inline] + fn into_sdh(self) -> Alternate { + self.inner.into_sdh().into() + } + #[inline] + fn into_uart(self) -> Alternate { + self.inner.into_uart().into() + } + #[inline] + fn into_mm_uart(self) -> Alternate { + self.inner.into_mm_uart().into() + } + #[inline] + fn into_pull_up_pwm(self) -> Alternate> { + self.inner.into_pull_up_pwm().into() + } + #[inline] + fn into_pull_down_pwm(self) -> Alternate> { + self.inner.into_pull_down_pwm().into() + } + #[inline] + fn into_floating_pwm(self) -> Alternate> { + self.inner.into_floating_pwm().into() + } + #[inline] + fn into_i2c(self) -> Alternate> { + self.inner.into_i2c().into() + } + #[inline] + fn into_jtag_d0(self) -> Alternate { + self.inner.into_jtag_d0().into() + } + #[inline] + fn into_jtag_m0(self) -> Alternate { + self.inner.into_jtag_m0().into() + } + #[inline] + fn into_jtag_lp(self) -> Alternate { + self.inner.into_jtag_lp().into() + } +} + impl ErrorType for Output { type Error = core::convert::Infallible; } @@ -90,32 +136,11 @@ impl, const N: usize, M> } } -#[cfg(feature = "glb-v1")] -impl From>> - for Output -{ - #[inline] - fn from(inner: super::pad_v1::Padv1>) -> Self { - Self { inner } - } -} - -#[cfg(feature = "glb-v2")] -impl From>> - for Output -{ - #[inline] - fn from(inner: super::pad_v2::Padv2>) -> Self { - Self { inner } - } -} - -#[cfg(not(any(feature = "glb-v1", feature = "glb-v2")))] -impl From>> +impl From>> for Output { #[inline] - fn from(inner: super::pad_dummy::PadDummy>) -> Self { + fn from(inner: super::Inner>) -> Self { Self { inner } } } diff --git a/bouffalo-hal/src/i2c.rs b/bouffalo-hal/src/i2c.rs index fdd8607..1dcbf56 100644 --- a/bouffalo-hal/src/i2c.rs +++ b/bouffalo-hal/src/i2c.rs @@ -3,7 +3,7 @@ use core::ops::Deref; use crate::{ glb::{self, v2::I2cClockSource}, - gpio::{self, Pad}, + gpio::{self, Alternate}, }; use volatile_register::{RO, RW, WO}; @@ -495,15 +495,19 @@ impl FifoConfig1 { } /// Managed Inter-Integrated Circuit peripheral. -pub struct I2c { +pub struct I2c { i2c: I2C, - pads: PADS, + Alternates: AlternateS, } impl, SCL, SDA> I2c { /// Create a new Inter-Integrated Circuit instance. #[inline] - pub fn new(i2c: I2C, pads: (SCL, SDA), glb: &glb::v2::RegisterBlock) -> Self + pub fn new( + i2c: I2C, + Alternates: (SCL, SDA), + glb: &glb::v2::RegisterBlock, + ) -> Self where SCL: SclPin, SDA: SdaPin, @@ -547,17 +551,17 @@ impl, SCL, SDA> I2c { ); } - Self { i2c, pads } + Self { i2c, Alternates } } - /// Release the I2C instance and return the pads. + /// Release the I2C instance and return the Alternates. #[inline] pub fn free(self, glb: &glb::v2::RegisterBlock) -> (I2C, (SCL, SDA)) { unsafe { glb.i2c_config.modify(|config| config.disable_clock()); glb.clock_config_1.modify(|config| config.disable_i2c()); } - (self.i2c, self.pads) + (self.i2c, self.Alternates) } /// Enable sub-address. @@ -602,11 +606,15 @@ impl embedded_hal::i2c::Error for Error { } } -impl, PADS> embedded_hal::i2c::ErrorType for I2c { +impl, AlternateS> embedded_hal::i2c::ErrorType + for I2c +{ type Error = Error; } -impl, PADS> embedded_hal::i2c::I2c for I2c { +impl, AlternateS> embedded_hal::i2c::I2c + for I2c +{ #[inline] fn transaction( &mut self, @@ -661,37 +669,37 @@ mod i2c_impls { // 0, 2, 4, ..., 2n: SCL // 1, 3, 5, ..., 2n+1: SDA - // TODO: support other pads if needed - impl SclPin for Pad> {} - impl SdaPin for Pad> {} - impl SclPin for Pad> {} - impl SdaPin for Pad> {} - impl SclPin for Pad> {} - impl SdaPin for Pad> {} - impl SclPin for Pad> {} - impl SdaPin for Pad> {} - impl SclPin for Pad> {} - impl SdaPin for Pad> {} - impl SclPin for Pad> {} - impl SdaPin for Pad> {} - impl SclPin for Pad> {} - impl SdaPin for Pad> {} - impl SclPin for Pad> {} - impl SdaPin for Pad> {} - impl SclPin for Pad> {} - impl SdaPin for Pad> {} - impl SclPin for Pad> {} - impl SdaPin for Pad> {} - impl SclPin for Pad> {} - impl SdaPin for Pad> {} - impl SclPin for Pad> {} - impl SdaPin for Pad> {} - impl SclPin for Pad> {} - impl SdaPin for Pad> {} - impl SclPin for Pad> {} - impl SdaPin for Pad> {} - impl SclPin for Pad> {} - impl SdaPin for Pad> {} + // TODO: support other Alternates if needed + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} + impl SclPin for Alternate> {} + impl SdaPin for Alternate> {} } #[cfg(test)] diff --git a/bouffalo-hal/src/pwm.rs b/bouffalo-hal/src/pwm.rs index 31eca33..4e598b8 100644 --- a/bouffalo-hal/src/pwm.rs +++ b/bouffalo-hal/src/pwm.rs @@ -4,7 +4,7 @@ use crate::glb::{ self, v2::{PwmSignal0, PwmSignal1}, }; -use crate::gpio::{self, Pad}; +use crate::gpio::{self, Alternate}; use core::marker::PhantomData; use core::ops::{Deref, DerefMut}; use embedded_time::rate::Hertz; @@ -772,11 +772,11 @@ impl, S, const I: usize, const J: usize> Chan #[inline] pub fn positive_signal_pin( self, - pin: Pad>, - ) -> PwmPin>, Positive> + pin: Alternate>, + ) -> PwmPin>, Positive> where GLB: Deref, - Pad>: HasPwmSignal, + Alternate>: HasPwmSignal, { PwmPin { channel: self, @@ -791,11 +791,11 @@ impl, S, const I: usize, const J: usize> Chan #[inline] pub fn negative_signal_pin( self, - pin: Pad>, - ) -> PwmPin>, Negative> + pin: Alternate>, + ) -> PwmPin>, Negative> where GLB: Deref, - Pad>: HasPwmSignal, + Alternate>: HasPwmSignal, { PwmPin { channel: self, @@ -818,11 +818,11 @@ impl ExternalBreak { #[inline] pub fn external_break_pin( self, - pin: Pad>, - ) -> PwmPin>, ()> + pin: Alternate>, + ) -> PwmPin>, ()> where GLB: Deref, - Pad>: HasPwmExternalBreak, + Alternate>: HasPwmExternalBreak, { PwmPin { channel: self, @@ -842,7 +842,7 @@ pub struct Negative; /// /// It checks if it is connected to PWM group `I`, channel `J` and polarity `P` with signal settings `S`. #[diagnostic::on_unimplemented( - message = "this I/O pad has no hardware connection to '{P}' polarity signal of PWM group {I}, channel {J} with signal setting {S}" + message = "this I/O Alternate has no hardware connection to '{P}' polarity signal of PWM group {I}, channel {J} with signal setting {S}" )] pub trait HasPwmSignal {} @@ -850,7 +850,7 @@ pub trait HasPwmSignal {} /// /// It checks if it is connected to external break signal of PWM group `I`. #[diagnostic::on_unimplemented( - message = "this I/O pad has no hardware connection to external break signal of PWM group {I}" + message = "this I/O Alternate has no hardware connection to external break signal of PWM group {I}" )] pub trait HasPwmExternalBreak {} @@ -997,193 +997,193 @@ impl, S, const I: usize, const J: usize, PIN, mod gpio_impls { use super::*; - impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Pad> {} - - impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Negative> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Positive> for Pad> {} - impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Negative> for Pad> {} - - impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Pad> {} - - impl HasPwmExternalBreak<0> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Pad> {} - impl HasPwmExternalBreak<0> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Pad> {} - impl HasPwmExternalBreak<0> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Pad> {} - impl HasPwmExternalBreak<0> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Pad> {} - impl HasPwmExternalBreak<0> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Pad> {} - impl HasPwmExternalBreak<0> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Pad> {} - impl HasPwmExternalBreak<0> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Pad> {} - impl HasPwmExternalBreak<0> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Pad> {} - impl HasPwmExternalBreak<0> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Pad> {} - impl HasPwmExternalBreak<0> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Pad> {} - impl HasPwmExternalBreak<0> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Pad> {} - impl HasPwmExternalBreak<0> for Pad> {} - impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Pad> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(SingleEnd, S2), 0, 1, Positive> for Alternate> {} + + impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 3, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 0, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 1, Negative> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Positive> for Alternate> {} + impl HasPwmSignal<(DifferentialEnd, S2), 0, 2, Negative> for Alternate> {} + + impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 2, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 3, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, SingleEnd), 1, 1, Positive> for Alternate> {} + + impl HasPwmExternalBreak<0> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Alternate> {} + impl HasPwmExternalBreak<0> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Alternate> {} + impl HasPwmExternalBreak<0> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Alternate> {} + impl HasPwmExternalBreak<0> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Alternate> {} + impl HasPwmExternalBreak<0> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Alternate> {} + impl HasPwmExternalBreak<0> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Alternate> {} + impl HasPwmExternalBreak<0> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Alternate> {} + impl HasPwmExternalBreak<0> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Alternate> {} + impl HasPwmExternalBreak<0> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Alternate> {} + impl HasPwmExternalBreak<0> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Alternate> {} + impl HasPwmExternalBreak<0> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 1, Positive> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 2, Positive> for Alternate> {} + impl HasPwmExternalBreak<0> for Alternate> {} + impl HasPwmSignal<(S1, BrushlessDcMotor), 0, 0, Positive> for Alternate> {} } #[cfg(test)] diff --git a/bouffalo-hal/src/spi.rs b/bouffalo-hal/src/spi.rs index e59e454..3acf7e1 100644 --- a/bouffalo-hal/src/spi.rs +++ b/bouffalo-hal/src/spi.rs @@ -1,7 +1,7 @@ //! Serial Peripheral Interface peripheral. use crate::glb::{self, v2::SpiMode}; -use crate::gpio::{self, Pad}; +use crate::gpio::{self, Alternate}; use core::cmp::max; use core::ops::Deref; use embedded_hal::spi::Mode; @@ -630,7 +630,7 @@ impl, PADS, const I: usize> Spi #[inline] pub fn new(spi: SPI, pads: PADS, mode: Mode, glb: &GLB) -> Self where - PADS: Pads, + PADS: Alternates, GLB: Deref, { let mut config = Config(0) @@ -877,105 +877,106 @@ impl, PINS, const I: usize> } } -/// Valid SPI pads. -pub trait Pads {} +/// Valid SPI Alternates. +pub trait Alternates {} -impl Pads<1> +impl Alternates<1> for ( - Pad>, - Pad>, - Pad>, + Alternate>, + Alternate>, + Alternate>, ) where A1: Deref, A2: Deref, A3: Deref, - Pad>: HasClkSignal, - Pad>: HasMosiSignal, - Pad>: HasCsSignal, + Alternate>: HasClkSignal, + Alternate>: HasMosiSignal, + Alternate>: HasCsSignal, { } -impl Pads<1> +impl + Alternates<1> for ( - Pad>, - Pad>, - Pad>, - Pad>, + Alternate>, + Alternate>, + Alternate>, + Alternate>, ) where A1: Deref, A2: Deref, A3: Deref, A4: Deref, - Pad>: HasClkSignal, - Pad>: HasMosiSignal, - Pad>: HasMisoSignal, - Pad>: HasCsSignal, + Alternate>: HasClkSignal, + Alternate>: HasMosiSignal, + Alternate>: HasMisoSignal, + Alternate>: HasCsSignal, { } /// Check if target gpio `Pin` is internally connected to SPI clock signal. pub trait HasClkSignal {} -impl HasClkSignal for Pad> {} -impl HasClkSignal for Pad> {} -impl HasClkSignal for Pad> {} -impl HasClkSignal for Pad> {} -impl HasClkSignal for Pad> {} -impl HasClkSignal for Pad> {} -impl HasClkSignal for Pad> {} -impl HasClkSignal for Pad> {} -impl HasClkSignal for Pad> {} -impl HasClkSignal for Pad> {} -impl HasClkSignal for Pad> {} +impl HasClkSignal for Alternate> {} +impl HasClkSignal for Alternate> {} +impl HasClkSignal for Alternate> {} +impl HasClkSignal for Alternate> {} +impl HasClkSignal for Alternate> {} +impl HasClkSignal for Alternate> {} +impl HasClkSignal for Alternate> {} +impl HasClkSignal for Alternate> {} +impl HasClkSignal for Alternate> {} +impl HasClkSignal for Alternate> {} +impl HasClkSignal for Alternate> {} /// Check if target gpio `Pin` is internally connected to SPI MISO signal. pub trait HasMisoSignal {} -impl HasMisoSignal for Pad> {} -impl HasMisoSignal for Pad> {} -impl HasMisoSignal for Pad> {} -impl HasMisoSignal for Pad> {} -impl HasMisoSignal for Pad> {} -impl HasMisoSignal for Pad> {} -impl HasMisoSignal for Pad> {} -impl HasMisoSignal for Pad> {} -impl HasMisoSignal for Pad> {} -impl HasMisoSignal for Pad> {} -impl HasMisoSignal for Pad> {} +impl HasMisoSignal for Alternate> {} +impl HasMisoSignal for Alternate> {} +impl HasMisoSignal for Alternate> {} +impl HasMisoSignal for Alternate> {} +impl HasMisoSignal for Alternate> {} +impl HasMisoSignal for Alternate> {} +impl HasMisoSignal for Alternate> {} +impl HasMisoSignal for Alternate> {} +impl HasMisoSignal for Alternate> {} +impl HasMisoSignal for Alternate> {} +impl HasMisoSignal for Alternate> {} /// Check if target gpio `Pin` is internally connected to SPI MOSI signal. pub trait HasMosiSignal {} -impl HasMosiSignal for Pad> {} -impl HasMosiSignal for Pad> {} -impl HasMosiSignal for Pad> {} -impl HasMosiSignal for Pad> {} -impl HasMosiSignal for Pad> {} -impl HasMosiSignal for Pad> {} -impl HasMosiSignal for Pad> {} -impl HasMosiSignal for Pad> {} -impl HasMosiSignal for Pad> {} -impl HasMosiSignal for Pad> {} -impl HasMosiSignal for Pad> {} -impl HasMosiSignal for Pad> {} +impl HasMosiSignal for Alternate> {} +impl HasMosiSignal for Alternate> {} +impl HasMosiSignal for Alternate> {} +impl HasMosiSignal for Alternate> {} +impl HasMosiSignal for Alternate> {} +impl HasMosiSignal for Alternate> {} +impl HasMosiSignal for Alternate> {} +impl HasMosiSignal for Alternate> {} +impl HasMosiSignal for Alternate> {} +impl HasMosiSignal for Alternate> {} +impl HasMosiSignal for Alternate> {} +impl HasMosiSignal for Alternate> {} /// Check if target gpio `Pin` is internally connected to SPI CS signal. pub trait HasCsSignal {} -impl HasCsSignal for Pad> {} -impl HasCsSignal for Pad> {} -impl HasCsSignal for Pad> {} -impl HasCsSignal for Pad> {} -impl HasCsSignal for Pad> {} -impl HasCsSignal for Pad> {} -impl HasCsSignal for Pad> {} -impl HasCsSignal for Pad> {} -impl HasCsSignal for Pad> {} -impl HasCsSignal for Pad> {} -impl HasCsSignal for Pad> {} -impl HasCsSignal for Pad> {} +impl HasCsSignal for Alternate> {} +impl HasCsSignal for Alternate> {} +impl HasCsSignal for Alternate> {} +impl HasCsSignal for Alternate> {} +impl HasCsSignal for Alternate> {} +impl HasCsSignal for Alternate> {} +impl HasCsSignal for Alternate> {} +impl HasCsSignal for Alternate> {} +impl HasCsSignal for Alternate> {} +impl HasCsSignal for Alternate> {} +impl HasCsSignal for Alternate> {} +impl HasCsSignal for Alternate> {} #[cfg(test)] mod tests { diff --git a/bouffalo-hal/src/uart/pad.rs b/bouffalo-hal/src/uart/pad.rs index 4a6cf72..76d0ed3 100644 --- a/bouffalo-hal/src/uart/pad.rs +++ b/bouffalo-hal/src/uart/pad.rs @@ -1,62 +1,62 @@ use super::{BlockingReceiveHalf, BlockingTransmitHalf, MuxCts, MuxRts, MuxRxd, MuxTxd, UartMux}; use crate::glb; -use crate::gpio::{MmUart, Pad, Uart}; +use crate::gpio::{Alternate, MmUart, Uart}; use core::ops::Deref; /// Check if target gpio `Pin` is internally connected to UART signal index `I`. pub trait HasUartSignal {} -impl HasUartSignal<0> for Pad {} -impl HasUartSignal<1> for Pad {} -impl HasUartSignal<2> for Pad {} -impl HasUartSignal<3> for Pad {} -impl HasUartSignal<4> for Pad {} -impl HasUartSignal<5> for Pad {} -impl HasUartSignal<6> for Pad {} -impl HasUartSignal<7> for Pad {} -impl HasUartSignal<8> for Pad {} -impl HasUartSignal<9> for Pad {} -impl HasUartSignal<10> for Pad {} -impl HasUartSignal<11> for Pad {} -impl HasUartSignal<0> for Pad {} -impl HasUartSignal<1> for Pad {} -impl HasUartSignal<2> for Pad {} -impl HasUartSignal<3> for Pad {} -impl HasUartSignal<4> for Pad {} -impl HasUartSignal<5> for Pad {} -impl HasUartSignal<6> for Pad {} -impl HasUartSignal<7> for Pad {} -impl HasUartSignal<8> for Pad {} -impl HasUartSignal<9> for Pad {} -impl HasUartSignal<10> for Pad {} -impl HasUartSignal<11> for Pad {} -impl HasUartSignal<0> for Pad {} -impl HasUartSignal<1> for Pad {} -impl HasUartSignal<2> for Pad {} -impl HasUartSignal<3> for Pad {} -impl HasUartSignal<4> for Pad {} -impl HasUartSignal<5> for Pad {} -impl HasUartSignal<6> for Pad {} -impl HasUartSignal<7> for Pad {} -impl HasUartSignal<8> for Pad {} -impl HasUartSignal<9> for Pad {} -impl HasUartSignal<10> for Pad {} -impl HasUartSignal<11> for Pad {} -impl HasUartSignal<0> for Pad {} -impl HasUartSignal<1> for Pad {} -impl HasUartSignal<2> for Pad {} -impl HasUartSignal<3> for Pad {} -impl HasUartSignal<4> for Pad {} -impl HasUartSignal<5> for Pad {} -impl HasUartSignal<6> for Pad {} -impl HasUartSignal<7> for Pad {} -impl HasUartSignal<8> for Pad {} -impl HasUartSignal<9> for Pad {} +impl HasUartSignal<0> for Alternate {} +impl HasUartSignal<1> for Alternate {} +impl HasUartSignal<2> for Alternate {} +impl HasUartSignal<3> for Alternate {} +impl HasUartSignal<4> for Alternate {} +impl HasUartSignal<5> for Alternate {} +impl HasUartSignal<6> for Alternate {} +impl HasUartSignal<7> for Alternate {} +impl HasUartSignal<8> for Alternate {} +impl HasUartSignal<9> for Alternate {} +impl HasUartSignal<10> for Alternate {} +impl HasUartSignal<11> for Alternate {} +impl HasUartSignal<0> for Alternate {} +impl HasUartSignal<1> for Alternate {} +impl HasUartSignal<2> for Alternate {} +impl HasUartSignal<3> for Alternate {} +impl HasUartSignal<4> for Alternate {} +impl HasUartSignal<5> for Alternate {} +impl HasUartSignal<6> for Alternate {} +impl HasUartSignal<7> for Alternate {} +impl HasUartSignal<8> for Alternate {} +impl HasUartSignal<9> for Alternate {} +impl HasUartSignal<10> for Alternate {} +impl HasUartSignal<11> for Alternate {} +impl HasUartSignal<0> for Alternate {} +impl HasUartSignal<1> for Alternate {} +impl HasUartSignal<2> for Alternate {} +impl HasUartSignal<3> for Alternate {} +impl HasUartSignal<4> for Alternate {} +impl HasUartSignal<5> for Alternate {} +impl HasUartSignal<6> for Alternate {} +impl HasUartSignal<7> for Alternate {} +impl HasUartSignal<8> for Alternate {} +impl HasUartSignal<9> for Alternate {} +impl HasUartSignal<10> for Alternate {} +impl HasUartSignal<11> for Alternate {} +impl HasUartSignal<0> for Alternate {} +impl HasUartSignal<1> for Alternate {} +impl HasUartSignal<2> for Alternate {} +impl HasUartSignal<3> for Alternate {} +impl HasUartSignal<4> for Alternate {} +impl HasUartSignal<5> for Alternate {} +impl HasUartSignal<6> for Alternate {} +impl HasUartSignal<7> for Alternate {} +impl HasUartSignal<8> for Alternate {} +impl HasUartSignal<9> for Alternate {} /// Check if an internal multi-media UART signal is connected to target gpio `Pin`. pub trait HasMmUartSignal {} -impl HasMmUartSignal for Pad {} +impl HasMmUartSignal for Alternate {} /// Valid UART pads. #[diagnostic::on_unimplemented( @@ -93,17 +93,17 @@ fn from_pads( } impl Pads - for (Pad, UartMux>) + for (Alternate, UartMux>) where A1: Deref, - Pad: HasUartSignal, + Alternate: HasUartSignal, { const RTS: bool = false; const CTS: bool = false; const TXD: bool = true; const RXD: bool = false; type Split = ( - BlockingTransmitHalf, UartMux>)>, + BlockingTransmitHalf, UartMux>)>, BlockingReceiveHalf, ); #[inline] @@ -124,22 +124,22 @@ impl< const N2: usize, > Pads for ( - (Pad, UartMux>), - (Pad, UartMux>), + (Alternate, UartMux>), + (Alternate, UartMux>), ) where A1: Deref, A3: Deref, - Pad: HasUartSignal, - Pad: HasUartSignal, + Alternate: HasUartSignal, + Alternate: HasUartSignal, { const RTS: bool = false; const CTS: bool = false; const TXD: bool = true; const RXD: bool = true; type Split = ( - BlockingTransmitHalf, UartMux>)>, - BlockingReceiveHalf, UartMux>)>, + BlockingTransmitHalf, UartMux>)>, + BlockingReceiveHalf, UartMux>)>, ); #[inline] fn split(self, uart: T) -> Self::Split { @@ -159,14 +159,14 @@ impl< const N2: usize, > Pads for ( - (Pad, UartMux>), - (Pad, UartMux>), + (Alternate, UartMux>), + (Alternate, UartMux>), ) where A1: Deref, A3: Deref, - Pad: HasUartSignal, - Pad: HasUartSignal, + Alternate: HasUartSignal, + Alternate: HasUartSignal, { const RTS: bool = false; const CTS: bool = true; @@ -175,8 +175,8 @@ where type Split = BlockingTransmitHalf< T, ( - (Pad, UartMux>), - (Pad, UartMux>), + (Alternate, UartMux>), + (Alternate, UartMux>), ), >; #[inline] @@ -205,20 +205,20 @@ impl< const N4: usize, > Pads for ( - (Pad, UartMux>), - (Pad, UartMux>), - (Pad, UartMux>), - (Pad, UartMux>), + (Alternate, UartMux>), + (Alternate, UartMux>), + (Alternate, UartMux>), + (Alternate, UartMux>), ) where A1: Deref, A3: Deref, A5: Deref, A7: Deref, - Pad: HasUartSignal, - Pad: HasUartSignal, - Pad: HasUartSignal, - Pad: HasUartSignal, + Alternate: HasUartSignal, + Alternate: HasUartSignal, + Alternate: HasUartSignal, + Alternate: HasUartSignal, { const RTS: bool = false; const CTS: bool = true; @@ -228,15 +228,15 @@ where BlockingTransmitHalf< T, ( - (Pad, UartMux>), - (Pad, UartMux>), + (Alternate, UartMux>), + (Alternate, UartMux>), ), >, BlockingReceiveHalf< T, ( - (Pad, UartMux>), - (Pad, UartMux>), + (Alternate, UartMux>), + (Alternate, UartMux>), ), >, ); @@ -250,10 +250,10 @@ where const MMUART_UART_ID: usize = 3; -impl Pads for Pad +impl Pads for Alternate where A1: Deref, - Pad: HasMmUartSignal, + Alternate: HasMmUartSignal, { const RTS: bool = { N % 4 == 2 }; const CTS: bool = { N % 4 == 3 }; @@ -268,12 +268,12 @@ where } impl Pads - for (Pad, Pad) + for (Alternate, Alternate) where A1: Deref, A2: Deref, - Pad: HasMmUartSignal, - Pad: HasMmUartSignal, + Alternate: HasMmUartSignal, + Alternate: HasMmUartSignal, { const RTS: bool = { N1 % 4 == 2 || N2 % 4 == 2 }; const CTS: bool = { N1 % 4 == 3 || N2 % 4 == 3 }; @@ -289,17 +289,17 @@ where impl Pads for ( - Pad, - Pad, - Pad, + Alternate, + Alternate, + Alternate, ) where A1: Deref, A2: Deref, A3: Deref, - Pad: HasMmUartSignal, - Pad: HasMmUartSignal, - Pad: HasMmUartSignal, + Alternate: HasMmUartSignal, + Alternate: HasMmUartSignal, + Alternate: HasMmUartSignal, { const RTS: bool = { N1 % 4 == 2 || N2 % 4 == 2 || N3 % 4 == 2 }; const CTS: bool = { N1 % 4 == 3 || N2 % 4 == 3 || N3 % 4 == 3 }; @@ -316,20 +316,20 @@ where impl Pads for ( - Pad, - Pad, - Pad, - Pad, + Alternate, + Alternate, + Alternate, + Alternate, ) where A1: Deref, A2: Deref, A3: Deref, A4: Deref, - Pad: HasMmUartSignal, - Pad: HasMmUartSignal, - Pad: HasMmUartSignal, - Pad: HasMmUartSignal, + Alternate: HasMmUartSignal, + Alternate: HasMmUartSignal, + Alternate: HasMmUartSignal, + Alternate: HasMmUartSignal, { const RTS: bool = { N1 % 4 == 2 || N2 % 4 == 2 || N3 % 4 == 2 || N4 % 4 == 2 }; const CTS: bool = { N1 % 4 == 3 || N2 % 4 == 3 || N3 % 4 == 3 || N4 % 4 == 3 }; diff --git a/examples/peripherals/sdcard-gpt-demo/src/main.rs b/examples/peripherals/sdcard-gpt-demo/src/main.rs index 038662d..0679c96 100644 --- a/examples/peripherals/sdcard-gpt-demo/src/main.rs +++ b/examples/peripherals/sdcard-gpt-demo/src/main.rs @@ -249,22 +249,22 @@ fn main(p: Peripherals, c: Clocks) -> ! { Spi< bouffalo_rt::soc::bl808::SPI0, ( - bouffalo_hal::gpio::Pad< + bouffalo_hal::gpio::Alternate< bouffalo_rt::soc::bl808::GLBv2, 3, bouffalo_hal::gpio::Spi<1>, >, - bouffalo_hal::gpio::Pad< + bouffalo_hal::gpio::Alternate< bouffalo_rt::soc::bl808::GLBv2, 1, bouffalo_hal::gpio::Spi<1>, >, - bouffalo_hal::gpio::Pad< + bouffalo_hal::gpio::Alternate< bouffalo_rt::soc::bl808::GLBv2, 2, bouffalo_hal::gpio::Spi<1>, >, - bouffalo_hal::gpio::Pad< + bouffalo_hal::gpio::Alternate< bouffalo_rt::soc::bl808::GLBv2, 0, bouffalo_hal::gpio::Spi<1>,