new file mode 100644
 (file)
index 0000000..
21c4ed3 
--- /dev/null
+# _esptic_
+
+Quick & dirty implementation of tic2json for ESP8266/ESP32.
+Gets TIC data on RX pin, outputs formatted JSON on UART TX.
+
+### Configure the project
+
+`idf.py menuconfig`
+
+* Set TIC baudrate and UART under Component config -> esptic
+* Set TIC version under Component config -> tic2json
+
+### Build and Flash
+
+Build the project and flash it to the board:
+
+`idf.py flash`
+
+See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
 
new file mode 100644
 (file)
index 0000000..
c462771 
--- /dev/null
+idf_component_register(SRC_DIRS "src")
+target_compile_options(${COMPONENT_LIB} PRIVATE -DBAREBUILD)
+add_custom_target(CSOURCES ALL make -C ${COMPONENT_DIR}/src csources)
+
+if(CONFIG_TIC2JSON_TICV01)
+add_definitions(-DTICV01)
+endif()
+if(CONFIG_TIC2JSON_TICV02)
+add_definitions(-DTICV02)
+endif()
 
new file mode 100644
 (file)
index 0000000..
e47d39a 
--- /dev/null
+COMPONENT_SRCDIRS := src
+CFLAGS += -DBAREBUILD
+
+ifdef CONFIG_TIC2JSON_TICV01
+CFLAGS += -DTICV01
+endif
+
+ifdef CONFIG_TIC2JSON_TICV02
+CFLAGS += -DTICV02
+endif
+
+$(COMPONENT_LIBRARY): csource
+
+csource:
+    make -C $(COMPONENT_PATH)/$(COMPONENT_SRCDIRS) csources
+
+.PHONY: csource
 
new file mode 100644
 (file)
index 0000000..
527ca08 
--- /dev/null
+//
+// main.c
+// app stub for ESP8266/ESP32
+//
+// (C) 2021 Thibaut VARENE
+// License: GPLv2 - http://www.gnu.org/licenses/gpl-2.0.html
+//
+
+/**
+ * @file
+ * Receives TIC on RX, outputs JSON on TX.
+ * @note: Memory usage detailed below has been tested on ESP8266 in "Release" (-Os) build:
+ * - TICV01: max stack 5400, max heap: 3764+80
+ * - TICV02: max stack 5816, max heap: 3764+80
+ */
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "esp_vfs_dev.h"
+#include "driver/uart.h"
+
+void ticmain(void);
+
+void app_main(void)
+{
+    uart_config_t uart_config = {
+        .baud_rate = CONFIG_ESPTIC_BAUDRATE,
+        .data_bits = UART_DATA_7_BITS,
+        .parity  = UART_PARITY_EVEN,
+        .stop_bits = UART_STOP_BITS_1,
+    };
+    ESP_ERROR_CHECK(uart_param_config(CONFIG_ESPTIC_UART_NUM, &uart_config));
+
+    /* Install UART driver for interrupt-driven reads and writes */
+    ESP_ERROR_CHECK(uart_driver_install(CONFIG_ESPTIC_UART_NUM,
+        UART_FIFO_LEN*2, 0, 0, NULL, 0));
+
+    /* Tell VFS to use UART driver */
+    esp_vfs_dev_uart_use_driver(CONFIG_ESPTIC_UART_NUM);
+
+    while (1)
+        ticmain();
+}