pub struct Pin<const P: char, const N: u8, MODE> { /* private fields */ }Expand description
A single pin: P is the port ('A', 'B', 'C' or 'F'), N the pin
number.
Implementations§
Source§impl<const P: char, const N: u8> Pin<P, N, Debugger>
Ways out of Debugger, each giving up debug access on this pin.
impl<const P: char, const N: u8> Pin<P, N, Debugger>
Ways out of Debugger, each giving up debug access on this pin.
Every one of them writes the mode itself rather than merely relabelling the type, so the pin never sits in a state its type misdescribes.
The activate_ prefix announces the cost: once the pin leaves SWD, the board
stops answering the probe until the next reset.
Sourcepub fn activate_into_input(self) -> Pin<P, N, Input>
pub fn activate_into_input(self) -> Pin<P, N, Input>
Releases the pin as a digital input.
Sourcepub fn activate(self) -> Pin<P, N, Input>
pub fn activate(self) -> Pin<P, N, Input>
Releases the pin as an input; shorthand for
activate_into_input.
Sourcepub fn activate_into_push_pull_output(self) -> Pin<P, N, Output<PushPull>>
pub fn activate_into_push_pull_output(self) -> Pin<P, N, Output<PushPull>>
Releases the pin as a push-pull output.
Sourcepub fn activate_into_open_drain_output(self) -> Pin<P, N, Output<OpenDrain>>
pub fn activate_into_open_drain_output(self) -> Pin<P, N, Output<OpenDrain>>
Releases the pin as an open-drain output.
Sourcepub fn activate_into_output(self) -> Pin<P, N, Output<PushPull>>
pub fn activate_into_output(self) -> Pin<P, N, Output<PushPull>>
Releases the pin as an output; shorthand for the push-pull variant.
Sourcepub fn activate_into_analog(self) -> Pin<P, N, Analog>
pub fn activate_into_analog(self) -> Pin<P, N, Analog>
Releases the pin as an analog input, as required by the ADC.
Sourcepub fn activate_into_alternate<const AF: u8>(self) -> Pin<P, N, Alternate<AF>>where
Self: ValidAf<AF>,
pub fn activate_into_alternate<const AF: u8>(self) -> Pin<P, N, Alternate<AF>>where
Self: ValidAf<AF>,
Releases the pin to a peripheral through alternate function AF,
driven push-pull.
Gated by ValidAf exactly as
into_alternate is.
Source§impl<const P: char, const N: u8, MODE> Pin<P, N, MODE>where
MODE: Active,
impl<const P: char, const N: u8, MODE> Pin<P, N, MODE>where
MODE: Active,
Sourcepub fn into_input(self) -> Pin<P, N, Input>
pub fn into_input(self) -> Pin<P, N, Input>
Reconfigures the pin as a digital input.
Sourcepub fn into_push_pull_output(self) -> Pin<P, N, Output<PushPull>>
pub fn into_push_pull_output(self) -> Pin<P, N, Output<PushPull>>
Reconfigures the pin as a push-pull output.
Sourcepub fn into_open_drain_output(self) -> Pin<P, N, Output<OpenDrain>>
pub fn into_open_drain_output(self) -> Pin<P, N, Output<OpenDrain>>
Reconfigures the pin as an open-drain output.
The pin can also be read back in this mode, which shared buses such as I²C rely on.
Sourcepub fn into_output(self) -> Pin<P, N, Output<PushPull>>
pub fn into_output(self) -> Pin<P, N, Output<PushPull>>
Reconfigures the pin as an output; shorthand for the push-pull variant.
Sourcepub fn into_analog(self) -> Pin<P, N, Analog>
pub fn into_analog(self) -> Pin<P, N, Analog>
Reconfigures the pin as an analog input, as required by the ADC.
Sourcepub fn into_alternate<const AF: u8>(self) -> Pin<P, N, Alternate<AF>>where
Self: ValidAf<AF>,
pub fn into_alternate<const AF: u8>(self) -> Pin<P, N, Alternate<AF>>where
Self: ValidAf<AF>,
Routes the pin to a peripheral through alternate function AF, driven
push-pull.
Sourcepub fn into_alternate_open_drain<const AF: u8>(
self,
) -> Pin<P, N, Alternate<AF, OpenDrain>>where
Self: ValidAf<AF>,
pub fn into_alternate_open_drain<const AF: u8>(
self,
) -> Pin<P, N, Alternate<AF, OpenDrain>>where
Self: ValidAf<AF>,
Same, but leaves the pin open-drain: I2c accepts
only pins that went through here.
Sourcepub fn lock(self) -> Pin<P, N, Locked<MODE>>where
Self: HasLock,
pub fn lock(self) -> Pin<P, N, Locked<MODE>>where
Self: HasLock,
Freezes the pin’s configuration until the next chip reset.
Mode, pull, output type, speed and alternate function stop responding to
writes, with no way back in hardware or in the type: a Locked pin is
still read and written, never reconfigured. Ports with a LOCK register
only.
Source§impl<const P: char, const N: u8, OTYPE> Pin<P, N, Output<OTYPE>>
impl<const P: char, const N: u8, OTYPE> Pin<P, N, Output<OTYPE>>
Sourcepub fn is_set_high(&self) -> bool
pub fn is_set_high(&self) -> bool
Returns whether the pin is being driven high.
Reads back OCTL, i.e. what was last written, not what the wire is at —
for the latter on an open-drain pin see is_high.
Sourcepub fn is_set_low(&self) -> bool
pub fn is_set_low(&self) -> bool
Returns whether the pin is being driven low.
Source§impl<const P: char, const N: u8, MODE> Pin<P, N, Locked<MODE>>where
Pin<P, N, MODE>: StatefulOutputPin,
impl<const P: char, const N: u8, MODE> Pin<P, N, Locked<MODE>>where
Pin<P, N, MODE>: StatefulOutputPin,
Sourcepub fn is_set_high(&self) -> bool
pub fn is_set_high(&self) -> bool
Returns whether the pin is being driven high, read back from OCTL.
Sourcepub fn is_set_low(&self) -> bool
pub fn is_set_low(&self) -> bool
Returns whether the pin is being driven low, read back from OCTL.
Trait Implementations§
impl ChannelPin<Timer0, 0> for Pin<'A', 8, Alternate<2>>
pads_ge_24 only.impl ChannelPin<Timer0, 1> for Pin<'A', 9, Alternate<2>>
impl ChannelPin<Timer0, 2> for Pin<'A', 10, Alternate<2>>
impl ChannelPin<Timer2, 0> for Pin<'A', 6, Alternate<1>>
impl ChannelPin<Timer2, 0> for Pin<'B', 4, Alternate<1>>
pads_ge_28 only.impl ChannelPin<Timer2, 1> for Pin<'A', 7, Alternate<1>>
impl ChannelPin<Timer2, 1> for Pin<'B', 5, Alternate<1>>
pads_ge_28 only.impl ChannelPin<Timer2, 2> for Pin<'B', 0, Alternate<1>>
pads_ge_24 only.impl ChannelPin<Timer2, 3> for Pin<'B', 1, Alternate<1>>
impl ChannelPin<Timer13, 0> for Pin<'A', 4, Alternate<4>>
impl ChannelPin<Timer13, 0> for Pin<'A', 7, Alternate<4>>
impl ChannelPin<Timer13, 0> for Pin<'B', 1, Alternate<2>>
impl ChannelPin<Timer15, 0> for Pin<'A', 6, Alternate<5>>
impl ChannelPin<Timer16, 0> for Pin<'A', 7, Alternate<5>>
impl<MODE> ExtiConfigured for Pin<'A', 0, MODE>
impl<MODE> ExtiConfigured for Pin<'A', 1, MODE>
impl<MODE> ExtiConfigured for Pin<'A', 2, MODE>
impl<MODE> ExtiConfigured for Pin<'A', 3, MODE>
impl<MODE> ExtiConfigured for Pin<'A', 4, MODE>
impl<MODE> ExtiConfigured for Pin<'A', 5, MODE>
impl<MODE> ExtiConfigured for Pin<'A', 6, MODE>
impl<MODE> ExtiConfigured for Pin<'A', 7, MODE>
impl<MODE> ExtiConfigured for Pin<'A', 8, MODE>
pads_ge_24 only.impl<MODE> ExtiConfigured for Pin<'A', 9, MODE>
impl<MODE> ExtiConfigured for Pin<'A', 10, MODE>
impl<MODE> ExtiConfigured for Pin<'A', 13, MODE>
impl<MODE> ExtiConfigured for Pin<'A', 14, MODE>
impl<MODE> ExtiConfigured for Pin<'A', 15, MODE>
pads_ge_28 only.impl<MODE> ExtiConfigured for Pin<'B', 0, MODE>
pads_ge_24 only.impl<MODE> ExtiConfigured for Pin<'B', 1, MODE>
impl<MODE> ExtiConfigured for Pin<'B', 3, MODE>
pads_ge_28 only.impl<MODE> ExtiConfigured for Pin<'B', 4, MODE>
pads_ge_28 only.impl<MODE> ExtiConfigured for Pin<'B', 5, MODE>
pads_ge_28 only.impl<MODE> ExtiConfigured for Pin<'B', 6, MODE>
pads_ge_24 only.impl<MODE> ExtiConfigured for Pin<'B', 7, MODE>
pads_ge_24 only.impl<MODE> ExtiConfigured for Pin<'F', 0, MODE>
impl<MODE> ExtiConfigured for Pin<'F', 1, MODE>
impl<const N: u8, MODE> HasLock for Pin<'A', N, MODE>
impl<const N: u8, MODE> HasLock for Pin<'B', N, MODE>
Source§impl InvertingInput for Pin<'A', 4, Analog>
impl InvertingInput for Pin<'A', 4, Analog>
Source§impl InvertingInput for Pin<'A', 5, Analog>
impl InvertingInput for Pin<'A', 5, Analog>
Source§impl InvertingInput for Pin<'A', 0, Analog>
impl InvertingInput for Pin<'A', 0, Analog>
Source§impl InvertingInput for Pin<'A', 2, Analog>
impl InvertingInput for Pin<'A', 2, Analog>
impl MisoPin<Spi0> for Pin<'A', 6, Alternate<0>>
impl MisoPin<Spi0> for Pin<'B', 4, Alternate<0>>
pads_ge_28 only.impl MosiPin<Spi0> for Pin<'A', 7, Alternate<0>>
impl MosiPin<Spi0> for Pin<'B', 5, Alternate<0>>
pads_ge_28 only.Source§impl NonInvertingInput for Pin<'A', 1, Analog>
impl NonInvertingInput for Pin<'A', 1, Analog>
impl RxPin<Usart0> for Pin<'A', 10, Alternate<1>>
impl RxPin<Usart0> for Pin<'B', 7, Alternate<0>>
pads_ge_24 only.impl RxPin<Usart0> for Pin<'A', 3, Alternate<1>>
impl RxPin<Usart0> for Pin<'A', 15, Alternate<1>>
pads_ge_28 only.impl SckPin<Spi0> for Pin<'A', 5, Alternate<0>>
impl SckPin<Spi0> for Pin<'B', 3, Alternate<0>>
pads_ge_28 only.impl SclPin<I2c0> for Pin<'A', 9, Alternate<4, OpenDrain>>
impl SclPin<I2c0> for Pin<'B', 6, Alternate<1, OpenDrain>>
pads_ge_24 only.impl SclPin<I2c0> for Pin<'F', 1, Alternate<1, OpenDrain>>
impl SdaPin<I2c0> for Pin<'A', 10, Alternate<4, OpenDrain>>
impl SdaPin<I2c0> for Pin<'B', 7, Alternate<1, OpenDrain>>
pads_ge_24 only.impl SdaPin<I2c0> for Pin<'F', 0, Alternate<1, OpenDrain>>
Source§impl<const P: char, const N: u8, MODE> StatefulOutputPin for Pin<P, N, Locked<MODE>>where
Pin<P, N, MODE>: StatefulOutputPin,
impl<const P: char, const N: u8, MODE> StatefulOutputPin for Pin<P, N, Locked<MODE>>where
Pin<P, N, MODE>: StatefulOutputPin,
impl TxPin<Usart0> for Pin<'A', 9, Alternate<1>>
impl TxPin<Usart0> for Pin<'B', 6, Alternate<0>>
pads_ge_24 only.impl TxPin<Usart0> for Pin<'A', 2, Alternate<1>>
impl TxPin<Usart0> for Pin<'A', 14, Alternate<1>>
impl<MODE> ValidAf<0> for Pin<'A', 1, MODE>
AF0 — EVENTOUT.
impl<MODE> ValidAf<0> for Pin<'A', 4, MODE>
AF0 — SPI0_NSS/I2S0_WS.
impl<MODE> ValidAf<0> for Pin<'A', 5, MODE>
AF0 — SPI0_SCK/I2S0_CK.
impl<MODE> ValidAf<0> for Pin<'A', 6, MODE>
AF0 — SPI0_MISO.
impl<MODE> ValidAf<0> for Pin<'A', 7, MODE>
AF0 — SPI0_MOSI.
impl<MODE> ValidAf<0> for Pin<'A', 8, MODE>
pads_ge_24 only.AF0 — CK_OUT.
impl<MODE> ValidAf<0> for Pin<'A', 10, MODE>
AF0 — TIMER16_BRKIN.
impl<MODE> ValidAf<0> for Pin<'A', 13, MODE>
AF0 — SWDIO.
impl<MODE> ValidAf<0> for Pin<'A', 14, MODE>
AF0 — SWCLK.
impl<MODE> ValidAf<0> for Pin<'A', 15, MODE>
pads_ge_28 only.AF0 — SPI0_NSS/I2S0_WS.
impl<MODE> ValidAf<0> for Pin<'B', 0, MODE>
pads_ge_24 only.AF0 — EVENTOUT.
impl<MODE> ValidAf<0> for Pin<'B', 3, MODE>
pads_ge_28 only.AF0 — SPI0_SCK/I2S0_CK.
impl<MODE> ValidAf<0> for Pin<'B', 4, MODE>
pads_ge_28 only.AF0 — SPI0_MISO.
impl<MODE> ValidAf<0> for Pin<'B', 5, MODE>
pads_ge_28 only.AF0 — SPI0_MOSI.
impl<MODE> ValidAf<0> for Pin<'B', 6, MODE>
pads_ge_24 only.AF0 — USART0_TX.
impl<MODE> ValidAf<0> for Pin<'B', 7, MODE>
pads_ge_24 only.AF0 — USART0_RX.
impl<MODE> ValidAf<1> for Pin<'A', 0, MODE>
AF1 — USART0_CTS on x4, USART1_CTS on x6/x8.
impl<MODE> ValidAf<1> for Pin<'A', 1, MODE>
AF1 — USART0_RTS/DE on x4, USART1_RTS/DE on x6/x8.
impl<MODE> ValidAf<1> for Pin<'A', 2, MODE>
AF1 — USART0_TX on x4, USART1_TX on x6/x8.
impl<MODE> ValidAf<1> for Pin<'A', 3, MODE>
AF1 — USART0_RX on x4, USART1_RX on x6/x8.
impl<MODE> ValidAf<1> for Pin<'A', 4, MODE>
AF1 — USART0_CK on x4, USART1_CK on x6/x8.
impl<MODE> ValidAf<1> for Pin<'A', 6, MODE>
AF1 — TIMER2_CH0.
impl<MODE> ValidAf<1> for Pin<'A', 7, MODE>
AF1 — TIMER2_CH1.
impl<MODE> ValidAf<1> for Pin<'A', 8, MODE>
pads_ge_24 only.AF1 — USART0_CK.
impl<MODE> ValidAf<1> for Pin<'A', 9, MODE>
AF1 — USART0_TX.
impl<MODE> ValidAf<1> for Pin<'A', 10, MODE>
AF1 — USART0_RX.
impl<MODE> ValidAf<1> for Pin<'A', 13, MODE>
AF1 — IFRP_OUT.
impl<MODE> ValidAf<1> for Pin<'A', 14, MODE>
AF1 — USART0_TX on x4, USART1_TX on x6/x8.
impl<MODE> ValidAf<1> for Pin<'A', 15, MODE>
pads_ge_28 only.AF1 — USART0_RX on x4, USART1_RX on x6/x8.
impl<MODE> ValidAf<1> for Pin<'B', 0, MODE>
pads_ge_24 only.AF1 — TIMER2_CH2.
impl<MODE> ValidAf<1> for Pin<'B', 1, MODE>
AF1 — TIMER2_CH3.
impl<MODE> ValidAf<1> for Pin<'B', 3, MODE>
pads_ge_28 only.AF1 — EVENTOUT.
impl<MODE> ValidAf<1> for Pin<'B', 4, MODE>
pads_ge_28 only.AF1 — TIMER2_CH0.
impl<MODE> ValidAf<1> for Pin<'B', 5, MODE>
pads_ge_28 only.AF1 — TIMER2_CH1.
impl<MODE> ValidAf<1> for Pin<'B', 6, MODE>
pads_ge_24 only.AF1 — I2C0_SCL.
impl<MODE> ValidAf<1> for Pin<'B', 7, MODE>
pads_ge_24 only.AF1 — I2C0_SDA.
impl<MODE> ValidAf<1> for Pin<'F', 0, MODE>
AF1 — I2C0_SDA.
impl<MODE> ValidAf<1> for Pin<'F', 1, MODE>
AF1 — I2C0_SCL.
impl<MODE> ValidAf<2> for Pin<'A', 6, MODE>
AF2 — TIMER0_BRKIN.
impl<MODE> ValidAf<2> for Pin<'A', 7, MODE>
AF2 — TIMER0_CH0_ON.
impl<MODE> ValidAf<2> for Pin<'A', 8, MODE>
pads_ge_24 only.AF2 — TIMER0_CH0.
impl<MODE> ValidAf<2> for Pin<'A', 9, MODE>
AF2 — TIMER0_CH1.
impl<MODE> ValidAf<2> for Pin<'A', 10, MODE>
AF2 — TIMER0_CH2.
impl<MODE> ValidAf<2> for Pin<'B', 0, MODE>
pads_ge_24 only.AF2 — TIMER0_CH1_ON.
impl<MODE> ValidAf<2> for Pin<'B', 1, MODE>
AF2 — TIMER13_CH0.
impl<MODE> ValidAf<2> for Pin<'B', 4, MODE>
pads_ge_28 only.AF2 — EVENTOUT.
impl<MODE> ValidAf<2> for Pin<'B', 5, MODE>
pads_ge_28 only.AF2 — I2C0_SMBA.
impl<MODE> ValidAf<2> for Pin<'B', 6, MODE>
pads_ge_24 only.AF2 — TIMER15_CH0_ON.
impl<MODE> ValidAf<2> for Pin<'B', 7, MODE>
pads_ge_24 only.AF2 — TIMER16_CH0_ON.
impl<MODE> ValidAf<3> for Pin<'A', 8, MODE>
pads_ge_24 only.AF3 — EVENTOUT.
impl<MODE> ValidAf<3> for Pin<'A', 15, MODE>
pads_ge_28 only.AF3 — EVENTOUT.
impl<MODE> ValidAf<3> for Pin<'B', 1, MODE>
AF3 — TIMER0_CH2_ON.
impl<MODE> ValidAf<3> for Pin<'B', 5, MODE>
pads_ge_28 only.AF3 — TIMER15_BRKIN.
impl<MODE> ValidAf<4> for Pin<'A', 4, MODE>
AF4 — TIMER13_CH0.
impl<MODE> ValidAf<4> for Pin<'A', 7, MODE>
AF4 — TIMER13_CH0.
impl<MODE> ValidAf<4> for Pin<'A', 9, MODE>
AF4 — I2C0_SCL.
impl<MODE> ValidAf<4> for Pin<'A', 10, MODE>
AF4 — I2C0_SDA.
impl<MODE> ValidAf<4> for Pin<'B', 4, MODE>
pads_ge_28 only.AF4 — I2C0_TXFRAME.
impl<MODE> ValidAf<5> for Pin<'A', 6, MODE>
AF5 — TIMER15_CH0.
impl<MODE> ValidAf<5> for Pin<'A', 7, MODE>
AF5 — TIMER16_CH0.
impl<MODE> ValidAf<5> for Pin<'A', 9, MODE>
AF5 — CK_OUT.
impl<MODE> ValidAf<6> for Pin<'A', 6, MODE>
AF6 — EVENTOUT.
impl<MODE> ValidAf<6> for Pin<'A', 7, MODE>
AF6 — EVENTOUT.
impl<MODE> ValidAf<6> for Pin<'B', 4, MODE>
pads_ge_28 only.AF6 — TIMER16_BRKIN.
impl<MODE> ValidAf<7> for Pin<'A', 0, MODE>
AF7 — CMP_OUT.
impl<MODE> ValidAf<7> for Pin<'A', 6, MODE>
AF7 — CMP_OUT.