Skip to content

Commit 17a13cd

Browse files
committed
Workaround to reset UARTE peripheral to be able to go into deep sleep
1 parent cbf9f06 commit 17a13cd

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

drivers/source/SerialBase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ SerialBase::~SerialBase()
272272
for (int irq = 0; irq < IrqCnt; irq++) {
273273
attach(NULL, (IrqType)irq);
274274
}
275+
serial_free(&_serial);
275276
}
276277

277278
#if DEVICE_SERIAL_FC

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/serial_api.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,21 @@ void serial_free(serial_t *obj)
10091009
if (nordic_nrf5_uart_state[instance].usage_counter == 0) {
10101010

10111011
nrf_uarte_disable(nordic_nrf5_uart_register[instance]);
1012+
1013+
/* Turn NRF_UARTE0_BASE or NRF_UARTE1_BASE power off and on to reset peripheral. */
1014+
if (instance == 0) {
1015+
*(volatile uint32_t *)0x40002FFC = 0;
1016+
*(volatile uint32_t *)0x40002FFC;
1017+
*(volatile uint32_t *)0x40002FFC = 1;
1018+
}
1019+
#if UART1_ENABLED
1020+
else {
1021+
*(volatile uint32_t *)0x40028FFC = 0;
1022+
*(volatile uint32_t *)0x40028FFC;
1023+
*(volatile uint32_t *)0x40028FFC = 1;
1024+
}
1025+
#endif
1026+
10121027
}
10131028
}
10141029
}

0 commit comments

Comments
 (0)