| /* |
| * Copyright (c) 2016, Freescale Semiconductor, Inc. |
| * Copyright 2016-2017 NXP |
| * All rights reserved. |
| * |
| * SPDX-License-Identifier: BSD-3-Clause |
| */ |
| |
| #include "board.h" |
| #include "fsl_uart.h" |
| |
| #include "pin_mux.h" |
| #include "clock_config.h" |
| /******************************************************************************* |
| * Definitions |
| ******************************************************************************/ |
| #define DEMO_UART UART2 |
| #define DEMO_UART_CLK_FREQ BOARD_DEBUG_UART_CLK_FREQ |
| #define DEMO_UART_BAUDRATE 115200U |
| |
| /******************************************************************************* |
| * Prototypes |
| ******************************************************************************/ |
| |
| /******************************************************************************* |
| * Variables |
| ******************************************************************************/ |
| |
| uint8_t txbuff[] = "Uart polling example\r\nBoard will send back received characters\r\n"; |
| uint8_t rxbuff[20] = {0}; |
| /******************************************************************************* |
| * Code |
| ******************************************************************************/ |
| /*! |
| * @brief Main function |
| */ |
| int main(void) |
| { |
| uint8_t ch; |
| status_t status; |
| uart_config_t config; |
| |
| /* Board specific RDC settings */ |
| BOARD_RdcInit(); |
| |
| BOARD_InitPins(); |
| BOARD_BootClockRUN(); |
| BOARD_InitMemory(); |
| |
| /* |
| * config.baudRate_Bps = 115200U; |
| * config.parityMode = kUART_ParityDisabled; |
| * config.dataBitsCount = kUART_EightDataBits; |
| * config.stopBitCount = kUART_OneStopBit; |
| * config.txFifoWatermark = 2; |
| * config.rxFifoWatermark = 1; |
| * config.enableTx = false; |
| * config.enableRx = false; |
| */ |
| UART_GetDefaultConfig(&config); |
| config.baudRate_Bps = DEMO_UART_BAUDRATE; |
| config.enableTx = true; |
| config.enableRx = true; |
| |
| status = UART_Init(DEMO_UART, &config, DEMO_UART_CLK_FREQ); |
| if (kStatus_Success != status) |
| { |
| return kStatus_Fail; |
| } |
| |
| UART_WriteBlocking(DEMO_UART, txbuff, sizeof(txbuff) - 1); |
| |
| while (1) |
| { |
| UART_ReadBlocking(DEMO_UART, &ch, 1); |
| UART_WriteBlocking(DEMO_UART, &ch, 1); |
| } |
| } |