aboutsummaryrefslogtreecommitdiff
path: root/master/main/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'master/main/main.c')
-rw-r--r--master/main/main.c34
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));
+}
+