1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

usbus_dfu: Use ztimer for reboot timeout

This commit is contained in:
Koen Zandberg 2021-10-25 22:25:10 +02:00
parent 5c01e14b7a
commit 5dfc4725c8
No known key found for this signature in database
GPG Key ID: 0895A893E6D2985B

View File

@ -26,7 +26,7 @@
#include "riotboot/magic.h"
#include "riotboot/usb_dfu.h"
#ifdef MODULE_RIOTBOOT_USB_DFU
#include "xtimer.h"
#include "ztimer.h"
#endif
#include "periph/pm.h"
@ -48,7 +48,7 @@ static void _init(usbus_t *usbus, usbus_handler_t *handler);
#ifdef MODULE_RIOTBOOT_USB_DFU
static void _reboot(void *arg);
static xtimer_t scheduled_reboot = { .callback=_reboot };
static ztimer_t scheduled_reboot = { .callback=_reboot };
#define REBOOT_DELAY 2
#endif
@ -151,9 +151,6 @@ static void _init(usbus_t *usbus, usbus_handler_t *handler)
/* attached alternate settings to their interface */
usbus_add_interface_alt(&dfu->iface, &dfu->iface_alt_slot1);
/* Start xtimer for scheduled reboot after firmware upgrade */
xtimer_init();
#endif
/* Add interface to the stack */
usbus_add_interface(usbus, &dfu->iface);
@ -217,7 +214,7 @@ static void _dfu_class_control_req(usbus_t *usbus, usbus_dfu_device_t *dfu, usb_
/* Scheduled reboot, so we can answer back dfu-util before rebooting */
dfu->dfu_state = USB_DFU_STATE_DFU_DL_IDLE;
#ifdef MODULE_RIOTBOOT_USB_DFU
xtimer_set(&scheduled_reboot, 1 * US_PER_SEC);
ztimer_set(ZTIMER_SEC, &scheduled_reboot, 1);
#endif
}
memset(&buf, 0, sizeof(buf));