Skip to content

Commit 9edc558

Browse files
committed
remove unnesessary into_alternate
1 parent dbf02ae commit 9edc558

17 files changed

+57
-70
lines changed

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: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -161,31 +161,12 @@ fn main() -> ! {
161161
// STM32F412 uses I2c1 type for i2c bus.
162162
// The pins are mentioned in documentation -um2135-discovery-kit-with-stm32f412zg-mcu-stmicroelectronics
163163
#[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-
};
164+
let mut i2c = { I2c::new(p.I2C1, (gpiob.pb6, gpiob.pb7), 400.kHz(), &clocks) };
175165

176166
// STM32F413 uses FMPI2C1 type.
177167
// The pins are mentioned in documentation -um2135-discovery-kit-with-stm32f413zh-mcu-stmicroelectronics
178168
#[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-
};
169+
let mut i2c = { FMPI2c::new(p.FMPI2C1, (gpioc.pc6, gpioc.pc7), 400.kHz()) };
189170

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

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

examples/rtic-serial-dma-rx-idle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ mod app {
6767
let gpioa = dp.GPIOA.split();
6868

6969
// Initialize UART with DMA events
70-
let rx_pin = gpioa.pa10.into_alternate();
70+
let rx_pin = gpioa.pa10;
7171
let mut rx = dp
7272
.USART1
7373
.rx(

examples/rtic-spi-slave-dma.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ mod app {
7070

7171
let sck = gpiob.pb3.into_alternate();
7272
let miso = gpiob.pb4.into_alternate();
73-
let mosi = gpiob.pb5.into_alternate();
73+
let mosi = gpiob.pb5;
7474

7575
let mode = Mode {
7676
polarity: Polarity::IdleLow,

0 commit comments

Comments
 (0)