/******************************************************************************* * Function Name : OTGD_FS_CoreInit * Description : Initialize the USB_OTG controller registers and prepares the core for device mode or host mode operation. * Input : None * Output : None * Return : Status *******************************************************************************/ USB_OTG_Status OTGD_FS_CoreInit(void) { USB_OTG_Status status = USB_OTG_OK; USB_OTG_usb_cfg_data usbcfg; usbcfg.d32 = 0; /* Reset the Controller */ OTGD_FS_CoreReset(); usbcfg.d32 = READ_REG32(&core_regs.common_regs->usb_cfg); usbcfg.b.physel = 1; WRITE_REG32 (&core_regs.common_regs->usb_cfg, usbcfg.d32); /* init and configure the phy */ OTGD_FS_PhyInit(); /* Reset after a PHY select and set Host mode */ OTGD_FS_CoreReset(); /* Set Host or Device Mode */ SetID(); return status; }
/******************************************************************************* * Function Name : OTGD_FS_CoreInit * Description : Initialize the USB_OTG controller registers and prepares the core for device mode or host mode operation. * Input : None * Output : None * Return : Status *******************************************************************************/ USB_OTG_Status OTGD_FS_CoreInit(void) { USB_OTG_Status status = USB_OTG_OK; USB_OTG_GUSBCFG_TypeDef usbcfg; USB_OTG_GCCFG_TypeDef gccfg; usbcfg.d32 = 0; gccfg.d32 = 0; usbcfg.d32 = USB_OTG_READ_REG32(&USB_OTG_FS_regs.GREGS->GUSBCFG); usbcfg.b.physel = 1; USB_OTG_WRITE_REG32 (&USB_OTG_FS_regs.GREGS->GUSBCFG, usbcfg.d32); /* init and configure the phy */ gccfg.d32 = 0; gccfg.b.vbussensingB = 1; gccfg.b.pwdn = 1; USB_OTG_WRITE_REG32 (&USB_OTG_FS_regs.GREGS->GCCFG, gccfg.d32); mDELAY(50); /* Reset after a PHY select and set Host mode */ OTGD_FS_CoreReset(); /* Set Device Mode */ OTGD_FS_SetDeviceMode(); return status; }