USB XMEGA support improvements; add DFLL clock platform support, ensure the endpoint table is correctly aligned and configured in the USB controller.

This commit is contained in:
Dean Camera 2011-10-07 05:52:35 +00:00
parent db73b11244
commit a4d67bb6ff
2 changed files with 87 additions and 2 deletions

View file

@ -40,7 +40,7 @@ volatile uint8_t USB_CurrentMode = USB_MODE_None;
volatile uint8_t USB_Options;
#endif
USB_EP_TABLE_t USB_EndpointTable ATTR_ALIGNED(2);
USB_EP_TABLE_t USB_EndpointTable ATTR_ALIGNED(4);
void USB_Init(
#if defined(USB_CAN_BE_BOTH)
@ -72,6 +72,8 @@ void USB_Init(
NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc;
USB.CAL1 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL1));
USB.EPPTR = (intptr_t)&USB_EndpointTable;
if ((USB_Options & USB_OPT_BUSEVENT_PRIHIGH) == USB_OPT_BUSEVENT_PRIHIGH)
USB.INTCTRLA = (3 << USB_INTLVL_gp);
else if ((USB_Options & USB_OPT_BUSEVENT_PRIMED) == USB_OPT_BUSEVENT_PRIMED)
@ -81,7 +83,7 @@ void USB_Init(
SetGlobalInterruptMask(CurrentGlobalInt);
USB_ResetInterface();
USB_ResetInterface();
}
void USB_Disable(void)
@ -102,6 +104,8 @@ void USB_ResetInterface(void)
else
CLK.USBCTRL = ((((F_USB / 48000000) - 1) << CLK_USBPSDIV_gp) | CLK_USBSRC_PLL_gc | CLK_USBSEN_bm);
USB_Device_SetDeviceAddress(0);
USB_INT_DisableAllInterrupts();
USB_INT_ClearAllInterrupts();