Skip to content

Commit bdd35ed

Browse files
author
Jonathan Pallant (42 Technology)
committed
Disable UART if we find it already enabled.
1 parent 6e034b6 commit bdd35ed

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

nrf-hal-common/src/uarte.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ where
4343
T: Instance,
4444
{
4545
pub fn new(uarte: T, mut pins: Pins, parity: Parity, baudrate: Baudrate) -> Self {
46+
// Is the UART already on? It might be if you had a bootloader
47+
if uarte.enable.read().bits() != 0 {
48+
while uarte.events_txstopped.read().bits() == 0 {
49+
// Spin
50+
}
51+
52+
// Disable UARTE instance
53+
uarte.enable.write(|w| w.enable().disabled());
54+
}
55+
4656
// Select pins
4757
uarte.psel.rxd.write(|w| {
4858
unsafe { w.bits(pins.rxd.psel_bits()) };

0 commit comments

Comments
 (0)