]> vcs.slashdirt.org Git - sw/tic2json.git/commitdiff

vcs.slashdirt.org Git - sw/tic2json.git/commitdiff

git git / sw / tic2json.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2f45aaf)
Add build recipes for ESP8266/ESP32 FreeRTOS IDF
Sun, 5 Sep 2021 18:57:08 +0000 (20:57 +0200)
Sun, 5 Sep 2021 20:31:27 +0000 (22:31 +0200)
This commit adds recipes for a quick implementation of tic2json on
Espressif FreeRTOS IDF SDK. It builds identically for ESP8266 and ESP32
(tested only on ESP8266).

The included main_app() stub sets up a serial conversion with raw TIC
on input (RX) and JSON on output (TX).

The build recipe is hackish, but it get things done.

13 files changed:
embedded/ESP-RTOS/esptic/.gitignore [new file with mode: 0644] patch | blob
embedded/ESP-RTOS/esptic/CMakeLists.txt [new file with mode: 0644] patch | blob
embedded/ESP-RTOS/esptic/Makefile [new file with mode: 0644] patch | blob
embedded/ESP-RTOS/esptic/README.md [new file with mode: 0644] patch | blob
embedded/ESP-RTOS/esptic/main/Kconfig [new file with mode: 0644] patch | blob
embedded/ESP-RTOS/esptic/main/main.c [new file with mode: 0644] patch | blob

diff --git a/embedded/ESP-RTOS/esptic/.gitignore b/embedded/ESP-RTOS/esptic/.gitignore
new file mode 100644 (file)
index 0000000..ce66cbf
--- /dev/null
+++ b/embedded/ESP-RTOS/esptic/.gitignore
@@ -0,0 +1,3 @@
+build/
+sdkconfig
+sdkconfig.old
diff --git a/embedded/ESP-RTOS/esptic/CMakeLists.txt b/embedded/ESP-RTOS/esptic/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c80f2d4
--- /dev/null
+++ b/embedded/ESP-RTOS/esptic/CMakeLists.txt
@@ -0,0 +1,6 @@
+# The following four lines of boilerplate have to be in your project's CMakeLists
+# in this exact order for cmake to work correctly
+cmake_minimum_required(VERSION 3.5)
+
+include($ENV{IDF_PATH}/tools/cmake/project.cmake)
+project(esptic)
diff --git a/embedded/ESP-RTOS/esptic/Makefile b/embedded/ESP-RTOS/esptic/Makefile
new file mode 100644 (file)
index 0000000..8be1c8e
--- /dev/null
+++ b/embedded/ESP-RTOS/esptic/Makefile
@@ -0,0 +1,9 @@
+#
+# This is a project Makefile. It is assumed the directory this Makefile resides in is a
+# project subdirectory.
+#
+
+PROJECT_NAME := esptic
+
+include $(IDF_PATH)/make/project.mk
+
diff --git a/embedded/ESP-RTOS/esptic/README.md b/embedded/ESP-RTOS/esptic/README.md
new file mode 100644 (file)
index 0000000..21c4ed3
--- /dev/null
+++ b/embedded/ESP-RTOS/esptic/README.md
@@ -0,0 +1,19 @@
+# _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.
diff --git a/embedded/ESP-RTOS/esptic/components/tic2json/CMakeLists.txt b/embedded/ESP-RTOS/esptic/components/tic2json/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c462771
--- /dev/null
+++ b/embedded/ESP-RTOS/esptic/components/tic2json/CMakeLists.txt
@@ -0,0 +1,10 @@
+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()
diff --git a/embedded/ESP-RTOS/esptic/components/tic2json/Kconfig b/embedded/ESP-RTOS/esptic/components/tic2json/Kconfig
new file mode 100644 (file)
index 0000000..f5a36c6
--- /dev/null
+++ b/embedded/ESP-RTOS/esptic/components/tic2json/Kconfig
@@ -0,0 +1,12 @@
+menu "tic2json"
+
+ choice TIC2JSON_TICVERSION
+ bool "TIC version"
+ default TIC2JSON_TICV02
+ config TIC2JSON_TICV01
+ bool "01 (Historique)"
+ config TIC2JSON_TICV02
+ bool "02 (Standard)"
+ endchoice
+
+endmenu
diff --git a/embedded/ESP-RTOS/esptic/components/tic2json/component.mk b/embedded/ESP-RTOS/esptic/components/tic2json/component.mk
new file mode 100644 (file)
index 0000000..e47d39a
--- /dev/null
+++ b/embedded/ESP-RTOS/esptic/components/tic2json/component.mk
@@ -0,0 +1,17 @@
+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
diff --git a/embedded/ESP-RTOS/esptic/components/tic2json/src b/embedded/ESP-RTOS/esptic/components/tic2json/src
new file mode 120000 (symlink)
index 0000000..3efed95
--- /dev/null
+++ b/embedded/ESP-RTOS/esptic/components/tic2json/src
@@ -0,0 +1 @@
+../../../../../
\ No newline at end of file
diff --git a/embedded/ESP-RTOS/esptic/main/CMakeLists.txt b/embedded/ESP-RTOS/esptic/main/CMakeLists.txt
new file mode 100644 (file)
index 0000000..383a2d6
--- /dev/null
+++ b/embedded/ESP-RTOS/esptic/main/CMakeLists.txt
@@ -0,0 +1,3 @@
+set(COMPONENT_SRCS "main.c")
+register_component()
+
diff --git a/embedded/ESP-RTOS/esptic/main/Kconfig b/embedded/ESP-RTOS/esptic/main/Kconfig
new file mode 100644 (file)
index 0000000..6bfe446
--- /dev/null
+++ b/embedded/ESP-RTOS/esptic/main/Kconfig
@@ -0,0 +1,17 @@
+menu "esptic"
+
+config ESPTIC_BAUDRATE
+ int "TIC baudrate"
+ default 9600
+ help
+ TIC standard: 9600
+ TIC historique: 1200
+
+config ESPTIC_UART_NUM
+ int "TIC UART"
+ default 0
+ help
+ UART peripheral to use for TIC input and JSON output
+
+endmenu
+
diff --git a/embedded/ESP-RTOS/esptic/main/component.mk b/embedded/ESP-RTOS/esptic/main/component.mk
new file mode 100644 (file)
index 0000000..44bd2b5
--- /dev/null
+++ b/embedded/ESP-RTOS/esptic/main/component.mk
@@ -0,0 +1,3 @@
+#
+# Main Makefile. This is basically the same as a component makefile.
+#
diff --git a/embedded/ESP-RTOS/esptic/main/main.c b/embedded/ESP-RTOS/esptic/main/main.c
new file mode 100644 (file)
index 0000000..527ca08
--- /dev/null
+++ b/embedded/ESP-RTOS/esptic/main/main.c
@@ -0,0 +1,43 @@
+//
+// 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();
+}
diff --git a/embedded/ESP-RTOS/esptic/sdkconfig.defaults b/embedded/ESP-RTOS/esptic/sdkconfig.defaults
new file mode 100644 (file)
index 0000000..a3a0e21
--- /dev/null
+++ b/embedded/ESP-RTOS/esptic/sdkconfig.defaults
@@ -0,0 +1,2 @@
+CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y
+CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
tic2json TIC parser/converter
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /