您好!
SDK 6.41.0.17 + syscfg 1.15.0 + CCS 12.3.0.00005
我正在低优先级 RTOS 任务循环中将数据从无线电移动到 UART。
我注意到,使用 GPIO 切换和计时范围, UART2_WRITE ()阻止了我的线程200-500 us。
您能告诉我、我是否正确设置了这个吗? 对于非阻塞 API,200-500 us 是正常的吗?
void appUartInit() {
UART2_Params uartParams;
UART2_Params_init(&uartParams);
uartParams.baudRate = 8*115200;
uartParams.writeMode = UART2_Mode_NONBLOCKING;
uartParams.readMode = UART2_Mode_NONBLOCKING;
/*
* UART2_ReadReturnMode_PARTIAL unblocks or performs a callback whenever a read timeout error occurs on the UART peripheral.
* This timeout error is not the same as the blocking read timeout in the UART2_Params;
* the read timeout occurs if the read FIFO is non-empty and no new data has been received for a device/baudrate dependent number of clock cycles.
* This mode can be used when the exact number of bytes to be read is not known.
*/
uartParams.readReturnMode = UART2_ReadReturnMode_PARTIAL;
uart[1] = UART2_open(CONFIG_UART_0, &uartParams);
if (uart[1] == NULL)
{
while (1) {}
}
}
int appUartWrite(uint8_t *buf, int len) {
size_t bytesWritten = 0;
GPIO_write(CONFIG_GPIO_0, 1);
UART2_write(uart[1], buf, len, (size_t *)&bytesWritten);
GPIO_write(CONFIG_GPIO_0, 0);
return bytesWritten;
}