/*! * @brief Main function */ int main(void) { uint8_t ch; lpuart_config_t config; BOARD_InitPins(); BOARD_BootClockRUN(); CLOCK_SetLpuart1Clock(1U); /* * config.baudRate_Bps = 115200U; * config.parityMode = kLPUART_ParityDisabled; * config.stopBitCount = kLPUART_OneStopBit; * config.txFifoWatermark = 0; * config.rxFifoWatermark = 0; * config.enableTx = false; * config.enableRx = false; */ LPUART_GetDefaultConfig(&config); config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE; config.enableTx = true; config.enableRx = true; LPUART_Init(DEMO_LPUART, &config, CLOCK_GetFreq(DEMO_LPUART_CLKSRC)); LPUART_WriteBlocking(DEMO_LPUART, txbuff, sizeof(txbuff) - 1); while (1) { LPUART_ReadBlocking(DEMO_LPUART, &ch, 1); LPUART_WriteBlocking(DEMO_LPUART, &ch, 1); } }
void hw_uart_printchar(int c) { #ifdef FREESCALE_KSDK_BM LPUART_WriteBlocking(UART_PORT, (const uint8_t*)&c, 1); /* Send the character */ #else while(!(UART_PORT->S1 & UART_S1_TDRE_MASK)); /* Wait until space is available in the FIFO */ UART_PORT->D = (uint8_t)c; /* Send the character */ #endif }
/*! * @brief Main function */ int main(void) { lpuart_config_t config; BOARD_InitPins(); BOARD_BootClockRUN(); CLOCK_SetLpuart1Clock(1U); /* * config.baudRate_Bps = 115200U; * config.parityMode = kLPUART_ParityDisabled; * config.stopBitCount = kLPUART_OneStopBit; * config.txFifoWatermark = 0; * config.rxFifoWatermark = 0; * config.enableTx = false; * config.enableRx = false; */ LPUART_GetDefaultConfig(&config); config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE; config.enableTx = true; config.enableRx = true; LPUART_Init(DEMO_LPUART, &config, CLOCK_GetFreq(DEMO_LPUART_CLKSRC)); /* Send g_tipString out. */ LPUART_WriteBlocking(DEMO_LPUART, g_tipString, sizeof(g_tipString) / sizeof(g_tipString[0])); /* Enable RX interrupt. */ LPUART_EnableInterrupts(DEMO_LPUART, kLPUART_RxDataRegFullInterruptEnable); EnableIRQ(DEMO_LPUART_IRQn); while (1) { /* Send data only when LPUART TX register is empty and ring buffer has data to send out. */ while ((kLPUART_TxDataRegEmptyFlag & LPUART_GetStatusFlags(DEMO_LPUART)) && (rxIndex != txIndex)) { LPUART_WriteByte(DEMO_LPUART, demoRingBuffer[txIndex]); txIndex++; txIndex %= DEMO_RING_BUFFER_SIZE; } } }
void modem_write(const uint8_t *buffer, size_t size) { LPUART_WriteBlocking(BOARD_CELL_UART, buffer, size); }