Skip to content

Commit 0ffbce7

Browse files
authored
Merge pull request #34 from david-sawatzke/serial_mult
Add a tx only and a rx only serial instance
2 parents ac4c91b + c8dd9b1 commit 0ffbce7

File tree

4 files changed

+213
-82
lines changed

4 files changed

+213
-82
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

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

1516
### Changed
1617

examples/serial_echo.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ fn main() -> ! {
2626
let tx = gpioa.pa9.into_alternate_af1(cs);
2727
let rx = gpioa.pa10.into_alternate_af1(cs);
2828

29-
let serial = Serial::usart1(p.USART1, (tx, rx), 115_200.bps(), &mut rcc);
30-
31-
let (mut tx, mut rx) = serial.split();
29+
let mut serial = Serial::usart1(p.USART1, (tx, rx), 115_200.bps(), &mut rcc);
3230

3331
loop {
34-
let received = block!(rx.read()).unwrap();
35-
block!(tx.write(received)).ok();
32+
let received = block!(serial.read()).unwrap();
33+
block!(serial.write(received)).ok();
3634
}
3735
});
3836
}

examples/watchdog.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,23 @@ fn main() -> ! {
3636
let mut delay = Delay::new(cp.SYST, &rcc);
3737

3838
let tx = gpioa.pa9.into_alternate_af1(cs);
39-
let rx = gpioa.pa10.into_alternate_af1(cs);
4039

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

43-
let (mut tx, _rx) = serial.split();
44-
tx.write_str("RESET \r\n").ok();
42+
serial.write_str("RESET \r\n").ok();
4543

4644
watchdog.start(Hertz(1));
4745
delay.delay_ms(500_u16);
4846
watchdog.feed();
4947
delay.delay_ms(500_u16);
5048
watchdog.feed();
5149
delay.delay_ms(500_u16);
52-
tx.write_str("This will get printed \r\n").ok();
50+
serial.write_str("This will get printed \r\n").ok();
5351
watchdog.feed();
5452

5553
// Now a reset happens while delaying
5654
delay.delay_ms(1500_u16);
57-
tx.write_str("This won't\r\n").ok();
55+
serial.write_str("This won't\r\n").ok();
5856
});
5957
}
6058

0 commit comments

Comments
 (0)