Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split Serial PINS #392

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added

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

### 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