Skip to content

Commit 1b07deb

Browse files
committed
split Serial PINS
1 parent 9876d19 commit 1b07deb

File tree

4 files changed

+112
-86
lines changed

4 files changed

+112
-86
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Added
1111

12+
- Possibility to unite Tx and Rx parts of Serial
1213
- `Instance` for Timer's, rtic-monotonic fugit impl
1314
- Serial can now be reconfigured, allowing to change e.g. the baud rate after initialisation.
1415

1516
### Changed
1617

18+
- serial: move TX pin and USART into `Tx` structure and RX pin into `Rx` structure
1719
- replace `GetBusFreq` with `BusClock` and `BusTimerClock`
1820

1921
## [v0.8.0] - 2021-12-29

examples/serial-interrupt-idle.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@ use panic_halt as _;
99

1010
use cortex_m_rt::entry;
1111
use stm32f1xx_hal::{
12+
gpio::{
13+
gpiob::{PB6, PB7},
14+
Alternate, Floating, Input, PushPull,
15+
},
1216
pac,
1317
pac::interrupt,
1418
pac::USART1,
1519
prelude::*,
1620
serial::{Config, Rx, Serial, Tx},
1721
};
1822

19-
static mut RX: Option<Rx<USART1>> = None;
20-
static mut TX: Option<Tx<USART1>> = None;
23+
static mut RX: Option<Rx<USART1, PB7<Input<Floating>>>> = None;
24+
static mut TX: Option<Tx<USART1, PB6<Alternate<PushPull>>>> = None;
2125
#[entry]
2226
fn main() -> ! {
2327
// Get access to the device specific peripherals from the peripheral access crate

examples/serial.rs

+8
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,13 @@ fn main() -> ! {
8989
assert_eq!(received, sent);
9090
asm::bkpt();
9191

92+
// And later reunite it again
93+
let mut serial = tx.reunite(rx);
94+
let sent = b'Z';
95+
block!(serial.write(sent)).ok();
96+
let received = block!(serial.read()).unwrap();
97+
assert_eq!(received, sent);
98+
asm::bkpt();
99+
92100
loop {}
93101
}

0 commit comments

Comments
 (0)