drivers: usb_dc_nrfx: check the device state before disable or uninit

Check the device state before nrfx_usbd_disable and
nrfx_usbd_uninit. Otherwise it may lead to an ASSERT
inside the HAL driver.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
This commit is contained in:
Johann Fischer 2019-07-02 01:10:58 +02:00 committed by Ioannis Glaropoulos
commit cb37505976

View file

@ -1348,8 +1348,14 @@ int usb_dc_detach(void)
usbd_evt_flush();
eps_ctx_uninit();
if (nrfx_usbd_is_enabled()) {
nrfx_usbd_disable();
}
if (nrfx_usbd_is_initialized()) {
nrfx_usbd_uninit();
}
(void) hf_clock_enable(false, false);
nrf5_power_usb_power_int_enable(false);