Autor Tema: USB HOST con Launchpad ek-tm4c123gxl  (Leído 2556 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado elmasvital

  • Administrador
  • PIC24H
  • *******
  • Mensajes: 1713
USB HOST con Launchpad ek-tm4c123gxl
« en: 01 de Agosto de 2014, 08:32:01 »
Alguien ha conseguido hacer andar el usb Host en este dispositivo?

Estoy intentando adaptar varios ejemplos para otras placas pero no soy capaz de hacerlo andar

Alimento el dispositivo que le conecto, un teclado o un ratón a través de un jumper al lado del switch de selección de power que tiene. Funciona la tensión ok pq el ratón se enciende.

He intentado cebar el pin PB1 con la tensión de Vbus y PB0 a GND para forzar a usar el modo host pero nada. No reconoce lo que le pincho.

Código: C++
  1. int
  2. main(void)
  3. {
  4. //    uint32_t ui32SysClock, ui32PLLRate;
  5.  
  6.  
  7.     //
  8.     // Set the system clock to run at 50MHz from the PLL.
  9.     //
  10. //    ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL), 80000000);
  11.  
  12.     ui32SysClock= SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
  13.    //                    SYSCTL_XTAL_16MHZ);
  14.  
  15.  
  16.     // Set the part pin out appropriately for this device.
  17.     //
  18.     PinoutSet(false, true);
  19.  
  20.     ConfigureUART();
  21.  
  22.     // Print a welcome message
  23.     //
  24.     UARTprintf("\033[2J\033[H");
  25.     UARTprintf("USB Host Mouse Example\n");
  26.     UARTprintf("Waiting for device....\n");
  27.  
  28.     //
  29.     // Save the PLL rate used by this application.
  30.     //
  31.    // ui32PLLRate = 480000000;
  32.  
  33.     //
  34.     // Initialize the connection status.
  35.     //
  36.     g_sStatus.bConnected = false;
  37.     g_sStatus.ui32Buttons = 0;
  38.  
  39.     //
  40.     // Enable Clocking to the USB controller.
  41.     //
  42.     ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
  43.  
  44.     //
  45.     // Enable Interrupts
  46.     //
  47.     ROM_IntMasterEnable();
  48.  
  49.     //
  50.     // Initialize the USB stack mode and pass in a mode callback.
  51.     //
  52.     USBStackModeSet(0, eUSBModeForceHost, 0);
  53.  
  54.     //
  55.     // Register the host class drivers.
  56.     //
  57.     USBHCDRegisterDrivers(0, g_ppHostClassDrivers, g_ui32NumHostClassDrivers);
  58.  
  59.     //
  60.     // Open an instance of the mouse driver.  The mouse does not need
  61.     // to be present at this time, this just save a place for it and allows
  62.     // the applications to be notified when a mouse is present.
  63.     //
  64.     g_psMouse = USBHMouseOpen(MouseCallback, 0, 0);
  65.  
  66.     //
  67.     // Initialize the power configuration. This sets the power enable signal
  68.     // to be active high and does not enable the power fault.
  69.     //
  70.     USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);
  71.  
  72.     //
  73.     // Tell the USB library the CPU clock and the PLL frequency.  This is a
  74.     // new requirement for TM4C129 devices.
  75.     //
  76. //    USBHCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &ui32SysClock);
  77. //    USBHCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate);
  78.  
  79.     //
  80.     // Initialize the USB controller for Host mode.
  81.     //
  82.     USBHCDInit(0, g_pui8HCDPool, sizeof(g_pui8HCDPool));
  83.  
  84.     //
  85.     // The main loop for the application.
  86.     //
  87.     while(1)
  88.     {
  89.         //
  90.         // Call the USB library to let non-interrupt code run.
  91.         //
  92.         USBHCDMain();
  93.  
  94.         //
  95.         // Call the mouse and mass storage main routines.
  96.         //
  97.         MouseMain();
  98.     }
  99. }
  100.  
  101. void
  102. PinoutSet(bool bEthernet, bool bUSB)
  103. {
  104.     //
  105.     // Enable all the GPIO peripherals.
  106.     //
  107.     ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
  108.     ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
  109.     ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
  110.  
  111.     //
  112.     // PA0-1 are used for UART0.
  113.     //
  114.     ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
  115.     ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
  116.  
  117.     ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
  118.  
  119.     //
  120.     // PB0-1/PD6/PL6-7 are used for USB.
  121.     // PQ4 can be used as a power fault detect on this board but it is not
  122.     // the hardware peripheral power fault input pin.
  123.     //
  124.     if(bUSB)
  125.     {
  126.         HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
  127.         HWREG(GPIO_PORTD_BASE + GPIO_O_CR) = 0xff;
  128.  
  129.  
  130. //        ROM_GPIOPinConfigure(GPIO_PD6_USB0EPEN);
  131.         ROM_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_1);
  132.         ROM_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5);
  133.  
  134.     }
  135.  
  136. }
« Última modificación: 01 de Agosto de 2014, 08:34:13 por elmasvital »

Desconectado elmasvital

  • Administrador
  • PIC24H
  • *******
  • Mensajes: 1713
Re: USB HOST con Launchpad ek-tm4c123gxl
« Respuesta #1 en: 02 de Agosto de 2014, 08:55:06 »
Resuelto


Esta es la nueva forma de configurar el clock en las TM4C129

    ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL), 120000000);

ui32SysClock guarda la frecuencia de reloj del sistema. Se usa en vez de SysCtlGetClock
 
Y esta para los TM4C123

    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

Esta función no devuelve nada por lo que para conocer la velocidad de reloj del sitema hay que usar SysCtlGetClock ();

« Última modificación: 02 de Agosto de 2014, 09:16:29 por elmasvital »


 

anything