Add code to start the USBB Generic Clock from the user-specified master clock source (OSCx or PLLx) in the AVR32 UC3B core USB driver.

pull/1469/head
Dean Camera 14 years ago
parent c79f6e2586
commit 29ba88cffd

@ -92,6 +92,8 @@ void USB_Disable(void)
USB_CurrentMode = USB_MODE_None; USB_CurrentMode = USB_MODE_None;
#endif #endif
AVR32_PM.GCCTRL[3].cen = false;
USB_IsInitialized = false; USB_IsInitialized = false;
} }
@ -106,6 +108,12 @@ void USB_ResetInterface(void)
USB_Controller_Reset(); USB_Controller_Reset();
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].pllsel = !(USB_Options & USB_OPT_GCLK_SRC_OSC);
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].oscsel = !(USB_Options & USB_OPT_GCLK_CHANNEL_0);
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].diven = (F_CLOCK != 48000000UL);
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].div = ((F_CLOCK / 2) / 48000000UL);
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].cen = true;
#if defined(USB_CAN_BE_BOTH) #if defined(USB_CAN_BE_BOTH)
if (UIDModeSelectEnabled) if (UIDModeSelectEnabled)
{ {

@ -82,6 +82,27 @@
/* Public Interface - May be used in end-application: */ /* Public Interface - May be used in end-application: */
/* Macros: */ /* Macros: */
/** \name USB Controller Option Masks */
//@{
/** Selects one of the system's main clock oscillators as the input clock to the USB Generic Clock source
* generation module. This indicates that an external oscillator should be used directly instead of an
* internal PLL clock source.
*/
#define USB_OPT_GCLK_SRC_OSC (1 << 1)
/** Selects one of the system's PLL oscillators as the input clock to the USB Generic Clock source
* generation module. This indicates that one of the device's PLL outputs should be used instead of an
* external oscillator source.
*/
#define USB_OPT_GCLK_SRC_PLL (0 << 1)
/** Selects PLL or External Oscillator 0 as the USB Generic Clock source module input clock. */
#define USB_OPT_GCLK_CHANNEL_0 (1 << 2)
/** Selects PLL or External Oscillator 1 as the USB Generic Clock source module input clock. */
#define USB_OPT_GCLK_CHANNEL_1 (0 << 2)
//@}
/** \name Endpoint/Pipe Type Masks */ /** \name Endpoint/Pipe Type Masks */
//@{ //@{
/** Mask for a CONTROL type endpoint or pipe. /** Mask for a CONTROL type endpoint or pipe.
@ -272,6 +293,9 @@
/* Private Interface - For use in library only: */ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
/* Macros: */
#define USB_GCLK_USBB_INDEX 3
/* Function Prototypes: */ /* Function Prototypes: */
#if defined(__INCLUDE_FROM_USB_CONTROLLER_C) #if defined(__INCLUDE_FROM_USB_CONTROLLER_C)
#if defined(USB_CAN_BE_DEVICE) #if defined(USB_CAN_BE_DEVICE)

Loading…
Cancel
Save