Merge pull request #684 from adafruit/fix-uarte-not-power-down-correctly

Fix uarte not power down correctly
This commit is contained in:
Ha Thach authored and GitHub committed 2021-08-18 14:16:00 +07:00
commit f51a7fad1b
1 file changed
+8
+8
View File
@@ -156,9 +156,17 @@ void Uart::end()
nrfUart->INTENCLR = UARTE_INTENSET_ENDRX_Msk | UARTE_INTENSET_ENDTX_Msk;
nrfUart->EVENTS_RXTO = 0;
nrfUart->EVENTS_TXSTOPPED = 0;
nrfUart->TASKS_STOPRX = 0x1UL;
nrfUart->TASKS_STOPTX = 0x1UL;
// Wait for TXSTOPPED event and for RXTO event
// This is required before disabling UART to fully power down transceiver PHY.
// Otherwise transceiver will continue to consume ~900uA
while ( !(nrfUart->EVENTS_TXSTOPPED && nrfUart->EVENTS_RXTO) ) yield();
nrfUart->ENABLE = UARTE_ENABLE_ENABLE_Disabled;
nrfUart->PSEL.TXD = 0xFFFFFFFF;