Skip to content

Commit 283e2fb

Browse files
committed
infallible
1 parent 9c9c6e1 commit 283e2fb

File tree

7 files changed

+20
-18
lines changed

7 files changed

+20
-18
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2020

2121
- DMA traits now require AsSlice instead of AsRef
2222

23+
- `void::Void` replaced with `Infallible` where it is possible
24+
2325
## [v0.4.0] - 2019-08-09
2426

2527
### Added

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ be specified as part of the `Cargo.toml` definition.
4949

5050
```toml
5151
[dependencies.stm32f1xx-hal]
52-
version = "0.3.0"
52+
version = "0.4.0"
5353
features = ["stm32f100", "rt"]
5454
```
5555

@@ -99,14 +99,15 @@ fn main() -> ! {
9999
// in order to configure the port. For pins 0-7, crl should be passed instead.
100100
let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
101101
// Configure the syst timer to trigger an update every second
102-
let mut timer = Timer::syst(cp.SYST, 1.hz(), clocks);
102+
let mut timer = Timer::syst(cp.SYST, clocks)
103+
.start_count_down(1.hz());
103104

104105
// Wait for the timer to trigger an update and change the state of the LED
105106
loop {
106107
block!(timer.wait()).unwrap();
107-
led.set_high();
108+
led.set_high().unwrap();
108109
block!(timer.wait()).unwrap();
109-
led.set_low();
110+
led.set_low().unwrap();
110111
}
111112
}
112113
```

examples/pwm_input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn main() -> ! {
3232
let (_pa15, _pb3, pb4) = afio.mapr.disable_jtag(gpioa.pa15, gpiob.pb3, gpiob.pb4);
3333
let pb5 = gpiob.pb5;
3434

35-
let mut pwm_input = Timer::tim3(p.TIM3, &clocks, &mut rcc.apb1)
35+
let pwm_input = Timer::tim3(p.TIM3, &clocks, &mut rcc.apb1)
3636
.pwm_input(
3737
(pb4, pb5),
3838
&mut afio.mapr,

examples/serial_config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use stm32f1xx_hal::{
1414
prelude::*,
1515
pac,
1616
serial::{self, Serial},
17-
timer::Timer,
1817
};
1918
use cortex_m_rt::entry;
2019

src/gpio.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ macro_rules! gpio {
7777
]) => {
7878
/// GPIO
7979
pub mod $gpiox {
80-
use void::Void;
80+
use core::convert::Infallible;
8181
use core::marker::PhantomData;
8282

8383
use crate::hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin, toggleable};
@@ -157,7 +157,7 @@ macro_rules! gpio {
157157
}
158158

159159
impl<MODE> OutputPin for $PXx<Output<MODE>> {
160-
type Error = Void;
160+
type Error = Infallible;
161161
fn set_high(&mut self) -> Result<(), Self::Error> {
162162
// NOTE(unsafe) atomic write to a stateless register
163163
Ok(unsafe { (*$GPIOX::ptr()).bsrr.write(|w| w.bits(1 << self.i)) })
@@ -170,7 +170,7 @@ macro_rules! gpio {
170170
}
171171

172172
impl<MODE> InputPin for $PXx<Input<MODE>> {
173-
type Error = Void;
173+
type Error = Infallible;
174174
fn is_high(&self) -> Result<bool, Self::Error> {
175175
self.is_low().map(|b| !b)
176176
}
@@ -195,7 +195,7 @@ macro_rules! gpio {
195195
impl <MODE> toggleable::Default for $PXx<Output<MODE>> {}
196196

197197
impl InputPin for $PXx<Output<OpenDrain>> {
198-
type Error = Void;
198+
type Error = Infallible;
199199
fn is_high(&self) -> Result<bool, Self::Error> {
200200
self.is_low().map(|b| !b)
201201
}
@@ -454,7 +454,7 @@ macro_rules! gpio {
454454
}
455455

456456
impl<MODE> OutputPin for $PXi<Output<MODE>> {
457-
type Error = Void;
457+
type Error = Infallible;
458458
fn set_high(&mut self) -> Result<(), Self::Error> {
459459
// NOTE(unsafe) atomic write to a stateless register
460460
Ok(unsafe { (*$GPIOX::ptr()).bsrr.write(|w| w.bits(1 << $i)) })
@@ -480,7 +480,7 @@ macro_rules! gpio {
480480
impl<MODE> toggleable::Default for $PXi<Output<MODE>> {}
481481

482482
impl<MODE> InputPin for $PXi<Input<MODE>> {
483-
type Error = Void;
483+
type Error = Infallible;
484484
fn is_high(&self) -> Result<bool, Self::Error> {
485485
self.is_low().map(|b| !b)
486486
}
@@ -492,7 +492,7 @@ macro_rules! gpio {
492492
}
493493

494494
impl InputPin for $PXi<Output<OpenDrain>> {
495-
type Error = Void;
495+
type Error = Infallible;
496496
fn is_high(&self) -> Result<bool, Self::Error> {
497497
self.is_low().map(|b| !b)
498498
}

src/rtc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::pac::{RTC, RCC};
1717
use crate::backup_domain::BackupDomain;
1818

1919
use nb;
20-
use void::Void;
20+
use core::convert::Infallible;
2121

2222
// The LSE runs at at 32 768 hertz unless an external clock is provided
2323
const LSE_HERTZ: u32 = 32_768;
@@ -154,11 +154,11 @@ impl Rtc {
154154
use nb::block;
155155
156156
rtc.set_alarm(rtc.read_counts() + 5);
157-
// NOTE: Safe unwrap because Void can't be returned
157+
// NOTE: Safe unwrap because Infallible can't be returned
158158
block!(rtc.wait_alarm()).unwrap();
159159
```
160160
*/
161-
pub fn wait_alarm(&mut self) -> nb::Result<(), Void> {
161+
pub fn wait_alarm(&mut self) -> nb::Result<(), Infallible> {
162162
if self.regs.crl.read().alrf().bit() == true {
163163
self.regs.crl.modify(|_, w| w.alrf().clear_bit());
164164
Ok(())

src/serial.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use core::sync::atomic::{self, Ordering};
4242

4343
use nb;
4444
use crate::pac::{USART1, USART2, USART3};
45-
use void::Void;
45+
use core::convert::Infallible;
4646

4747
use crate::afio::MAPR;
4848
use crate::dma::{dma1, CircBuffer, Static, Transfer, R, W, RxDma, TxDma};
@@ -388,7 +388,7 @@ macro_rules! hal {
388388
}
389389

390390
impl crate::hal::serial::Write<u8> for Tx<$USARTX> {
391-
type Error = Void;
391+
type Error = Infallible;
392392

393393
fn flush(&mut self) -> nb::Result<(), Self::Error> {
394394
// NOTE(unsafe) atomic read with no side effects

0 commit comments

Comments
 (0)