void mgos_uart_hal_flush_fifo(struct mgos_uart_state *us) { struct cc32xx_uart_state *ds = (struct cc32xx_uart_state *) us->dev_data; while (MAP_UARTBusy(ds->base)) { } }
//***************************************************************************** // // Configue UART in internal loopback mode and tranmsit and receive data // internally. // //***************************************************************************** int main(void) { #if defined(TARGET_IS_TM4C129_RA0) || \ defined(TARGET_IS_TM4C129_RA1) || \ defined(TARGET_IS_TM4C129_RA2) uint32_t ui32SysClock; #endif uint8_t ui8DataTx[NUM_UART_DATA]; uint8_t ui8DataRx[NUM_UART_DATA]; uint32_t ui32index; // // Set the clocking to run directly from the crystal. // #if defined(TARGET_IS_TM4C129_RA0) || \ defined(TARGET_IS_TM4C129_RA1) || \ defined(TARGET_IS_TM4C129_RA2) ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_OSC), 25000000); #else MAP_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); #endif // // Enable the peripherals used by this example. // UART0 : To dump information to the console about the example. // UART7 : Enabled in loopback mode. Anything transmitted to Tx will be // received at the Rx. // MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // // Set GPIO A0 and A1 as UART pins. // GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Internal loopback programming. Configure the UART in loopback mode. // UARTLoopbackEnable(UART7_BASE); // // Configure the UART for 115,200, 8-N-1 operation. // #if defined(TARGET_IS_TM4C129_RA0) || \ defined(TARGET_IS_TM4C129_RA1) || \ defined(TARGET_IS_TM4C129_RA2) MAP_UARTConfigSetExpClk(UART0_BASE, ui32SysClock, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); MAP_UARTConfigSetExpClk(UART7_BASE, ui32SysClock, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); #else MAP_UARTConfigSetExpClk(UART0_BASE, MAP_SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); MAP_UARTConfigSetExpClk(UART7_BASE, MAP_SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); #endif // // Print banner after clearing the terminal. // UARTSend(UART0_BASE, (uint8_t *)"\033[2J\033[1;1H", 10); UARTSend(UART0_BASE, (uint8_t *)"\nUART Loopback Example ->", strlen("\nUART Loopback Example ->")); // // Prepare data to send over the UART configured for internal loopback. // ui8DataTx[0] = 'u'; ui8DataTx[1] = 'a'; ui8DataTx[2] = 'r'; ui8DataTx[3] = 't'; // // Inform user that data is being sent over for internal loopback. // UARTSend(UART0_BASE, (uint8_t *)"\n\n\rSending : ", strlen("\n\n\rSending : ")); UARTSend(UART0_BASE, (uint8_t*)ui8DataTx, NUM_UART_DATA); // // Send the data, which was prepared above, over the UART configured for // internal loopback operation. // for(ui32index = 0 ; ui32index < NUM_UART_DATA ; ui32index++) { UARTCharPut(UART7_BASE, ui8DataTx[ui32index]); } // // Wait for the UART module to complete transmitting. // while(MAP_UARTBusy(UART7_BASE)) { } // // Inform user that data the loopback data is being received. // UARTSend(UART0_BASE, (uint8_t *)"\n\rReceiving : ", strlen("\n\rReceiving : ")); // // Read data from the UART's receive FIFO and store it. // for(ui32index = 0 ; ui32index < NUM_UART_DATA ; ui32index++) { // // Get the data received by the UART at its receive FIFO // ui8DataRx[ui32index] = UARTCharGet(UART7_BASE); } // // Display the data received, after loopback, over UART's receive FIFO. // UARTSend(UART0_BASE, (uint8_t*)ui8DataRx, NUM_UART_DATA); // // Return no errors // return(0); }