35 #ifndef ROS_LIB_TIVAC_HARDWARE_USB_H
36 #define ROS_LIB_TIVAC_HARDWARE_USB_H
42 #include <inc/hw_types.h>
43 #include <inc/hw_memmap.h>
44 #include <inc/hw_ints.h>
45 #include <driverlib/sysctl.h>
46 #include <driverlib/gpio.h>
47 #include <driverlib/rom.h>
48 #include <driverlib/rom_map.h>
49 #include <driverlib/systick.h>
50 #include <driverlib/pin_map.h>
51 #include <driverlib/usb.h>
52 #include <usblib/usblib.h>
53 #include <usblib/usbcdc.h>
54 #include <usblib/usb-ids.h>
55 #include <usblib/device/usbdevice.h>
56 #include <usblib/device/usbdcdc.h>
60 #define SYSTICKHZ 1000UL
63 #define LED1 GPIO_PIN_3 // Green LED
64 #define LED2 GPIO_PIN_2 // Blue LED
65 #define LED_PORT GPIO_PORTF_BASE
66 #define LED_PERIPH SYSCTL_PERIPH_GPIOF
70 #define LED1 GPIO_PIN_1 // D1 LED
71 #define LED2 GPIO_PIN_0 // D2 LED
72 #define LED_PORT GPIO_PORTN_BASE
73 #define LED_PERIPH SYSCTL_PERIPH_GPION
75 #error "Must define system clock frequency on: TM4C129FREQ"
97 #if defined(LED_HEARTBEAT) || defined(LED_COMM)
98 MAP_SysCtlPeripheralEnable(LED_PERIPH);
101 MAP_GPIOPinTypeGPIOOutput(LED_PORT, LED1);
104 MAP_GPIOPinTypeGPIOOutput(LED_PORT, LED2);
113 MAP_SysTickIntEnable();
115 MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
118 MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
119 MAP_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_5 | GPIO_PIN_4);
122 MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
123 MAP_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);
131 USBStackModeSet(0, eUSBModeForceDevice, 0);
138 USBIntRegister(USB0_BASE, USB0DeviceIntHandler);
141 MAP_IntMasterEnable();
148 if (USBBufferRead(&
g_sRxBuffer, &ui8ReadData, 1) == 1)
152 MAP_GPIOPinWrite(LED_PORT, LED2, MAP_GPIOPinRead(LED_PORT, LED2)^LED2);
161 void write(uint8_t* data,
int length)
165 MAP_GPIOPinWrite(LED_PORT, LED2, MAP_GPIOPinRead(LED_PORT, LED2)^LED2);
185 MAP_GPIOPinWrite(LED_PORT, LED1, MAP_GPIOPinRead(LED_PORT, LED1)^LED1);
204 MAP_SysCtlDelay(this->ui32SysClkFreq/3/
SYSTICKHZ * 500);
207 MAP_SysCtlDelay(this->ui32SysClkFreq/3/
SYSTICKHZ * ms);
210 #endif // ROS_LIB_TIVAC_HARDWARE_USB_H