lpcware

HAL_USBDeInit

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by brunoalmeida on Mon Jul 28 17:00:04 MST 2014
I found this code on LPCUSBLib/Drivers/USB/Core/HAL/LPC18XX/HAL_LPC18xx.c

void HAL_USBDeInit(uint8_t corenum, uint8_t mode)
{
HAL_DisableUSBInterrupt(corenum);
if (mode == USB_MODE_Device) {
#if defined(USB_CAN_BE_HOST)
USB_REG(corenum)->USBSTS_H = 0xFFFFFFFF;/* clear all current interrupts */
USB_REG(corenum)->PORTSC1_H &= ~(1 << 12);/* clear port power */
USB_REG(corenum)->USBMODE_H =   (1 << 0);/* set USB mode reserve */
#endif
}
else if (mode == USB_MODE_Host) {
#if defined(USB_CAN_BE_DEVICE)
/* Clear all pending interrupts */
USB_REG(corenum)->USBSTS_D   = 0xFFFFFFFF;
USB_REG(corenum)->ENDPTNAK   = 0xFFFFFFFF;
USB_REG(corenum)->ENDPTNAKEN = 0;
USB_REG(corenum)->ENDPTSETUPSTAT = USB_REG(corenum)->ENDPTSETUPSTAT;
USB_REG(corenum)->ENDPTCOMPLETE  = USB_REG(corenum)->ENDPTCOMPLETE;
while (USB_REG(corenum)->ENDPTPRIME) ;/* Wait until all bits are 0 */
USB_REG(corenum)->ENDPTFLUSH = 0xFFFFFFFF;
while (USB_REG(corenum)->ENDPTFLUSH) ;/* Wait until all bits are 0 */
#endif
}

  (...)
}

Is this right ? To de-initialize a host i will modify device configuration and to deinit a device i will modify a host configuration ?

Outcomes