38 lines
738 B
C++
38 lines
738 B
C++
//
|
|
// Created by erki on 6/3/23.
|
|
//
|
|
|
|
#include "app_serial.hpp"
|
|
|
|
#include "driver/uart.h"
|
|
|
|
namespace
|
|
{
|
|
|
|
QueueHandle_t s_uart_queue = nullptr;
|
|
|
|
}
|
|
|
|
namespace Serial
|
|
{
|
|
|
|
QueueHandle_t setupSerial()
|
|
{
|
|
uart_config_t 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,
|
|
.source_clk = UART_SCLK_DEFAULT,
|
|
};
|
|
|
|
ESP_ERROR_CHECK(uart_driver_install(UART_NUM_0, 128, 128 * 2, 4, &s_uart_queue, 0));
|
|
ESP_ERROR_CHECK(uart_param_config(UART_NUM_0, &config));
|
|
ESP_ERROR_CHECK(uart_set_pin(UART_NUM_0, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
|
|
|
|
return s_uart_queue;
|
|
}
|
|
|
|
}
|