/* Function to check and wait while the USB DFU is in progress.  */
void wait_for_usb_dfu(k_timeout_t delay)
/* Function to check and wait while the USB DFU is in progress.  */
void wait_for_usb_dfu(k_timeout_t delay)
{
	k_timepoint_t end = sys_timepoint_calc(delay);
	while (!sys_timepoint_expired(end)) {
		if (is_dfu_started()) {
			k_poll_event_init(&dfu_event, K_POLL_TYPE_SIGNAL,
				K_POLL_MODE_NOTIFY_ONLY, &dfu_signal);
			if (k_poll(&dfu_event, 1, K_FOREVER) != 0) {
				LOG_DBG("USB DFU Error");
			}
			LOG_INF("USB DFU Completed");
			break;
		}
		k_msleep(INTERMITTENT_CHECK_DELAY);
	}
}