110 lines
2.3 KiB
C
110 lines
2.3 KiB
C
#include "CanDataHandler.h"
|
|
#include "cmsis_os2.h"
|
|
#include "FreeRTOS.h"
|
|
|
|
|
|
// Memory for the task
|
|
StaticTask_t CLS_FW_Task_cb;
|
|
uint32_t CLS_FW_Task_stk[512];
|
|
// Attributes for the task
|
|
osThreadId_t CLS_FW_Task_id;
|
|
const osThreadAttr_t CLS_FW_Task_attr = {
|
|
.name = "CLS_FW_Task",
|
|
.attr_bits = 0U,
|
|
.cb_mem = &CLS_FW_Task_cb,
|
|
.cb_size = sizeof(CLS_FW_Task_cb),
|
|
.stack_mem = CLS_FW_Task_stk,
|
|
.stack_size = sizeof(CLS_FW_Task_stk),
|
|
.priority = osPriorityNormal,
|
|
.reserved = 0U
|
|
};
|
|
|
|
void wait_for_start_callback() {
|
|
osThreadFlagsSet(CLS_FW_Task_id, 1);
|
|
}
|
|
|
|
void wait_for_start_enter() {
|
|
// CanData_regEventMsg(...) // wait_for_start_callback // MessageCode::Firmware(FirmwareChannel::SlaveOutMasterIn);
|
|
}
|
|
|
|
|
|
void wait_for_start() {
|
|
//osWaitForNotify // add timeout with eeror
|
|
//wait_for_start_exit()
|
|
//goto running
|
|
}
|
|
|
|
void wait_for_start_exit() {
|
|
//CanData_removeEvent(...)
|
|
//f_lseek(&SDFile,0); or Open file
|
|
// frame.counter = 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
void running_callback_error() {
|
|
// lock the file
|
|
// reset the file
|
|
// reset the packcount
|
|
// unlock the filec
|
|
}
|
|
|
|
void running_callback_ack() {
|
|
//osNotify
|
|
}
|
|
|
|
void running_enter() {
|
|
// CanData_regEventMsg(...) // running_callback_error // MessageCode::Firmware(FirmwareChannel::SlaveOutMasterIn);
|
|
// CanData_regEventMsg(...) //running_callback_ack // MessageCode::Firmware(FirmwareChannel::SlaveFeedback);
|
|
}
|
|
|
|
|
|
void running() {
|
|
|
|
//4x
|
|
// -- read file upto 4 bytes
|
|
// -- send bytes can
|
|
// -- if eof -> exit()
|
|
// wait for Notify ack and repeat ^^
|
|
|
|
}
|
|
|
|
void running_exit() {
|
|
// send DONE PACK
|
|
|
|
//CanData_removeEvent(...)
|
|
//CanData_removeEvent(...)
|
|
|
|
// we are done task exit
|
|
}
|
|
|
|
|
|
typedef struct {
|
|
char name[16];
|
|
uint8_t device;
|
|
} CLSFirmwareUpdateArgs;
|
|
|
|
void CLSFirmwareUpdateTask_func(void *argument);
|
|
|
|
void CLSFirmwareUpdateTask_start(CLSFirmwareUpdateArgs args) {
|
|
// Task functionality here
|
|
|
|
// check CLS_FW_Task_id is null or stopped
|
|
// osThreadGetState
|
|
CLS_FW_Task_id = osThreadNew(CLSFirmwareUpdateTask_func, NULL, &CLS_FW_Task_attr);
|
|
}
|
|
|
|
|
|
void CLSFirmwareUpdateTask_func(void *argument) {
|
|
|
|
wait_for_start_enter();
|
|
wait_for_start();
|
|
wait_for_start_exit();
|
|
|
|
running_enter();
|
|
running();
|
|
running_exit();
|
|
|
|
osThreadExit();
|
|
} |