Skip to content

Commit 8913a39

Browse files
bors[bot]dimpoloburrbull
authored
Merge #266
266: const generic pins r=therealprof a=burrbull requires Rust 1.51 Depends on #323 Co-authored-by: Dimitri Polonski <dimi.polonski@gmail.com> Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
2 parents 1f57503 + 23c3d11 commit 8913a39

17 files changed

+826
-644
lines changed

CHANGELOG.md

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

1010
### Added
1111

12+
- Generic `into_alternate` and `into_alternate_open_drain`. Non-generic ones are deprecated
13+
- Internal implementation of GPIO Pin API changed to use Const Generics
1214
- `PinExt` trait. Make `ExtiPin` implementation generic
1315
- `Enable`, `LPEnable` and `Reset` traits in `rcc`. Implemented for all used peripherals
1416
- Features corresponding to peripherals
@@ -106,13 +108,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
106108
- Added support for CAN on additional models: STM32F412, STM32F413, STM32F415,
107109
STM32F417, STM32F423, STM32F427, STM32F429, STM32F437, STM32F439, STM32F469,
108110
and STM32F479 [#262]
111+
- Added `gpio::gpiox::Pxi::downgrade2` method [#272]
109112

110113
[#231]: https://github.com/stm32-rs/stm32f4xx-hal/pull/231
111114
[#262]: https://github.com/stm32-rs/stm32f4xx-hal/pull/262
112115
[#263]: https://github.com/stm32-rs/stm32f4xx-hal/pull/263
113116
[#278]: https://github.com/stm32-rs/stm32f4xx-hal/issues/278
114117
[#273]: https://github.com/stm32-rs/stm32f4xx-hal/pull/273
115118
[#286]: https://github.com/stm32-rs/stm32f4xx-hal/pull/286
119+
[#272]: https://github.com/stm32-rs/stm32f4xx-hal/issues/272
116120

117121
### Fixed
118122

examples/analog-stopwatch-with-spi-ssd1306.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ fn main() -> ! {
9494
//cs - pe4
9595
//dc - pe3
9696

97-
let sck = gpioe.pe2.into_alternate_af5();
98-
let miso = gpioe.pe5.into_alternate_af5();
99-
let mosi = gpioe.pe6.into_alternate_af5();
97+
let sck = gpioe.pe2.into_alternate();
98+
let miso = gpioe.pe5.into_alternate();
99+
let mosi = gpioe.pe6.into_alternate();
100100

101101
let spi = Spi::spi4(
102102
dp.SPI4,

examples/can-send.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ fn main() -> ! {
2525

2626
let gpiob = dp.GPIOB.split();
2727
let mut can1 = {
28-
let rx = gpiob.pb8.into_alternate_af9();
29-
let tx = gpiob.pb9.into_alternate_af9();
28+
let rx = gpiob.pb8.into_alternate();
29+
let tx = gpiob.pb9.into_alternate();
3030

3131
let can = Can::new(dp.CAN1, (tx, rx));
3232

@@ -43,8 +43,8 @@ fn main() -> ! {
4343
filters.enable_bank(0, Mask32::accept_all());
4444

4545
let _can2 = {
46-
let tx = gpiob.pb13.into_alternate_af9();
47-
let rx = gpiob.pb12.into_alternate_af9();
46+
let tx = gpiob.pb13.into_alternate();
47+
let rx = gpiob.pb12.into_alternate();
4848

4949
let can = Can::new(dp.CAN2, (tx, rx));
5050

examples/f413disco_lcd_ferris.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -710,27 +710,27 @@ fn main() -> ! {
710710
// Define the pins we need for our 16bit parallel bus
711711
let lcd_pins = LcdPins {
712712
data: (
713-
gpiod.pd14.into_alternate_af12(),
714-
gpiod.pd15.into_alternate_af12(),
715-
gpiod.pd0.into_alternate_af12(),
716-
gpiod.pd1.into_alternate_af12(),
717-
gpioe.pe7.into_alternate_af12(),
718-
gpioe.pe8.into_alternate_af12(),
719-
gpioe.pe9.into_alternate_af12(),
720-
gpioe.pe10.into_alternate_af12(),
721-
gpioe.pe11.into_alternate_af12(),
722-
gpioe.pe12.into_alternate_af12(),
723-
gpioe.pe13.into_alternate_af12(),
724-
gpioe.pe14.into_alternate_af12(),
725-
gpioe.pe15.into_alternate_af12(),
726-
gpiod.pd8.into_alternate_af12(),
727-
gpiod.pd9.into_alternate_af12(),
728-
gpiod.pd10.into_alternate_af12(),
713+
gpiod.pd14.into_alternate(),
714+
gpiod.pd15.into_alternate(),
715+
gpiod.pd0.into_alternate(),
716+
gpiod.pd1.into_alternate(),
717+
gpioe.pe7.into_alternate(),
718+
gpioe.pe8.into_alternate(),
719+
gpioe.pe9.into_alternate(),
720+
gpioe.pe10.into_alternate(),
721+
gpioe.pe11.into_alternate(),
722+
gpioe.pe12.into_alternate(),
723+
gpioe.pe13.into_alternate(),
724+
gpioe.pe14.into_alternate(),
725+
gpioe.pe15.into_alternate(),
726+
gpiod.pd8.into_alternate(),
727+
gpiod.pd9.into_alternate(),
728+
gpiod.pd10.into_alternate(),
729729
),
730-
address: gpiof.pf0.into_alternate_af12(),
731-
read_enable: gpiod.pd4.into_alternate_af12(),
732-
write_enable: gpiod.pd5.into_alternate_af12(),
733-
chip_select: ChipSelect3(gpiog.pg10.into_alternate_af12()),
730+
address: gpiof.pf0.into_alternate(),
731+
read_enable: gpiod.pd4.into_alternate(),
732+
write_enable: gpiod.pd5.into_alternate(),
733+
chip_select: ChipSelect3(gpiog.pg10.into_alternate()),
734734
};
735735

736736
// Setup the RESET pin

examples/i2s-audio-out-dma.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ fn main() -> ! {
107107
let i2c = I2c::new(
108108
dp.I2C1,
109109
(
110-
gpiob.pb6.into_alternate_af4_open_drain(),
111-
gpiob.pb9.into_alternate_af4_open_drain(),
110+
gpiob.pb6.into_alternate_open_drain(),
111+
gpiob.pb9.into_alternate_open_drain(),
112112
),
113113
100.khz(),
114114
clocks,
@@ -120,10 +120,10 @@ fn main() -> ! {
120120

121121
// I2S pins: (WS, CK, MCLK, SD) for I2S3
122122
let i2s_pins = (
123-
gpioa.pa4.into_alternate_af6(),
124-
gpioc.pc10.into_alternate_af6(),
125-
gpioc.pc7.into_alternate_af6(),
126-
gpioc.pc12.into_alternate_af6(),
123+
gpioa.pa4.into_alternate(),
124+
gpioc.pc10.into_alternate(),
125+
gpioc.pc7.into_alternate(),
126+
gpioc.pc12.into_alternate(),
127127
);
128128
let hal_i2s = I2s::i2s3(dp.SPI3, i2s_pins, clocks);
129129
let i2s_clock = hal_i2s.input_clock();

examples/i2s-audio-out.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ fn main() -> ! {
105105
let i2c = I2c::new(
106106
dp.I2C1,
107107
(
108-
gpiob.pb6.into_alternate_af4_open_drain(),
109-
gpiob.pb9.into_alternate_af4_open_drain(),
108+
gpiob.pb6.into_alternate_open_drain(),
109+
gpiob.pb9.into_alternate_open_drain(),
110110
),
111111
100.khz(),
112112
clocks,
@@ -118,10 +118,10 @@ fn main() -> ! {
118118

119119
// I2S pins: (WS, CK, MCLK, SD) for I2S3
120120
let i2s_pins = (
121-
gpioa.pa4.into_alternate_af6(),
122-
gpioc.pc10.into_alternate_af6(),
123-
gpioc.pc7.into_alternate_af6(),
124-
gpioc.pc12.into_alternate_af6(),
121+
gpioa.pa4.into_alternate(),
122+
gpioc.pc10.into_alternate(),
123+
gpioc.pc7.into_alternate(),
124+
gpioc.pc12.into_alternate(),
125125
);
126126
let hal_i2s = I2s::i2s3(dp.SPI3, i2s_pins, clocks);
127127
let i2s_clock = hal_i2s.input_clock();

examples/pwm.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ fn main() -> ! {
1616
let clocks = rcc.cfgr.freeze();
1717

1818
let gpioa = dp.GPIOA.split();
19-
let channels = (
20-
gpioa.pa8.into_alternate_af1(),
21-
gpioa.pa9.into_alternate_af1(),
22-
);
19+
let channels = (gpioa.pa8.into_alternate(), gpioa.pa9.into_alternate());
2320

2421
let pwm = pwm::tim1(dp.TIM1, channels, clocks, 20u32.khz());
2522
let (mut ch1, _ch2) = pwm;

examples/qei.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ fn main() -> ! {
3737
let gpioa = dp.GPIOA.split();
3838

3939
// Connect a rotary encoder to pins A0 and A1.
40-
let rotary_encoder_pins = (
41-
gpioa.pa0.into_alternate_af1(),
42-
gpioa.pa1.into_alternate_af1(),
43-
);
40+
let rotary_encoder_pins = (gpioa.pa0.into_alternate(), gpioa.pa1.into_alternate());
4441
let rotary_encoder_timer = dp.TIM2;
4542
let rotary_encoder = Qei::new(rotary_encoder_timer, rotary_encoder_pins);
4643

examples/rng-display.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ fn main() -> ! {
6767
// as per the STM32F407 datasheet. Pin assignment as per the
6868
// stm32f4-discovery (ST32F407G-DISC1) board.
6969
let gpiob = dp.GPIOB.split();
70-
let scl = gpiob.pb8.into_alternate_af4().set_open_drain();
71-
let sda = gpiob.pb9.into_alternate_af4().set_open_drain();
70+
let scl = gpiob.pb8.into_alternate().set_open_drain();
71+
let sda = gpiob.pb9.into_alternate().set_open_drain();
7272
let i2c = I2c::new(dp.I2C1, (scl, sda), 400.khz(), clocks);
7373

7474
// Set up the display

examples/sd.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ fn main() -> ! {
3535
let gpioc = device.GPIOC.split();
3636
let gpiod = device.GPIOD.split();
3737

38-
let d0 = gpioc.pc8.into_alternate_af12().internal_pull_up(true);
39-
let d1 = gpioc.pc9.into_alternate_af12().internal_pull_up(true);
40-
let d2 = gpioc.pc10.into_alternate_af12().internal_pull_up(true);
41-
let d3 = gpioc.pc11.into_alternate_af12().internal_pull_up(true);
42-
let clk = gpioc.pc12.into_alternate_af12().internal_pull_up(false);
43-
let cmd = gpiod.pd2.into_alternate_af12().internal_pull_up(true);
38+
let d0 = gpioc.pc8.into_alternate().internal_pull_up(true);
39+
let d1 = gpioc.pc9.into_alternate().internal_pull_up(true);
40+
let d2 = gpioc.pc10.into_alternate().internal_pull_up(true);
41+
let d3 = gpioc.pc11.into_alternate().internal_pull_up(true);
42+
let clk = gpioc.pc12.into_alternate().internal_pull_up(false);
43+
let cmd = gpiod.pd2.into_alternate().internal_pull_up(true);
4444
let mut sdio = Sdio::new(device.SDIO, (clk, cmd, d0, d1, d2, d3), clocks);
4545

4646
hprintln!("Waiting for card...").ok();

0 commit comments

Comments
 (0)