Skip to content

Commit a36bb93

Browse files
committed
generic
1 parent af887fe commit a36bb93

File tree

14 files changed

+294
-277
lines changed

14 files changed

+294
-277
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212
- Split USART and UART implementations [#608]
1313
- Add `lapce` editor settings [#601]
1414
- Use `enum`s for alternate peripheral pins [#594] [#610]
15+
- Use `enum`s for alternate peripheral pins [#594]
16+
- Use `enum`s for alternate peripheral pins (generic over otype) [#594] [#596] [#600]
1517
- Added missing U(S)ART DMA traits for HAL serial types [#593]
1618
- Improve SPI::new* docs [#587]
1719
- Add advanced timer dead time insertion example [#585]
@@ -65,6 +67,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6567
[#577]: https://github.com/stm32-rs/stm32f4xx-hal/pull/577
6668
[#578]: https://github.com/stm32-rs/stm32f4xx-hal/pull/578
6769
[#581]: https://github.com/stm32-rs/stm32f4xx-hal/pull/581
70+
[#594]: https://github.com/stm32-rs/stm32f4xx-hal/pull/594
71+
[#595]: https://github.com/stm32-rs/stm32f4xx-hal/pull/595
72+
[#596]: https://github.com/stm32-rs/stm32f4xx-hal/pull/596
73+
[#599]: https://github.com/stm32-rs/stm32f4xx-hal/pull/599
74+
[#601]: https://github.com/stm32-rs/stm32f4xx-hal/pull/601
75+
[#603]: https://github.com/stm32-rs/stm32f4xx-hal/pull/603
76+
[#600]: https://github.com/stm32-rs/stm32f4xx-hal/pull/600
6877

6978

7079
## [v0.14.0] - 2022-12-12

examples/i2s-audio-out.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn main() -> ! {
104104
.i2s_clk(61440.kHz())
105105
.freeze();
106106

107-
let i2s_pins = (gpioa.pa4, gpioc.pc10, NoPin, gpioc.pc12);
107+
let i2s_pins = (gpioa.pa4, gpioc.pc10, NoPin::new(), gpioc.pc12);
108108
let i2s = I2s::new(dp.SPI3, i2s_pins, &clocks);
109109
let i2s_config = I2sTransferConfig::new_master()
110110
.transmit()

examples/ist7920-bidi-normal-spi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() -> ! {
2929
led.set_low();
3030

3131
let sck = gpiob.pb3.into_alternate();
32-
let miso = NoMiso {};
32+
let miso = NoMiso::new();
3333
let mosi = gpiob.pb5.into_alternate();
3434

3535
let dc = gpiob.pb4.into_push_pull_output();

examples/rtic-i2s-audio-in-out.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ mod app {
188188
i2s2_driver.set_error_interrupt(true);
189189

190190
// I2S3 pins: (WS, CK, NoPin, SD) for I2S3
191-
let i2s3_pins = (gpioa.pa4, gpioc.pc10, NoPin, gpioc.pc12);
191+
let i2s3_pins = (gpioa.pa4, gpioc.pc10, NoPin::new(), gpioc.pc12);
192192
let i2s3 = I2s::new(device.SPI3, i2s3_pins, &clocks);
193193
let i2s3_config = i2s2_config.to_slave().transmit();
194194
let mut i2s3_driver = I2sDriver::new(i2s3, i2s3_config);

examples/spi-dma.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn main() -> ! {
5555
phase: Phase::CaptureOnFirstTransition,
5656
};
5757

58-
let spi2 = Spi::new(dp.SPI2, (pb13, NoMiso {}, pb15), mode, 3.MHz(), &clocks);
58+
let spi2 = Spi::new(dp.SPI2, (pb13, NoMiso::new(), pb15), mode, 3.MHz(), &clocks);
5959

6060
let buffer = cortex_m::singleton!(: [u8; ARRAY_SIZE] = [1; ARRAY_SIZE]).unwrap();
6161

examples/ws2812-spi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn main() -> ! {
2222
let gpioa = dp.GPIOA.split();
2323

2424
let spi = dp.SPI1.spi(
25-
(gpioa.pa5, NoPin, gpioa.pa7),
25+
(gpioa.pa5, NoPin::new(), gpioa.pa7),
2626
ws2812::MODE,
2727
3500.kHz(),
2828
&clocks,

src/can.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<CAN: Instance> Can<CAN> {
105105
where
106106
NoPin: Into<CAN::Rx>,
107107
{
108-
Self::new(usart, (tx_pin, NoPin))
108+
Self::new(usart, (tx_pin, NoPin::new()))
109109
}
110110
}
111111

@@ -114,7 +114,7 @@ impl<CAN: Instance> Can<CAN> {
114114
where
115115
NoPin: Into<CAN::Tx>,
116116
{
117-
Self::new(usart, (NoPin, rx_pin))
117+
Self::new(usart, (NoPin::new(), rx_pin))
118118
}
119119
}
120120

src/fmpi2c.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::ops::Deref;
22

3-
use crate::gpio;
3+
use crate::gpio::{self, OpenDrain};
44
use crate::i2c::{Error, NoAcknowledgeSource};
55
use crate::pac::{fmpi2c1, FMPI2C1, RCC};
66
use crate::rcc::{Enable, Reset};
@@ -21,8 +21,8 @@ pub trait Instance:
2121
}
2222

2323
impl Instance for FMPI2C1 {
24-
type Sda = gpio::alt::fmpi2c1::Sda;
25-
type Scl = gpio::alt::fmpi2c1::Scl;
24+
type Sda = gpio::alt::fmpi2c1::Sda<OpenDrain>;
25+
type Scl = gpio::alt::fmpi2c1::Scl<OpenDrain>;
2626
fn ptr() -> *const fmpi2c1::RegisterBlock {
2727
FMPI2C1::ptr() as *const _
2828
}

src/gpio.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,14 @@ pub use embedded_hal::digital::v2::PinState;
7676
use core::fmt;
7777

7878
/// A filler pin type
79-
#[derive(Debug)]
79+
#[derive(Debug, Default)]
8080
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
81-
pub struct NoPin;
81+
pub struct NoPin<Otype = PushPull>(PhantomData<Otype>);
82+
impl<Otype> NoPin<Otype> {
83+
pub fn new() -> Self {
84+
Self(PhantomData)
85+
}
86+
}
8287

8388
/// Extension trait to split a GPIO peripheral in independent pins and registers
8489
pub trait GpioExt {

0 commit comments

Comments
 (0)