Skip to content

Commit

Permalink
split Serial PINS
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Jan 9, 2022
1 parent 9876d19 commit 51f919b
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 79 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

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

## [v0.8.0] - 2021-12-29
Expand Down
8 changes: 6 additions & 2 deletions examples/serial-interrupt-idle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ use panic_halt as _;

use cortex_m_rt::entry;
use stm32f1xx_hal::{
gpio::{
gpiob::{PB6, PB7},
Alternate, Floating, Input, PushPull,
},
pac,
pac::interrupt,
pac::USART1,
prelude::*,
serial::{Config, Rx, Serial, Tx},
};

static mut RX: Option<Rx<USART1>> = None;
static mut TX: Option<Tx<USART1>> = None;
static mut RX: Option<Rx<USART1, PB7<Input<Floating>>>> = None;
static mut TX: Option<Tx<USART1, PB6<Alternate<PushPull>>>> = None;
#[entry]
fn main() -> ! {
// Get access to the device specific peripherals from the peripheral access crate
Expand Down
8 changes: 8 additions & 0 deletions examples/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,13 @@ fn main() -> ! {
assert_eq!(received, sent);
asm::bkpt();

// And later reunite it again
let mut serial = tx.reunite(rx);
let sent = b'Z';
block!(serial.write(sent)).ok();
let received = block!(serial.read()).unwrap();
assert_eq!(received, sent);
asm::bkpt();

loop {}
}
Loading

0 comments on commit 51f919b

Please sign in to comment.