/* leave DFU mode and reset device to jump to user loaded code  */
static void dfu_mode_leave(usb_dev *udev)
/* leave DFU mode and reset device to jump to user loaded code  */
static void dfu_mode_leave(usb_dev *udev)
{
    usbd_dfu_handler *dfu = (usbd_dfu_handler *)udev->class_data[USBD_DFU_INTERFACE];
    dfu->manifest_state = MANIFEST_COMPLETE;
    if (dfu_config_desc.dfu_func.bmAttributes & 0x04U) {
        dfu->bState = STATE_DFU_MANIFEST_SYNC;
    } else {
        dfu->bState = STATE_DFU_MANIFEST_WAIT_RESET;
        fmc_lock();
        NVIC_SystemReset();
    }
}