ESP32-WROOM-32 串口2的问题
Posted: Mon May 27, 2019 7:53 am
我想使用ESP32-WROOM-32的串口2,使用如下初始化代码(在ble_spp_server.c例程中将UART_NUM0 -> UART_NUM2),发现串口2既收不到数据,也发不出来数据,请问使用串口2有什么要注意的吗,还是ESP32-WROOM-32串口2不能用?
static void spp_uart_init(void)
{
uart_config_t uart_config = {
.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,
};
//Set UART parameters
uart_param_config(UART_NUM_2, &uart_config);
//Set UART pins
uart_set_pin(UART_NUM_2, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
//Install UART driver, and get the queue.
uart_driver_install(UART_NUM_2, 4096, 8192, 10,&spp_uart_queue,0);
xTaskCreate(uart_task, "uTask", 2048, (void*)USE_UART, 8, NULL);
}
static void spp_uart_init(void)
{
uart_config_t uart_config = {
.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,
};
//Set UART parameters
uart_param_config(UART_NUM_2, &uart_config);
//Set UART pins
uart_set_pin(UART_NUM_2, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
//Install UART driver, and get the queue.
uart_driver_install(UART_NUM_2, 4096, 8192, 10,&spp_uart_queue,0);
xTaskCreate(uart_task, "uTask", 2048, (void*)USE_UART, 8, NULL);
}