ESP32串口0用于下载程序跟输出log,现在我想通过串口工具发送几个字节的数据过去,
程序内未做任何初始化,直接采用uart_read_bytes读取
发现在没有发送数据时候也一直读取到数据
想不影响UART0本来原有的下载+LOG功能的前提下,在输入口增加接收功能,
有办法实现么?
[已解决]ESP32 下载串口用作普通串口
[已解决]ESP32 下载串口用作普通串口
Last edited by ripper on Wed Sep 08, 2021 2:43 am, edited 1 time in total.
-
- Posts: 786
- Joined: Wed Nov 14, 2018 8:45 am
Re: ESP32 下载串口用作普通串口
你参看一下示例 examples/peripherals/uart/uart_echo
Re: ESP32 下载串口用作普通串口
已解决,不是简单的串口应用。
LOG 串口在平时只是用于输出,UART0只有TX在工作,之前请教的是如何让RX也工作起来。
先显性的初始化一下UART0
Code: Select all
void DebugUartInit(void)
{
uart_config_t uartConfig =
{
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.source_clk = UART_SCLK_APB,
};
uart_driver_install(UART_NUM_0, BUF_SIZE, BUF_SIZE*2, 0, NULL, 0);
uart_param_config(UART_NUM_0, &uartConfig);
uart_set_pin(UART_NUM_0, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
}
Code: Select all
sReceiveData.size = 0;
sReceiveData.size = uart_read_bytes(UART_NUM_0, sReceiveData.data, BUF_SIZE, 100);
if(sReceiveData.size)
{
ESP_LOGI(TAG, "Size: %d", sReceiveData.size);
}
Who is online
Users browsing this forum: No registered users and 38 guests