change uart baudrate
各位先進好
請問有關改變baudrate方法,cc2640在TLInit()後當發現baudrate不是我想要的想改變baudrate,但又不想sw reset,是否有辦法??
有類似TLclose()之類的做法?
我有多種device,是共code的,2640會分別用四種不同baudrate依序向device溝通,當取得device回應,即使用該baudrate。
目前暫用sw reset,但希望改掉,不希望系統一直在reset
您可以试一下下面的程序
#include <ti/drivers/UART.h>
#include "inc/npi_tl_uart.h"
#include <ti/drivers/uart/UARTCC26XX.h>
change_uart_baudrate ()
{
Static UART_Handle uartHandle;
UART_close(uartHandle);
UART_Params params;
UART_Params_init(¶ms);
params.baudRate = change_baudrate;
params.readDataMode = UART_DATA_BINARY;
params.writeDataMode = UART_DATA_BINARY;
params.dataLength = UART_LEN_8;
params.stopBits = UART_STOP_ONE;
params.readMode = UART_MODE_CALLBACK;
params.writeMode = UART_MODE_CALLBACK;
params.readEcho = UART_ECHO_OFF;
params.readCallback = UART_read;
params.writeCallback = UART_write;
uartHandle = UART_open(CC2650_UART0, ¶ms);
UART_control(uartHandle, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE, NULL);
return 1;
}
main()
{
if (uart_baudrate_error)
change_uart_baudrate();
}