diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-25 12:23:01 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-25 12:23:01 +0200 |
commit | be1b5f0d35544582be1f4fa42aed303184ab27a7 (patch) | |
tree | 7f9bb0714ba02ce195d9fdebe7b56bee819456d3 /puzzle/smoketest | |
parent | 18e5d93da8fdf6dd97c9e2d090ae2648d85cb851 (diff) | |
parent | f594d070418a3b2be6e5c08068f969e8793315ba (diff) |
Merge branch 'prot/smoketest'
Diffstat (limited to 'puzzle/smoketest')
-rw-r--r-- | puzzle/smoketest/CMakeLists.txt | 41 | ||||
-rw-r--r-- | puzzle/smoketest/FreeRTOSConfig.h | 52 | ||||
-rw-r--r-- | puzzle/smoketest/index.dox | 11 | ||||
l--------- | puzzle/smoketest/lib | 1 | ||||
-rw-r--r-- | puzzle/smoketest/main.cpp | 28 | ||||
-rw-r--r-- | puzzle/smoketest/makefile | 8 | ||||
-rw-r--r-- | puzzle/smoketest/mod.c | 6 |
7 files changed, 147 insertions, 0 deletions
diff --git a/puzzle/smoketest/CMakeLists.txt b/puzzle/smoketest/CMakeLists.txt new file mode 100644 index 0000000..b71825f --- /dev/null +++ b/puzzle/smoketest/CMakeLists.txt @@ -0,0 +1,41 @@ +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) +add_compile_definitions(DEBUG) + +# arduino +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/lib/Arduino-CMake-Toolchain/Arduino-toolchain.cmake) +# set(ARDUINO_BOARD "Arduino Mega or Mega 2560 [avr.mega]") +set(ARDUINO_BOARD "Arduino Uno [avr.uno]") + +# freertos +add_library(freertos_config INTERFACE) +target_include_directories(freertos_config SYSTEM INTERFACE .) +set(FREERTOS_PORT GCC_ATMEGA) +set(FREERTOS_HEAP 4) + +project(pb_mod_smoketest C CXX) + +add_subdirectory(lib/pbdrv) +add_subdirectory(lib/FreeRTOS-Kernel) + +add_executable(main + main.cpp + mod.c + ) + +target_link_libraries(main PUBLIC + pbdrv-mod + ) +target_link_arduino_libraries(main PUBLIC + core + Wire + ) + +target_enable_arduino_upload(main) + diff --git a/puzzle/smoketest/FreeRTOSConfig.h b/puzzle/smoketest/FreeRTOSConfig.h new file mode 100644 index 0000000..81c487f --- /dev/null +++ b/puzzle/smoketest/FreeRTOSConfig.h @@ -0,0 +1,52 @@ +#pragma once + +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configMAX_PRIORITIES 32 +#define configMINIMAL_STACK_SIZE ((configSTACK_DEPTH_TYPE) 192) +#define configUSE_16_BIT_TICKS 1 +#define configIDLE_SHOULD_YIELD 1 +#define configUSE_MUTEXES 1 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_APPLICATION_TASK_TAG 0 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configQUEUE_REGISTRY_SIZE 8 +#define configUSE_QUEUE_SETS 0 +#define configUSE_TIME_SLICING 1 +#define configSTACK_DEPTH_TYPE uint16_t +#define configSUPPORT_STATIC_ALLOCATION 0 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +// #define configTOTAL_HEAP_SIZE (1024) +#define configTOTAL_HEAP_SIZE (1 * 1024) +#define configCHECK_FOR_STACK_OVERFLOW 0 +#define configUSE_MALLOC_FAILED_HOOK 0 +#define configUSE_DAEMON_TASK_STARTUP_HOOK 0 +#define configGENERATE_RUN_TIME_STATS 0 +#define configUSE_TRACE_FACILITY 0 +#define configUSE_STATS_FORMATTING_FUNCTIONS 0 +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) +#define configTIMER_QUEUE_LENGTH 10 +#define configTIMER_TASK_STACK_DEPTH 92 + +#include <assert.h> +#define configASSERT(x) assert(x) + +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_xTaskGetCurrentTaskHandle 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#define INCLUDE_xTaskGetIdleTaskHandle 1 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_xTimerPendFunctionCall 1 +#define INCLUDE_xTaskAbortDelay 1 +#define INCLUDE_xTaskGetHandle 1 +#define INCLUDE_xTaskResumeFromISR 1 +#define INCLUDE_xQueueGetMutexHolder 1 + diff --git a/puzzle/smoketest/index.dox b/puzzle/smoketest/index.dox new file mode 100644 index 0000000..15eae1f --- /dev/null +++ b/puzzle/smoketest/index.dox @@ -0,0 +1,11 @@ +// vim:ft=doxygen +/** +\ingroup puz +\defgroup puz_vault Vault +\brief Vault puzzle module + +\par Setup +- Use the Arduino IDE library manager to install the "TM1637" library (by + Avishay Orpaz) and its dependencies + +*/ diff --git a/puzzle/smoketest/lib b/puzzle/smoketest/lib new file mode 120000 index 0000000..58677dd --- /dev/null +++ b/puzzle/smoketest/lib @@ -0,0 +1 @@ +../../lib
\ No newline at end of file diff --git a/puzzle/smoketest/main.cpp b/puzzle/smoketest/main.cpp new file mode 100644 index 0000000..dc15e5f --- /dev/null +++ b/puzzle/smoketest/main.cpp @@ -0,0 +1,28 @@ +#include <Arduino.h> +#include "lib/pbdrv/pb-types.h" +#include "lib/pbdrv/pb-mod.h" + +#define EXTERNAL_LED_PIN 13 +#define BUTTON_PIN 10 // Define the pin where the external button is connected + +pb_global_state_t state = PB_GS_NOINIT; + +void setup() { + pinMode(EXTERNAL_LED_PIN, OUTPUT); + pinMode(BUTTON_PIN, INPUT_PULLUP); +} + +pb_global_state_t pb_hook_mod_state_read() { + return state; +} + +void pb_hook_mod_state_write(pb_global_state_t _state) { + state = _state; +} + +void loop() { + digitalWrite(EXTERNAL_LED_PIN, state == PB_GS_PLAYING); + + if (!digitalRead(BUTTON_PIN)) return; + state = PB_GS_SOLVED; +} diff --git a/puzzle/smoketest/makefile b/puzzle/smoketest/makefile new file mode 100644 index 0000000..6b8341b --- /dev/null +++ b/puzzle/smoketest/makefile @@ -0,0 +1,8 @@ +TARGET = $(BUILD_DIR)/main.elf + +include ../../lazy.mk + +export SERIAL_PORT ?= /dev/ttyACM0 +flash: upload; +upload: $(TARGET) + diff --git a/puzzle/smoketest/mod.c b/puzzle/smoketest/mod.c new file mode 100644 index 0000000..bae8a3d --- /dev/null +++ b/puzzle/smoketest/mod.c @@ -0,0 +1,6 @@ +#include "pb.h" +#include "pb-mod.h" + +const char * PB_MOD_NAME = "vault"; +const i2c_addr_t PB_MOD_ADDR = PB_ADDR_MOD_VAULT; + |