1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include <stdio.h>
#include "driver/uart.h"
#define ECHECK(...) ESP_ERROR_CHECK(__VA_ARGS__)
QueueHandle_t uart_queue;
void uart_setup(void);
void app_main(void)
{
uart_setup();
char message[] = "Hello World\n";
uart_write_bytes(UART_NUM_0, message, sizeof(message));
}
void uart_setup(void)
{
// stty -F /dev/ttyUSB0 cs8 -parenb -crtscts -cstopb
uart_config_t uart_config = {
.baud_rate = 9600,
.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,
};
#define UART_BUFFER_SIZE 2048
ECHECK(uart_param_config(UART_NUM_0, &uart_config));
ECHECK(uart_driver_install(UART_NUM_0, UART_BUFFER_SIZE, UART_BUFFER_SIZE, 10, &uart_queue, 0));
}
|