Skip to content

Commit 9779446

Browse files
bors[bot]burrbull
andauthored
Merge #632
632: fmc pins speed high + DataPins16 & remove unnesessary into_alternate in examples r=therealprof a=burrbull Co-authored-by: Andrey Zgarbul <[email protected]>
2 parents dbf02ae + 39e08c3 commit 9779446

25 files changed

+477
-622
lines changed

CHANGELOG.md

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

1010
### Changed
1111

12+
- Set `Speed::VeryHigh` default for FMC, SDIO & OTG_HS_ULPI pins, clean into_alternate in examples [#632]
1213
- Join `Serial`, `Rx`, `Tx` for `USART` and `UART` again. Make inner traits with different implementation for USART and UART. [#636]
1314

1415
### Fixed
1516

16-
- map `$SpiSlave` into `SpiSlave` struct in `spi!` macro [#635]
17+
- map `$SpiSlave` into `SpiSlave` struct in `spi!` macro [#635]
1718

19+
[#632]: https://github.com/stm32-rs/stm32f4xx-hal/pull/632
1820
[#635]: https://github.com/stm32-rs/stm32f4xx-hal/pull/635
21+
[#636]: https://github.com/stm32-rs/stm32f4xx-hal/pull/636
1922

2023
## [v0.16.0] - 2023-05-07
2124

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ fn main() -> ! {
9090
//cs - pe4
9191
//dc - pe3
9292

93-
let sck = gpioe.pe2.into_alternate();
94-
let miso = gpioe.pe5.into_alternate();
95-
let mosi = gpioe.pe6.into_alternate();
93+
let sck = gpioe.pe2;
94+
let miso = gpioe.pe5;
95+
let mosi = gpioe.pe6;
9696

9797
let spi = Spi::new(
9898
dp.SPI4,

examples/blinky.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//! Blinks an LED
2+
3+
#![deny(unsafe_code)]
4+
#![deny(warnings)]
5+
#![no_main]
6+
#![no_std]
7+
8+
use panic_halt as _;
9+
10+
use stm32f4xx_hal as hal;
11+
12+
use crate::hal::{pac, prelude::*};
13+
use cortex_m_rt::entry;
14+
15+
#[entry]
16+
fn main() -> ! {
17+
let p = pac::Peripherals::take().unwrap();
18+
19+
let gpioc = p.GPIOC.split();
20+
let mut led = gpioc.pc13.into_push_pull_output();
21+
22+
loop {
23+
for _ in 0..10_000 {
24+
led.set_high();
25+
}
26+
for _ in 0..10_000 {
27+
led.set_low();
28+
}
29+
}
30+
}

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::<9>();
29-
let tx = gpiob.pb9.into_alternate();
28+
let rx = gpiob.pb8;
29+
let tx = gpiob.pb9;
3030

3131
// let can = Can::new(dp.CAN1, (tx, rx));
3232
// or
@@ -44,8 +44,8 @@ fn main() -> ! {
4444
filters.enable_bank(0, Fifo::Fifo0, Mask32::accept_all());
4545

4646
let _can2 = {
47-
let tx = gpiob.pb13.into_alternate();
48-
let rx = gpiob.pb12.into_alternate();
47+
let tx = gpiob.pb13;
48+
let rx = gpiob.pb12;
4949

5050
let can = dp.CAN2.can((tx, rx));
5151

examples/display-touch.rs

Lines changed: 14 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use cortex_m;
1818
use cortex_m_rt::entry;
1919
use rtt_target::{rprintln, rtt_init_print};
2020
use stm32f4xx_hal::{
21-
fsmc_lcd::{FsmcLcd, LcdPins, Timing},
21+
fsmc_lcd::{DataPins16, FsmcLcd, LcdPins, Timing},
2222
gpio::Speed,
2323
pac,
2424
prelude::*,
@@ -67,33 +67,20 @@ fn main() -> ! {
6767

6868
// Pins connected to the LCD on the board
6969
use stm32f4xx_hal::gpio::alt::fsmc as alt;
70-
let lcd_pins = LcdPins {
71-
data: (
72-
gpiod.pd14.into(),
73-
gpiod.pd15.into(),
74-
gpiod.pd0.into(),
75-
gpiod.pd1.into(),
76-
gpioe.pe7.into(),
77-
gpioe.pe8.into(),
78-
gpioe.pe9.into(),
79-
gpioe.pe10.into(),
80-
gpioe.pe11.into(),
81-
gpioe.pe12.into(),
82-
gpioe.pe13.into(),
83-
gpioe.pe14.into(),
84-
gpioe.pe15.into(),
85-
gpiod.pd8.into(),
86-
gpiod.pd9.into(),
87-
gpiod.pd10.into(),
70+
let lcd_pins = LcdPins::new(
71+
DataPins16::new(
72+
gpiod.pd14, gpiod.pd15, gpiod.pd0, gpiod.pd1, gpioe.pe7, gpioe.pe8, gpioe.pe9,
73+
gpioe.pe10, gpioe.pe11, gpioe.pe12, gpioe.pe13, gpioe.pe14, gpioe.pe15, gpiod.pd8,
74+
gpiod.pd9, gpiod.pd10,
8875
),
89-
address: alt::Address::from(gpiof.pf0),
90-
read_enable: gpiod.pd4.into(),
91-
write_enable: gpiod.pd5.into(),
76+
alt::Address::from(gpiof.pf0),
77+
gpiod.pd4,
78+
gpiod.pd5,
9279
#[cfg(feature = "stm32f413")]
93-
chip_select: alt::ChipSelect3::from(gpiog.pg10),
80+
alt::ChipSelect3::from(gpiog.pg10),
9481
#[cfg(feature = "stm32f412")]
95-
chip_select: alt::ChipSelect1::from(gpiod.pd7),
96-
};
82+
alt::ChipSelect1::from(gpiod.pd7),
83+
);
9784

9885
// Enable backlight
9986
#[cfg(feature = "stm32f413")]
@@ -161,31 +148,12 @@ fn main() -> ! {
161148
// STM32F412 uses I2c1 type for i2c bus.
162149
// The pins are mentioned in documentation -um2135-discovery-kit-with-stm32f412zg-mcu-stmicroelectronics
163150
#[cfg(feature = "stm32f412")]
164-
let mut i2c = {
165-
I2c::new(
166-
p.I2C1,
167-
(
168-
gpiob.pb6.into_alternate_open_drain(), //scl pin
169-
gpiob.pb7.into_alternate_open_drain(), //sda pin
170-
),
171-
400.kHz(),
172-
&clocks,
173-
)
174-
};
151+
let mut i2c = { I2c::new(p.I2C1, (gpiob.pb6, gpiob.pb7), 400.kHz(), &clocks) };
175152

176153
// STM32F413 uses FMPI2C1 type.
177154
// The pins are mentioned in documentation -um2135-discovery-kit-with-stm32f413zh-mcu-stmicroelectronics
178155
#[cfg(feature = "stm32f413")]
179-
let mut i2c = {
180-
FMPI2c::new(
181-
p.FMPI2C1,
182-
(
183-
gpioc.pc6.into_alternate_open_drain(), // scl pin
184-
gpioc.pc7.into_alternate_open_drain(), // sda pin
185-
),
186-
400.kHz(),
187-
)
188-
};
156+
let mut i2c = { FMPI2c::new(p.FMPI2C1, (gpioc.pc6, gpioc.pc7), 400.kHz()) };
189157

190158
#[cfg(feature = "stm32f412")]
191159
let ts_int = gpiog.pg5.into_pull_down_input();

examples/f413disco-lcd-ferris.rs

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rtt_target::{self, rtt_init_print};
1616
use stm32f4xx_hal as hal;
1717

1818
use crate::hal::{
19-
fsmc_lcd::{FsmcLcd, LcdPins, Timing},
19+
fsmc_lcd::{DataPins16, FsmcLcd, LcdPins, Timing},
2020
gpio::Speed,
2121
pac::{CorePeripherals, Peripherals},
2222
prelude::*,
@@ -710,30 +710,17 @@ fn main() -> ! {
710710

711711
// Define the pins we need for our 16bit parallel bus
712712
use stm32f4xx_hal::gpio::alt::fsmc as alt;
713-
let lcd_pins = LcdPins {
714-
data: (
715-
gpiod.pd14.into(),
716-
gpiod.pd15.into(),
717-
gpiod.pd0.into(),
718-
gpiod.pd1.into(),
719-
gpioe.pe7.into(),
720-
gpioe.pe8.into(),
721-
gpioe.pe9.into(),
722-
gpioe.pe10.into(),
723-
gpioe.pe11.into(),
724-
gpioe.pe12.into(),
725-
gpioe.pe13.into(),
726-
gpioe.pe14.into(),
727-
gpioe.pe15.into(),
728-
gpiod.pd8.into(),
729-
gpiod.pd9.into(),
730-
gpiod.pd10.into(),
713+
let lcd_pins = LcdPins::new(
714+
DataPins16::new(
715+
gpiod.pd14, gpiod.pd15, gpiod.pd0, gpiod.pd1, gpioe.pe7, gpioe.pe8, gpioe.pe9,
716+
gpioe.pe10, gpioe.pe11, gpioe.pe12, gpioe.pe13, gpioe.pe14, gpioe.pe15, gpiod.pd8,
717+
gpiod.pd9, gpiod.pd10,
731718
),
732-
address: alt::Address::from(gpiof.pf0),
733-
read_enable: gpiod.pd4.into(),
734-
write_enable: gpiod.pd5.into(),
735-
chip_select: alt::ChipSelect3::from(gpiog.pg10),
736-
};
719+
alt::Address::from(gpiof.pf0),
720+
gpiod.pd4,
721+
gpiod.pd5,
722+
alt::ChipSelect3::from(gpiog.pg10),
723+
);
737724

738725
// Setup the RESET pin
739726
let rst = gpiob.pb13.into_push_pull_output().speed(Speed::VeryHigh);

examples/ist7920-bidi-normal-spi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn main() -> ! {
3030

3131
let sck = gpiob.pb3.into_alternate();
3232
let miso = NoMiso::new();
33-
let mosi = gpiob.pb5.into_alternate();
33+
let mosi = gpiob.pb5;
3434

3535
let dc = gpiob.pb4.into_push_pull_output();
3636
let mut res = gpiob.pb10.into_push_pull_output();

examples/pwm-input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn main() -> ! {
3131
ch1.enable();
3232

3333
// Configure a pin into TIM8_CH1 mode, which will be used to observe an input PWM signal.
34-
let pwm_reader_ch1 = gpioc.pc6.into_alternate();
34+
let pwm_reader_ch1 = gpioc.pc6;
3535

3636
// configure tim8 as a PWM input, using the best-guess frequency of the input signal.
3737
let monitor = Timer::new(dp.TIM8, &clocks).pwm_input(500.Hz(), pwm_reader_ch1);

examples/qei.rs

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

3838
// Connect a rotary encoder to pins A0 and A1.
39-
let rotary_encoder_pins = (gpioa.pa0.into_alternate(), gpioa.pa1.into_alternate());
39+
let rotary_encoder_pins = (gpioa.pa0, gpioa.pa1);
4040
let rotary_encoder_timer = dp.TIM2;
4141
let rotary_encoder = Qei::new(rotary_encoder_timer, rotary_encoder_pins);
4242

examples/rng-display.rs

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

7878
// Set up the display

0 commit comments

Comments
 (0)