Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion boot/zephyr/nrf_cleanup.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
* Copyright (c) 2020-2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <zephyr/kernel.h>

#if defined(CONFIG_NRFX_CLOCK)
#include <hal/nrf_clock.h>
#endif
Expand Down Expand Up @@ -105,6 +107,21 @@ void nrf_cleanup_peripheral(void)
for (int i = 0; i < sizeof(nrf_uarte_to_clean) / sizeof(nrf_uarte_to_clean[0]); ++i) {
NRF_UARTE_Type *current = nrf_uarte_to_clean[i];

/* Ensured that RX is stopped */
if (nrfy_uarte_event_check(current, NRF_UARTE_EVENT_RXSTARTED)) {
nrfy_uarte_task_trigger(current, NRF_UARTE_TASK_STOPRX);
/* Wait up to 100ms for task to stop */
for (int i = 0; i < 1000; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heard yesterday there is an deinit driver function in zephyr from @bjarki-andreasen not sure if it does the same as this or different but might be worth a look at

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes there is such deinit - API. I expected it will replace this implementation, but not today,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API is indeed implemented zephyrproject-rtos/zephyr#93273 can't we just use it?

if (nrfy_uarte_event_check(current, NRF_UARTE_EVENT_RXTO) ||
nrfy_uarte_event_check(current, NRF_UARTE_EVENT_ERROR)) {
/* RX terminated, break*/
break;
}
/* Wait before next check */
k_busy_wait(100);
}
}

nrfy_uarte_int_disable(current, 0xFFFFFFFF);
nrfy_uarte_int_uninit(current);
nrfy_uarte_task_trigger(current, NRF_UARTE_TASK_STOPRX);
Expand Down