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

Add a tx only and a rx only serial instance #34

Merged
merged 5 commits into from
Jan 11, 2019
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Support for stm32f0x1 line - @jessebraham
- Support for HSE as a system clocksource (#25 - breaking change) - @zklapow
- Add ability to use a Tx/Rx only serial instance - @david-sawatzke

### Changed

Expand Down
8 changes: 3 additions & 5 deletions examples/serial_echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ fn main() -> ! {
let tx = gpioa.pa9.into_alternate_af1(cs);
let rx = gpioa.pa10.into_alternate_af1(cs);

let serial = Serial::usart1(p.USART1, (tx, rx), 115_200.bps(), &mut rcc);

let (mut tx, mut rx) = serial.split();
let mut serial = Serial::usart1(p.USART1, (tx, rx), 115_200.bps(), &mut rcc);

loop {
let received = block!(rx.read()).unwrap();
block!(tx.write(received)).ok();
let received = block!(serial.read()).unwrap();
block!(serial.write(received)).ok();
}
});
}
Expand Down
10 changes: 4 additions & 6 deletions examples/watchdog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,23 @@ fn main() -> ! {
let mut delay = Delay::new(cp.SYST, &rcc);

let tx = gpioa.pa9.into_alternate_af1(cs);
let rx = gpioa.pa10.into_alternate_af1(cs);

let serial = Serial::usart1(p.USART1, (tx, rx), 115_200.bps(), &mut rcc);
let mut serial = Serial::usart1tx(p.USART1, tx, 115_200.bps(), &mut rcc);

let (mut tx, _rx) = serial.split();
tx.write_str("RESET \r\n").ok();
serial.write_str("RESET \r\n").ok();

watchdog.start(Hertz(1));
delay.delay_ms(500_u16);
watchdog.feed();
delay.delay_ms(500_u16);
watchdog.feed();
delay.delay_ms(500_u16);
tx.write_str("This will get printed \r\n").ok();
serial.write_str("This will get printed \r\n").ok();
watchdog.feed();

// Now a reset happens while delaying
delay.delay_ms(1500_u16);
tx.write_str("This won't\r\n").ok();
serial.write_str("This won't\r\n").ok();
});
}

Expand Down
Loading