int
main(void)
{
// uint32_t ui32SysClock, ui32PLLRate;
//
// Set the system clock to run at 50MHz from the PLL.
//
// ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL), 80000000);
ui32SysClock= SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
// SYSCTL_XTAL_16MHZ);
// Set the part pin out appropriately for this device.
//
PinoutSet(false, true);
ConfigureUART();
// Print a welcome message
//
UARTprintf("\033[2J\033[H");
UARTprintf("USB Host Mouse Example\n");
UARTprintf("Waiting for device....\n");
//
// Save the PLL rate used by this application.
//
// ui32PLLRate = 480000000;
//
// Initialize the connection status.
//
g_sStatus.bConnected = false;
g_sStatus.ui32Buttons = 0;
//
// Enable Clocking to the USB controller.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
//
// Enable Interrupts
//
ROM_IntMasterEnable();
//
// Initialize the USB stack mode and pass in a mode callback.
//
USBStackModeSet(0, eUSBModeForceHost, 0);
//
// Register the host class drivers.
//
USBHCDRegisterDrivers(0, g_ppHostClassDrivers, g_ui32NumHostClassDrivers);
//
// Open an instance of the mouse driver. The mouse does not need
// to be present at this time, this just save a place for it and allows
// the applications to be notified when a mouse is present.
//
g_psMouse = USBHMouseOpen(MouseCallback, 0, 0);
//
// Initialize the power configuration. This sets the power enable signal
// to be active high and does not enable the power fault.
//
USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);
//
// Tell the USB library the CPU clock and the PLL frequency. This is a
// new requirement for TM4C129 devices.
//
// USBHCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &ui32SysClock);
// USBHCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate);
//
// Initialize the USB controller for Host mode.
//
USBHCDInit(0, g_pui8HCDPool, sizeof(g_pui8HCDPool));
//
// The main loop for the application.
//
while(1)
{
//
// Call the USB library to let non-interrupt code run.
//
USBHCDMain();
//
// Call the mouse and mass storage main routines.
//
MouseMain();
}
}
void
PinoutSet(bool bEthernet, bool bUSB)
{
//
// Enable all the GPIO peripherals.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
//
// PA0-1 are used for UART0.
//
ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// PB0-1/PD6/PL6-7 are used for USB.
// PQ4 can be used as a power fault detect on this board but it is not
// the hardware peripheral power fault input pin.
//
if(bUSB)
{
HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG(GPIO_PORTD_BASE + GPIO_O_CR) = 0xff;
// ROM_GPIOPinConfigure(GPIO_PD6_USB0EPEN);
ROM_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_1);
ROM_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5);
}
}