Skip to content

Commit f1b44d6

Browse files
bors[bot]burrbull
andauthored
Merge #604
604: generic alt enums + pwm channel builders r=therealprof a=burrbull cc `@therealprof` cc `@janschiefer` I planning to change API for passing pins in PWM constructors. Now you need to specify channel number manually. See examples: https://github.com/stm32-rs/stm32f4xx-hal/blob/alt-pwm-simple/examples/pwm-dead-time.rs https://github.com/stm32-rs/stm32f4xx-hal/blob/alt-pwm-simple/examples/pwm.rs Could you test, please? Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
2 parents af887fe + ff99276 commit f1b44d6

22 files changed

+761
-784
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111
- Split SPI master and slave implementations [#609]
1212
- Split USART and UART implementations [#608]
1313
- Add `lapce` editor settings [#601]
14-
- Use `enum`s for alternate peripheral pins [#594] [#610]
14+
- Use `enum`s for alternate peripheral pins (generic over otype) [#594] [#596] [#600] [#610]
1515
- Added missing U(S)ART DMA traits for HAL serial types [#593]
1616
- Improve SPI::new* docs [#587]
1717
- Add advanced timer dead time insertion example [#585]
@@ -65,6 +65,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6565
[#577]: https://github.com/stm32-rs/stm32f4xx-hal/pull/577
6666
[#578]: https://github.com/stm32-rs/stm32f4xx-hal/pull/578
6767
[#581]: https://github.com/stm32-rs/stm32f4xx-hal/pull/581
68+
[#594]: https://github.com/stm32-rs/stm32f4xx-hal/pull/594
69+
[#595]: https://github.com/stm32-rs/stm32f4xx-hal/pull/595
70+
[#596]: https://github.com/stm32-rs/stm32f4xx-hal/pull/596
71+
[#599]: https://github.com/stm32-rs/stm32f4xx-hal/pull/599
72+
[#601]: https://github.com/stm32-rs/stm32f4xx-hal/pull/601
73+
[#603]: https://github.com/stm32-rs/stm32f4xx-hal/pull/603
74+
[#600]: https://github.com/stm32-rs/stm32f4xx-hal/pull/600
6875

6976

7077
## [v0.14.0] - 2022-12-12

examples/i2s-audio-out.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn main() -> ! {
104104
.i2s_clk(61440.kHz())
105105
.freeze();
106106

107-
let i2s_pins = (gpioa.pa4, gpioc.pc10, NoPin, gpioc.pc12);
107+
let i2s_pins = (gpioa.pa4, gpioc.pc10, NoPin::new(), gpioc.pc12);
108108
let i2s = I2s::new(dp.SPI3, i2s_pins, &clocks);
109109
let i2s_config = I2sTransferConfig::new_master()
110110
.transmit()

examples/ist7920-bidi-normal-spi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() -> ! {
2929
led.set_low();
3030

3131
let sck = gpiob.pb3.into_alternate();
32-
let miso = NoMiso {};
32+
let miso = NoMiso::new();
3333
let mosi = gpiob.pb5.into_alternate();
3434

3535
let dc = gpiob.pb4.into_push_pull_output();

examples/pwm-dead-time.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ use panic_halt as _; // panic handler
99
use cortex_m_rt::entry;
1010
use stm32f4xx_hal as hal;
1111

12-
use crate::hal::{pac, prelude::*, timer::Channel, timer::Polarity};
12+
use hal::{
13+
pac,
14+
prelude::*,
15+
timer::Channel,
16+
timer::{Channel1, Polarity},
17+
};
1318

1419
#[entry]
1520
fn main() -> ! {
@@ -20,7 +25,7 @@ fn main() -> ! {
2025

2126
let gpioa = dp.GPIOA.split();
2227

23-
let channels = (gpioa.pa8.into_alternate(), gpioa.pa7.into_alternate());
28+
let channels = Channel1::new(gpioa.pa8).with_complementary(gpioa.pa7);
2429

2530
let mut pwm = dp.TIM1.pwm_hz(channels, 20.kHz(), &clocks);
2631

examples/pwm-input.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
use panic_halt as _;
77

88
use cortex_m_rt::entry;
9-
use stm32f4xx_hal::{pac, prelude::*, timer::Timer};
9+
use stm32f4xx_hal::{
10+
pac,
11+
prelude::*,
12+
timer::{Channel1, Channel2, Timer},
13+
};
1014

1115
#[entry]
1216
fn main() -> ! {
@@ -18,7 +22,7 @@ fn main() -> ! {
1822
let gpioa = dp.GPIOA.split();
1923
let gpioc = dp.GPIOC.split();
2024

21-
let channels = (gpioa.pa8.into_alternate(), gpioa.pa9.into_alternate());
25+
let channels = (Channel1::new(gpioa.pa8), Channel2::new(gpioa.pa9));
2226
// configure tim1 as a PWM output of known frequency.
2327
let pwm = Timer::new(dp.TIM1, &clocks).pwm_hz(channels, 501.Hz());
2428
let (mut ch1, _ch2) = pwm.split();

examples/pwm-sinus.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ use panic_halt as _;
88
use core::f32::consts::FRAC_PI_2;
99
use cortex_m_rt::entry;
1010
use micromath::F32Ext;
11-
use stm32f4xx_hal::{pac, prelude::*, timer::Channel};
11+
use stm32f4xx_hal::{
12+
pac,
13+
prelude::*,
14+
timer::{Channel, Channel1, Channel2},
15+
};
1216

1317
#[entry]
1418
fn main() -> ! {
@@ -18,7 +22,7 @@ fn main() -> ! {
1822
let clocks = rcc.cfgr.use_hse(25.MHz()).freeze();
1923

2024
let gpioa = dp.GPIOA.split();
21-
let channels = (gpioa.pa8.into_alternate(), gpioa.pa9.into_alternate());
25+
let channels = (Channel1::new(gpioa.pa8), Channel2::new(gpioa.pa9));
2226

2327
let mut pwm = dp.TIM1.pwm_us(channels, 100.micros(), &clocks);
2428
let mut counter = dp.TIM2.counter_us(&clocks);

examples/pwm.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
use panic_halt as _;
77

88
use cortex_m_rt::entry;
9-
use stm32f4xx_hal::{pac, prelude::*};
9+
use stm32f4xx_hal::{
10+
pac,
11+
prelude::*,
12+
timer::{Channel1, Channel2},
13+
};
1014

1115
#[entry]
1216
fn main() -> ! {
@@ -16,7 +20,7 @@ fn main() -> ! {
1620
let clocks = rcc.cfgr.freeze();
1721

1822
let gpioa = dp.GPIOA.split();
19-
let channels = (gpioa.pa8.into_alternate(), gpioa.pa9.into_alternate());
23+
let channels = (Channel1::new(gpioa.pa8), Channel2::new(gpioa.pa9));
2024

2125
let pwm = dp.TIM1.pwm_hz(channels, 20.kHz(), &clocks).split();
2226
let (mut ch1, _ch2) = pwm;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ mod app {
188188
i2s2_driver.set_error_interrupt(true);
189189

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

examples/rtic-tick.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ mod app {
3636
(Shared {}, Local { led }, init::Monotonics(mono))
3737
}
3838

39-
#[idle]
40-
fn idle(_: idle::Context) -> ! {
41-
loop {}
42-
}
43-
4439
#[task(local = [led])]
4540
fn tick(ctx: tick::Context) {
4641
tick::spawn_after(1.secs()).ok();

examples/spi-dma.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn main() -> ! {
5555
phase: Phase::CaptureOnFirstTransition,
5656
};
5757

58-
let spi2 = Spi::new(dp.SPI2, (pb13, NoMiso {}, pb15), mode, 3.MHz(), &clocks);
58+
let spi2 = Spi::new(dp.SPI2, (pb13, NoMiso::new(), pb15), mode, 3.MHz(), &clocks);
5959

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

0 commit comments

Comments
 (0)