armchair_fw/common/uart_common.cpp
jonny_jr9 3722b0af74 Add uart templates, send and receive tasks with templates work
both boards compile and send/receive example data using new templates in
common uart code
common/uart_common.hpp
2023-08-30 09:01:31 +02:00

30 lines
748 B
C++

#include "uart_common.hpp"
static const char * TAG = "uart-common";
//===========================
//======== uart_init =======
//===========================
//initial struct on given pins
//TODO add pins and baud rate to config?
void uart_init(void){
uart_config_t uart1_config = {
.baud_rate = 115198,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_EVEN,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
};
ESP_LOGI(TAG, "configure...");
ESP_ERROR_CHECK(uart_param_config(UART_NUM_1, &uart1_config));
ESP_LOGI(TAG, "setpins...");
ESP_ERROR_CHECK(uart_set_pin(UART_NUM_1, 23, 22, 0, 0));
ESP_LOGI(TAG, "init...");
ESP_ERROR_CHECK(uart_driver_install(UART_NUM_1, 1024, 1024, 10, NULL, 0));
}