Skip to content

Commit 798c390

Browse files
committed
gracefully end() uart, wait for TX & RX phy to power down before disable it
this save around 900uA of power consumption
1 parent 3dda52f commit 798c390

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cores/nRF5/Uart.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,15 @@ void Uart::end()
156156

157157
nrfUart->INTENCLR = UARTE_INTENSET_ENDRX_Msk | UARTE_INTENSET_ENDTX_Msk;
158158

159+
nrfUart->EVENTS_RXTO = 0;
160+
nrfUart->EVENTS_TXSTOPPED = 0;
161+
159162
nrfUart->TASKS_STOPRX = 0x1UL;
160163
nrfUart->TASKS_STOPTX = 0x1UL;
161164

165+
// Wait for TXSTOPPED event and for RXTO event
166+
while ( !(nrfUart->EVENTS_TXSTOPPED && nrfUart->EVENTS_RXTO) ) yield();
167+
162168
nrfUart->ENABLE = UARTE_ENABLE_ENABLE_Disabled;
163169

164170
nrfUart->PSEL.TXD = 0xFFFFFFFF;

0 commit comments

Comments
 (0)