diff options
author | kartofen <mladenovnasko0@gmail.com> | 2023-12-25 01:45:05 +0200 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2023-12-25 01:45:05 +0200 |
commit | 4b0fdca8673c76cb2305db301a3b36e9e3822e02 (patch) | |
tree | bbcf1c6364baba0afe9a2a595f4a579ad0946188 /master/main/main.c |
Diffstat (limited to 'master/main/main.c')
-rw-r--r-- | master/main/main.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/master/main/main.c b/master/main/main.c new file mode 100644 index 0000000..ee170bc --- /dev/null +++ b/master/main/main.c @@ -0,0 +1,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)); +} + |