UART_init();
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uartParams.readMode=UART_MODE_CALLBACK;
uartParams.readCallback=vUartDefaultReceCallBack;
tgUartHand = UART_open(Board_UART0, &uartParams);
static uint8_t ucRxBuf[100];
static int_fast32_t ucRxLen=0;
static void vUartDefaultReceCallBack(UART_Handle uart, void *buf, size_t size)
{
UART_readCancel(tgUartHand);
ucRxLen= UART_read(tgUartHand,ucRxBuf,100);
}
UART_write可以发送数据。但是接收中断时没有发生。帮忙看看 哪里参数不对
Viki Shi:
可参考一下SDK中的UART例程
gui tan:
回复 Viki Shi:
/* Turn on user LED */GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
/* Create a UART with data processing off. */UART_Params_init(&uartParams);uartParams.writeDataMode = UART_DATA_BINARY;uartParams.readDataMode = UART_DATA_BINARY;uartParams.readReturnMode = UART_RETURN_FULL;uartParams.readEcho = UART_ECHO_OFF;uartParams.baudRate = 115200;
uart = UART_open(Board_UART0, &uartParams);
if (uart == NULL) {/* UART_open() failed */while (1);}
UART_write(uart, echoPrompt, sizeof(echoPrompt));
/* Loop forever echoing */while (1) {UART_read(uart, &input, 1);UART_write(uart, &input, 1);}
}看了下 只有这个? 还有别的