From e995e1bd01a2961a1e0a50e7b3c086fa1e37cce2 Mon Sep 17 00:00:00 2001 From: Oliver Walter Date: Sat, 18 May 2024 02:46:47 +0200 Subject: [PATCH] task setup --- Application/Tasks/CMakeLists.txt | 2 ++ Application/Tasks/LightState.c | 40 ++++++++++++++++++++++++++++++++ Application/Tasks/LightState.h | 7 ++++++ 3 files changed, 49 insertions(+) create mode 100644 Application/Tasks/LightState.c create mode 100644 Application/Tasks/LightState.h diff --git a/Application/Tasks/CMakeLists.txt b/Application/Tasks/CMakeLists.txt index 897c7a8..8a8de14 100644 --- a/Application/Tasks/CMakeLists.txt +++ b/Application/Tasks/CMakeLists.txt @@ -11,11 +11,13 @@ target_sources(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/FirmwareHandler.c ${CMAKE_CURRENT_LIST_DIR}/FirmwareUpdate.c ${CMAKE_CURRENT_LIST_DIR}/LightTask.c + ${CMAKE_CURRENT_LIST_DIR}/LightState.c INTERFACE ${CMAKE_CURRENT_LIST_DIR}/UsbDataHandler.h ${CMAKE_CURRENT_LIST_DIR}/CanDataTask.h ${CMAKE_CURRENT_LIST_DIR}/FirmwareUpdate.h ${CMAKE_CURRENT_LIST_DIR}/LightTask.h + ${CMAKE_CURRENT_LIST_DIR}/LightState.h ) target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR}) diff --git a/Application/Tasks/LightState.c b/Application/Tasks/LightState.c new file mode 100644 index 0000000..f6eca4a --- /dev/null +++ b/Application/Tasks/LightState.c @@ -0,0 +1,40 @@ +#include "cmsis_os2.h" +#include "LightState.h" +#include "BSP_GPIO.h" +#include "BSP_INA.h" + + +// Create the task with a specific priority and stack size +osThreadAttr_t task_attr = { + .name = "LightStateTask", + .priority = osPriorityNormal, + .stack_size = 1024 +}; + +// Function prototype for the task function +void LightStateTask(void *argument); + +// Function to start the LightStateTask +void LightStateTask_start(void) +{ + osThreadNew(LightStateTask, NULL, &task_attr); +} + +// Task function +void LightStateTask(void *argument) +{ + // Infinite loop to keep the task running + while (1) + { + // default state + int next_state = 0; + + // check if k15 is on + + + + + // Delay the task for a certain amount of time (in milliseconds) + osDelay(500); + } +} \ No newline at end of file diff --git a/Application/Tasks/LightState.h b/Application/Tasks/LightState.h new file mode 100644 index 0000000..c90f7a1 --- /dev/null +++ b/Application/Tasks/LightState.h @@ -0,0 +1,7 @@ +#ifndef LIGHT_STATE_H +#define LIGHT_STATE_H + +// Function to start the LightStateTask +void LightStateTask_start(); + +#endif // LIGHT_STATE_H \ No newline at end of file