35 #ifndef ROS_LIB_TIVAC_HARDWARE_H 36 #define ROS_LIB_TIVAC_HARDWARE_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/uart.h> 52 #include <utils/ringbuf.h> 55 #define SYSTICKHZ 1000UL 58 #define LED1 GPIO_PIN_3 // Green LED 59 #define LED2 GPIO_PIN_2 // Blue LED 60 #define LED_PORT GPIO_PORTF_BASE 61 #define LED_PERIPH SYSCTL_PERIPH_GPIOF 65 #define LED1 GPIO_PIN_1 // D1 LED 66 #define LED2 GPIO_PIN_0 // D2 LED 67 #define LED_PORT GPIO_PORTN_BASE 68 #define LED_PERIPH SYSCTL_PERIPH_GPION 70 #error "Must define system clock frequency on: TM4C129FREQ" 74 #ifndef ROSSERIAL_BAUDRATE 75 #define ROSSERIAL_BAUDRATE 57600 98 #if defined(LED_HEARTBEAT) || defined(LED_COMM) 99 MAP_SysCtlPeripheralEnable(LED_PERIPH);
102 MAP_GPIOPinTypeGPIOOutput(LED_PORT, LED1);
105 MAP_GPIOPinTypeGPIOOutput(LED_PORT, LED2);
114 MAP_SysTickIntEnable();
117 MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
118 MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
120 MAP_GPIOPinConfigure(GPIO_PA0_U0RX);
121 MAP_GPIOPinConfigure(GPIO_PA1_U0TX);
122 MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
125 (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
127 MAP_UARTFIFODisable(UART0_BASE);
134 MAP_IntEnable(INT_UART0);
135 MAP_UARTTxIntModeSet(UART0_BASE, UART_TXINT_MODE_EOT);
136 MAP_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_TX);
139 MAP_IntMasterEnable();
152 void write(uint8_t* data,
int length)
157 RingBufWrite(&
txBuffer, data, length);
158 MAP_UARTCharPutNonBlocking(UART0_BASE, RingBufReadOne(&
txBuffer));
162 RingBufWrite(&
txBuffer, data, length);
183 ui32Status = MAP_UARTIntStatus(UART0_BASE,
true);
185 MAP_UARTIntClear(UART0_BASE, ui32Status);
190 if (ui32Status & UART_INT_RX)
191 RingBufWriteOne(&
rxBuffer, MAP_UARTCharGetNonBlocking(UART0_BASE));
194 if (ui32Status & UART_INT_TX)
196 MAP_UARTCharPutNonBlocking(UART0_BASE, RingBufReadOne(&
txBuffer));
200 MAP_GPIOPinWrite(LED_PORT, LED2, MAP_GPIOPinRead(LED_PORT, LED2)^LED2);
211 MAP_GPIOPinWrite(LED_PORT, LED1, MAP_GPIOPinRead(LED_PORT, LED1)^LED1);
230 MAP_SysCtlDelay(this->ui32SysClkFreq/3/
SYSTICKHZ * 500);
233 MAP_SysCtlDelay(this->ui32SysClkFreq/3/
SYSTICKHZ * ms);
236 #endif // ROS_LIB_TIVAC_HARDWARE_H
uint8_t ui8rxBufferData[RX_BUFFER_SIZE]
void write(uint8_t *data, int length)
static void SystickIntHandler()
static void UARTIntHandler()
uint32_t getSysClkFreq(void)
#define ROSSERIAL_BAUDRATE
volatile uint32_t g_ui32heartbeat
uint8_t ui8txBufferData[TX_BUFFER_SIZE]
volatile uint32_t g_ui32milliseconds