From f1f146c887d476b37fe66e1164f89fea95143e74 Mon Sep 17 00:00:00 2001 From: Daniel Nakhooda Date: Sun, 9 Nov 2025 17:02:38 -0500 Subject: [PATCH] testing stuff --- CMakeLists.txt | 1 + Core/Inc/u_test.h | 11 +++++++++++ Core/Src/u_test.c | 12 ++++++++++++ Core/Src/u_threads.c | 8 ++++++++ 4 files changed, 32 insertions(+) create mode 100644 Core/Inc/u_test.h create mode 100644 Core/Src/u_test.c diff --git a/CMakeLists.txt b/CMakeLists.txt index ce53ecf..8164f86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,7 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE "../Drivers/Embedded-Base/general/src/lis2mdl_reg.c" # Core + "./Core/Src/u_test.c" "./Core/Src/u_inbox.c" "./Core/Src/u_sensors.c" "./Core/Src/u_threads.c" diff --git a/Core/Inc/u_test.h b/Core/Inc/u_test.h new file mode 100644 index 0000000..eaca6c2 --- /dev/null +++ b/Core/Inc/u_test.h @@ -0,0 +1,11 @@ +#ifndef __TEST_H +#define __TEST_H + +#include "u_statemachine.h" + +/** + * @brief Randomly sets the state of the State Machine + */ +void gpio_test(); + +#endif /* u_test.h */ \ No newline at end of file diff --git a/Core/Src/u_test.c b/Core/Src/u_test.c new file mode 100644 index 0000000..d1f74a8 --- /dev/null +++ b/Core/Src/u_test.c @@ -0,0 +1,12 @@ +#include + +#include "u_test.h" + +void gpio_test() { + int value = rand() % 3; + int status = set_statemachine((Lightning_Board_Light_Status) value); + + if (status != U_SUCCESS) { + PRINTLN_INFO("Failed to set State in GPIO Test"); + } +} \ No newline at end of file diff --git a/Core/Src/u_threads.c b/Core/Src/u_threads.c index 5930a56..69bbb8f 100644 --- a/Core/Src/u_threads.c +++ b/Core/Src/u_threads.c @@ -7,6 +7,9 @@ #include "bitstream.h" #include "u_statemachine.h" #include "u_mutexes.h" +#include "u_test.h" + +#define TEST_MODE 1 /* Default Thread */ static thread_t _default_thread = { @@ -129,6 +132,7 @@ static thread_t _gpio_lights_thread = { .function = gpio_lights_thread /* Thread Function */ }; void gpio_lights_thread(ULONG thread_input) { + while (1) { Lightning_Board_Light_Status state = get_current_state(); @@ -151,6 +155,10 @@ void gpio_lights_thread(ULONG thread_input) { } tx_thread_sleep(_gpio_lights_thread.sleep); + + #if TEST_MODE + gpio_test(); + #endif } }