task setup
This commit is contained in:
@@ -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})
|
||||
|
||||
40
Application/Tasks/LightState.c
Normal file
40
Application/Tasks/LightState.c
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
7
Application/Tasks/LightState.h
Normal file
7
Application/Tasks/LightState.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef LIGHT_STATE_H
|
||||
#define LIGHT_STATE_H
|
||||
|
||||
// Function to start the LightStateTask
|
||||
void LightStateTask_start();
|
||||
|
||||
#endif // LIGHT_STATE_H
|
||||
Reference in New Issue
Block a user