diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-15 15:32:37 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-15 15:32:37 +0200 |
commit | 310a0a145a807706e68200be6cf28f18f6886fd0 (patch) | |
tree | df16110469b0598c88e2b5e59ec6d838d037a012 | |
parent | 8de1733ca506dc7b7d4b66dca1b33c22e76dc855 (diff) |
add arduino code for simulated sensor
-rw-r--r-- | .gitmodules | 5 | ||||
-rw-r--r-- | arduino/.gitignore | 2 | ||||
-rw-r--r-- | arduino/CMakeLists.txt | 26 | ||||
m--------- | arduino/lib/Arduino-CMake-Toolchain | 0 | ||||
-rw-r--r-- | arduino/main.cpp | 14 | ||||
-rw-r--r-- | arduino/makefile | 31 |
6 files changed, 78 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules index 3db31c7..1fecd11 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,3 +3,8 @@ url = https://github.com/beagleboard/linux branch = v6.6.15-ti-rt-arm32-r1 shallow = true +[submodule "arduino/lib/Arduino-CMake-Toolchain"] + path = arduino/lib/Arduino-CMake-Toolchain + url = https://github.com/a9183756-gh/Arduino-CMake-Toolchain + branch = e745a9bed3c3fb83442d55bf05630f31574674f2 + shallow = true diff --git a/arduino/.gitignore b/arduino/.gitignore new file mode 100644 index 0000000..9785597 --- /dev/null +++ b/arduino/.gitignore @@ -0,0 +1,2 @@ +build +.cache diff --git a/arduino/CMakeLists.txt b/arduino/CMakeLists.txt new file mode 100644 index 0000000..a8fa7aa --- /dev/null +++ b/arduino/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.29) + +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_EXPORT_COMPILE_COMMANDS 1) + +# enable debug features +set(CMAKE_BUILD_TYPE Debug) + +# arduino +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/lib/Arduino-CMake-Toolchain/Arduino-toolchain.cmake) +set(ARDUINO_BOARD "Arduino Uno [avr.uno]") + +project(main C CXX) + +add_executable(main + main.cpp + ) + +target_link_arduino_libraries(main + core + Wire + ) + +target_enable_arduino_upload(main) + diff --git a/arduino/lib/Arduino-CMake-Toolchain b/arduino/lib/Arduino-CMake-Toolchain new file mode 160000 +Subproject e745a9bed3c3fb83442d55bf05630f31574674f diff --git a/arduino/main.cpp b/arduino/main.cpp new file mode 100644 index 0000000..e25a2bd --- /dev/null +++ b/arduino/main.cpp @@ -0,0 +1,14 @@ +#include <Arduino.h> +#include <Wire.h> + +void recv() { + Wire.write("foo"); +} + +void setup() { + Wire.begin(0x22); + Wire.onRequest(recv); +} + +void loop() { } + diff --git a/arduino/makefile b/arduino/makefile new file mode 100644 index 0000000..e712b62 --- /dev/null +++ b/arduino/makefile @@ -0,0 +1,31 @@ +BUILD_DIR ?= build +TARGET = $(BUILD_DIR)/main.elf + +CMFLAGS += --fresh +CMFLAGS += --log-level WARNING +CMFLAGS += -Wno-deprecated + +export SERIAL_PORT ?= /dev/ttyACM0 +.PHONY: FORCE + +all: FORCE $(TARGET) + +flash: upload-main; +upload-main: $(TARGET) + +$(BUILD_DIR)/build.ninja: CMakeLists.txt + @mkdir -p $(BUILD_DIR) + @cmake -B $(BUILD_DIR) -G Ninja $(CMFLAGS) + +$(TARGET): $(BUILD_DIR)/build.ninja FORCE + @ninja -C $(BUILD_DIR) + +clean: FORCE + $(RM) -r $(BUILD_DIR) + +# Forward any unknown targets to Ninja +ifneq ($(MAKECMDGOALS),) +%:: + @ninja -C $(BUILD_DIR) $@ +endif + |