// Start PLL and enable clock void UsbStartPLL(void) { UsbSetPLL_XTAL_Frequency(); UsbEnablePLL(); UsbWaitPLL_Locked(); UsbEnableClock(); }
void hcdi_init() { /* register virtual root hub driver */ usb_register_driver(&at90usb1287_roothub); /* enable regulator */ UHWCON |= (1<<UVREGE); /* force host mode */ UHWCON &= ~(1<<UIDE); UHWCON &= ~(1<<UIMOD); /* pll sart */ UsbSetPLL_CPU_Frequency(); UsbEnablePLL(); UsbWaitPLL_Locked(); /* Usb_disable */ USBCON &= ~(1<<USBE); /* Usb_enable */ USBCON |= (1<<USBE); /* unfreeze clock */ UsbEnableClock(); /* usb attach */ UDCON &= ~(1<<DETACH); /* enable uconv pin */ UsbDisableUVCON_PinControl(); UsbEnableUID_ModeSelection(); /* select host */ USBCON |= (1<<HOST); /* disable vbus hw control */ OTGCON |= (1<<VBUSHWC); // 4 /* enable vbus */ OTGCON |= (1<<VBUSREQ); UHIEN |= (1<<DDISCE); UHIEN |= (1<<DCONNE); UHIEN = 0xff; }