Skip to content

Commit cafed6d

Browse files
committed
PushPull/Floating by default
1 parent 8440c24 commit cafed6d

File tree

6 files changed

+43
-45
lines changed

6 files changed

+43
-45
lines changed

examples/can-echo.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use panic_halt as _;
1010
use bxcan::filter::Mask32;
1111
use cortex_m_rt::entry;
1212
use nb::block;
13-
use stm32f1xx_hal::{gpio::Floating, pac, prelude::*};
13+
use stm32f1xx_hal::{pac, prelude::*};
1414

1515
#[entry]
1616
fn main() -> ! {
@@ -31,7 +31,7 @@ fn main() -> ! {
3131
let rx = gpioa.pa11;
3232
let tx = gpioa.pa12;
3333

34-
let can = dp.CAN1.can::<Floating>(
34+
let can = dp.CAN1.can(
3535
#[cfg(not(feature = "connectivity"))]
3636
dp.USB,
3737
(tx, rx, &mut afio.mapr),
@@ -51,9 +51,7 @@ fn main() -> ! {
5151
#[cfg(feature = "connectivity")]
5252
let _can2 = {
5353
let gpiob = dp.GPIOB.split();
54-
let can = dp
55-
.CAN2
56-
.can::<Floating>((gpiob.pb6, gpiob.pb5, &mut afio.mapr));
54+
let can = dp.CAN2.can((gpiob.pb6, gpiob.pb5, &mut afio.mapr));
5755

5856
// APB1 (PCLK1): 8MHz, Bit rate: 125kBit/s, Sample Point 87.5%
5957
// Value was calculated with http://www.bittiming.can-wiki.info/

examples/serial_9bits.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ use cortex_m_rt::entry;
1313
use nb::block;
1414
use panic_halt as _;
1515
use stm32f1xx_hal::{
16-
gpio::{Floating, PushPull},
1716
pac,
1817
prelude::*,
19-
serial::{self, Config, Error, Serial},
18+
serial::{self, Config, Error},
2019
};
2120

2221
// The address of the slave device.
@@ -119,8 +118,10 @@ fn main() -> ! {
119118

120119
// Set up the usart device. Take ownership over the USART register and tx/rx pins. The rest of
121120
// the registers are used to enable and configure the device.
122-
let serial = Serial::<_, PushPull, Floating>::new(
123-
p.USART3,
121+
//
122+
//let serial = Serial::<_, PushPull, Floating>::new(p.USART3,
123+
// or shorter
124+
let serial = p.USART3.serial(
124125
(tx_pin, rx_pin, &mut afio.mapr),
125126
Config::default()
126127
.baudrate(9600.bps())

examples/spi-slave.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub const MODE: Mode = Mode {
2020
};
2121

2222
use stm32f1xx_hal::{
23-
gpio::Floating,
2423
pac::{self, interrupt, Peripherals, SPI2},
2524
prelude::*,
2625
spi::{Event, SpiSlave},
@@ -49,7 +48,7 @@ fn main() -> ! {
4948

5049
let spi1 = dp
5150
.SPI1
52-
.spi::<Floating>((sck, miso, mosi, &mut afio.mapr), MODE, 10.kHz(), &clocks);
51+
.spi((sck, miso, mosi, &mut afio.mapr), MODE, 10.kHz(), &clocks);
5352

5453
// SPI2
5554
// Convert pins before SPI initialization

src/can.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,34 +122,34 @@ macro_rules! remap {
122122
use remap;
123123

124124
pub trait CanExt: Sized + Instance {
125-
fn can<PULL>(
125+
fn can(
126126
self,
127127
#[cfg(not(feature = "connectivity"))] usb: pac::USB,
128-
pins: impl Into<Self::Pins<PULL>>,
129-
) -> Can<Self, PULL>;
130-
fn can_loopback<PULL>(
128+
pins: impl Into<Self::Pins<Floating>>,
129+
) -> Can<Self, Floating>;
130+
fn can_loopback(
131131
self,
132132
#[cfg(not(feature = "connectivity"))] usb: pac::USB,
133-
) -> Can<Self, PULL>;
133+
) -> Can<Self, Floating>;
134134
}
135135

136136
impl<CAN: Instance> CanExt for CAN {
137-
fn can<PULL>(
137+
fn can(
138138
self,
139139
#[cfg(not(feature = "connectivity"))] usb: pac::USB,
140-
pins: impl Into<Self::Pins<PULL>>,
141-
) -> Can<Self, PULL> {
140+
pins: impl Into<Self::Pins<Floating>>,
141+
) -> Can<Self, Floating> {
142142
Can::new(
143143
self,
144144
#[cfg(not(feature = "connectivity"))]
145145
usb,
146146
pins,
147147
)
148148
}
149-
fn can_loopback<PULL>(
149+
fn can_loopback(
150150
self,
151151
#[cfg(not(feature = "connectivity"))] usb: pac::USB,
152-
) -> Can<Self, PULL> {
152+
) -> Can<Self, Floating> {
153153
Can::new_loopback(
154154
self,
155155
#[cfg(not(feature = "connectivity"))]

src/serial.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,21 +179,21 @@ macro_rules! remap {
179179
use remap;
180180

181181
pub trait SerialExt: Sized + Instance {
182-
fn serial<Otype, PULL>(
182+
fn serial(
183183
self,
184-
pins: impl Into<Self::Pins<Otype, PULL>>,
184+
pins: impl Into<Self::Pins<PushPull, Floating>>,
185185
config: impl Into<Config>,
186186
clocks: &Clocks,
187-
) -> Serial<Self, Otype, PULL>;
187+
) -> Serial<Self, PushPull, Floating>;
188188
}
189189

190190
impl<USART: Instance> SerialExt for USART {
191-
fn serial<Otype, PULL>(
191+
fn serial(
192192
self,
193-
pins: impl Into<Self::Pins<Otype, PULL>>,
193+
pins: impl Into<Self::Pins<PushPull, Floating>>,
194194
config: impl Into<Config>,
195195
clocks: &Clocks,
196-
) -> Serial<Self, Otype, PULL> {
196+
) -> Serial<Self> {
197197
Serial::new(self, pins, config, clocks)
198198
}
199199
}

src/spi.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -292,51 +292,51 @@ macro_rules! remap {
292292
use remap;
293293

294294
pub trait SpiExt: Sized + Instance {
295-
fn spi<PULL>(
295+
fn spi(
296296
self,
297-
pins: impl Into<Self::MasterPins<PULL>>,
297+
pins: impl Into<Self::MasterPins<Floating>>,
298298
mode: Mode,
299299
freq: Hertz,
300300
clocks: &Clocks,
301-
) -> Spi<Self, u8, PULL>;
302-
fn spi_u16<PULL>(
301+
) -> Spi<Self, u8, Floating>;
302+
fn spi_u16(
303303
self,
304-
pins: impl Into<Self::MasterPins<PULL>>,
304+
pins: impl Into<Self::MasterPins<Floating>>,
305305
mode: Mode,
306306
freq: Hertz,
307307
clocks: &Clocks,
308-
) -> Spi<Self, u16, PULL> {
308+
) -> Spi<Self, u16> {
309309
Self::spi(self, pins, mode, freq, clocks).frame_size_16bit()
310310
}
311-
fn spi_slave<Otype, PULL>(
311+
fn spi_slave(
312312
self,
313-
pins: impl Into<Self::SlavePins<Otype, PULL>>,
313+
pins: impl Into<Self::SlavePins<PushPull, Floating>>,
314314
mode: Mode,
315-
) -> SpiSlave<Self, u8, Otype, PULL>;
316-
fn spi_slave_u16<Otype, PULL>(
315+
) -> SpiSlave<Self, u8, PushPull, Floating>;
316+
fn spi_slave_u16(
317317
self,
318-
pins: impl Into<Self::SlavePins<Otype, PULL>>,
318+
pins: impl Into<Self::SlavePins<PushPull, Floating>>,
319319
mode: Mode,
320-
) -> SpiSlave<Self, u16, Otype, PULL> {
320+
) -> SpiSlave<Self, u16, PushPull, Floating> {
321321
Self::spi_slave(self, pins, mode).frame_size_16bit()
322322
}
323323
}
324324

325325
impl<SPI: Instance> SpiExt for SPI {
326-
fn spi<PULL>(
326+
fn spi(
327327
self,
328-
pins: impl Into<Self::MasterPins<PULL>>,
328+
pins: impl Into<Self::MasterPins<Floating>>,
329329
mode: Mode,
330330
freq: Hertz,
331331
clocks: &Clocks,
332-
) -> Spi<Self, u8, PULL> {
332+
) -> Spi<Self, u8, Floating> {
333333
Spi::new(self, pins, mode, freq, clocks)
334334
}
335-
fn spi_slave<Otype, PULL>(
335+
fn spi_slave(
336336
self,
337-
pins: impl Into<Self::SlavePins<Otype, PULL>>,
337+
pins: impl Into<Self::SlavePins<PushPull, Floating>>,
338338
mode: Mode,
339-
) -> SpiSlave<Self, u8, Otype, PULL> {
339+
) -> SpiSlave<Self, u8, PushPull, Floating> {
340340
SpiSlave::new(self, pins, mode)
341341
}
342342
}

0 commit comments

Comments
 (0)