Skip to content

Commit 0584201

Browse files
authored
Merge pull request #813 from stm32-rs/none
remove NoPin, use Option
2 parents adfe814 + a811bf4 commit 0584201

19 files changed

+306
-287
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1616
- `serial` mod refactor [#833] [#839]
1717
- FMPI2c APB timings [#770]
1818
- Fefactor FMPI2c `embedded-hal` implementations [#784]
19+
- remove `NoPin`, use `Option` instead [#813]
1920

2021
[#770]: https://github.com/stm32-rs/stm32f4xx-hal/pull/770
2122
[#784]: https://github.com/stm32-rs/stm32f4xx-hal/pull/784
23+
[#813]: https://github.com/stm32-rs/stm32f4xx-hal/pull/813
2224
[#829]: https://github.com/stm32-rs/stm32f4xx-hal/pull/829
2325
[#831]: https://github.com/stm32-rs/stm32f4xx-hal/pull/831
2426
[#832]: https://github.com/stm32-rs/stm32f4xx-hal/pull/832

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

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

112112
let spi = Spi::new(
113113
dp.SPI4,
114-
(sck, miso, mosi),
114+
(Some(sck), Some(miso), Some(mosi)),
115115
Mode {
116116
polarity: Polarity::IdleLow,
117117
phase: Phase::CaptureOnFirstTransition,

examples/i2s-audio-out.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ use cortex_m_rt::entry;
5050

5151
use rtt_target::{rprintln, rtt_init_print};
5252

53-
use stm32f4xx_hal::gpio::NoPin;
5453
use stm32f4xx_hal::i2s::stm32_i2s_v12x::transfer::*;
5554
use stm32f4xx_hal::i2s::I2s;
5655
use stm32f4xx_hal::nb::block;
57-
use stm32f4xx_hal::pac::Peripherals;
56+
use stm32f4xx_hal::pac::{Peripherals, SPI3};
5857
use stm32f4xx_hal::prelude::*;
5958

6059
const SAMPLE_RATE: u32 = 48_000;
@@ -104,7 +103,7 @@ fn main() -> ! {
104103
.i2s_clk(61440.kHz())
105104
.freeze();
106105

107-
let i2s_pins = (gpioa.pa4, gpioc.pc10, NoPin::new(), gpioc.pc12);
106+
let i2s_pins = (gpioa.pa4, gpioc.pc10, SPI3::NoMck, gpioc.pc12);
108107
let i2s = I2s::new(dp.SPI3, i2s_pins, &clocks);
109108
let i2s_config = I2sTransferConfig::new_master()
110109
.transmit()

examples/ist7920-bidi-normal-spi.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ fn main() -> ! {
4545
// Change spi transfer mode to Bidi for more efficient operations.
4646
// let spi = Spi::new(dp.SPI1, (sck, miso, mosi), mode, 8.MHz(), &clocks).to_bidi_transfer_mode();
4747
// or
48-
let spi = dp.SPI1.spi_bidi((sck, mosi), mode, 8.MHz(), &clocks);
48+
let spi = dp
49+
.SPI1
50+
.spi_bidi((Some(sck), Some(mosi)), mode, 8.MHz(), &clocks);
4951

5052
let iface = SPIInterface::new(spi, dc, cs);
5153

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ mod app {
165165

166166
// I2S pins: (WS, CK, MCLK, SD) for I2S2
167167
let i2s2_pins = (
168-
gpiob.pb12, //WS
169-
gpiob.pb13, //CK
170-
gpioc.pc6, //MCK
171-
gpiob.pb15, //SD
172-
gpiob.pb14, //ExtSD
168+
gpiob.pb12, //WS
169+
gpiob.pb13, //CK
170+
Some(gpioc.pc6), //MCK
171+
gpiob.pb15, //SD
172+
gpiob.pb14, //ExtSD
173173
);
174174
let i2s2 = DualI2s::new(device.SPI2, device.I2S2EXT, i2s2_pins, &clocks);
175175
let i2s2_config = DualI2sDriverConfig::new_master()

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ mod app {
8080

8181
use super::hal;
8282

83-
use hal::gpio::{Edge, NoPin};
83+
use hal::gpio::Edge;
8484
use hal::i2s::stm32_i2s_v12x::driver::*;
8585
use hal::i2s::I2s;
8686
use hal::pac::Interrupt;
@@ -169,10 +169,10 @@ mod app {
169169

170170
// I2S pins: (WS, CK, MCLK, SD) for I2S2
171171
let i2s2_pins = (
172-
gpiob.pb12, //WS
173-
gpiob.pb13, //CK
174-
gpioc.pc6, //MCK
175-
gpiob.pb15, //SD
172+
gpiob.pb12, //WS
173+
gpiob.pb13, //CK
174+
Some(gpioc.pc6), //MCK
175+
gpiob.pb15, //SD
176176
);
177177
let i2s2 = I2s::new(device.SPI2, i2s2_pins, &clocks);
178178
let i2s2_config = I2sDriverConfig::new_master()
@@ -186,8 +186,8 @@ mod app {
186186
i2s2_driver.set_rx_interrupt(true);
187187
i2s2_driver.set_error_interrupt(true);
188188

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

examples/rtic-spi-slave-dma.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ mod app {
7777
phase: Phase::CaptureOnFirstTransition,
7878
};
7979

80-
let mut spi3 = SpiSlave::new(spi, (sck, miso, mosi, None), mode);
80+
let mut spi3 = SpiSlave::new(spi, (Some(sck), Some(miso), Some(mosi), SPI3::NoNss), mode);
8181
spi3.set_internal_nss(false);
8282

8383
let (tx, rx) = spi3.use_dma().txrx();

examples/sai-duplex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn main() -> ! {
4343
num_slots: 2,
4444
};
4545
let tx = saia.master_tx(
46-
(gpioe.pe2, gpioe.pe4, gpioe.pe5, gpioe.pe6),
46+
(Some(gpioe.pe2), gpioe.pe4, gpioe.pe5, gpioe.pe6),
4747
protocol,
4848
48.kHz(),
4949
&clocks,

examples/spi-dma.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,15 @@ use stm32f4xx_hal::pac::interrupt;
1313
use stm32f4xx_hal::{
1414
dma::{config, MemoryToPeripheral, Stream4, StreamsTuple, Transfer},
1515
gpio::Speed,
16-
pac,
16+
pac::{self, SPI2},
1717
prelude::*,
1818
spi::*,
1919
};
2020

2121
const ARRAY_SIZE: usize = 100;
2222

23-
type SpiDma = Transfer<
24-
Stream4<pac::DMA1>,
25-
0,
26-
Tx<pac::SPI2>,
27-
MemoryToPeripheral,
28-
&'static mut [u8; ARRAY_SIZE],
29-
>;
23+
type SpiDma =
24+
Transfer<Stream4<pac::DMA1>, 0, Tx<SPI2>, MemoryToPeripheral, &'static mut [u8; ARRAY_SIZE]>;
3025

3126
static G_TRANSFER: Mutex<RefCell<Option<SpiDma>>> = Mutex::new(RefCell::new(None));
3227

@@ -56,7 +51,13 @@ fn main() -> ! {
5651
phase: Phase::CaptureOnFirstTransition,
5752
};
5853

59-
let spi2 = Spi::new(dp.SPI2, (pb13, NoMiso::new(), pb15), mode, 3.MHz(), &clocks);
54+
let spi2 = Spi::new(
55+
dp.SPI2,
56+
(Some(pb13), SPI2::NoMiso, Some(pb15)),
57+
mode,
58+
3.MHz(),
59+
&clocks,
60+
);
6061

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

examples/spi_slave.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ fn main() -> ! {
2929
let mosi = gpioa.pa7.internal_resistor(Pull::Down);
3030

3131
// clock speed is determined by the master
32-
let nss = gpioa.pa4.internal_resistor(Pull::Up).into();
33-
let mut spi = p.SPI1.spi_slave((sck, miso, mosi, Some(nss)), MODE);
32+
let nss = gpioa.pa4.internal_resistor(Pull::Up);
33+
let mut spi = p
34+
.SPI1
35+
.spi_slave((Some(sck), Some(miso), Some(mosi), Some(nss)), MODE);
3436
// alternativelly you could use software `chip select`
3537
// let mut spi = SpiSlave::new(p.SPI1, (sck, miso, mosi, None), MODE);
3638
// spi.set_internal_nss(false);

0 commit comments

Comments
 (0)