bs_bcu_app/bsp/bsp_task.h

82 lines
1.8 KiB
C

#ifndef _BMS_TASK_H_
#define _BMS_TASK_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "kit_macro.h"
#include "os.h"
#define OS_MAX_TASKS 100
typedef struct _TaskArray
{
uint16_t task_id;
OS_TCB *task_tcb;
OS_PRIO task_prio;//优先级
uint16_t task_period;//执行时间
uint16_t wdog_timeout;
uint16_t wdog_tick;
uint16_t stk_size;
NoArgCall init;
UintArgCall task;
CPU_INT32U *stk_array;
struct _TaskArray *next_task;
bool is_time_out;
}TaskArray;
#define TASK_STATIC_INIT(_name,_idx, _prio,_period, _timeout,_init_call, _task_call, stack_size) \
OS_STK stack_##_name[stack_size]; \
OS_TCB tcb_##_name[1];\
TaskArray _name = \
{ \
(_idx), \
tcb_##_name, \
(_prio), \
(_period), \
(_timeout), \
0, \
stack_size, \
_init_call, \
_task_call, \
stack_##_name, \
NULL, \
false, \
}\
#define TASK_STATIC_INIT_CCM(_name,_idx, _prio,_period, _timeout,_init_call, _task_call, stack_size) \
CPU_STK stack_##_name[stack_size] __attribute__((section (".CCM_RAM"))); \
OS_TCB tcb_##_name[1] __attribute__((section (".CCM_RAM")));;\
TaskArray _name = \
{ \
(_idx), \
tcb_##_name, \
(_prio), \
(_period), \
(_timeout), \
0, \
stack_size, \
_init_call, \
_task_call, \
stack_##_name, \
NULL, \
false, \
}\
void bsp_task_beat_wdog(void);
void bsp_task_feed_wdog(uint32_t tick);
uint32_t bsp_task_delay_ms(uint32_t dly);
void bsp_task_set_timeout_call(UintArgCall call);
KitResult bsp_task_creat(TaskArray* task, uint8_t * name);
uint16_t bsp_task_get_max_wdog_tick(uint8_t task_id);
#ifdef __cplusplus
}
#endif
#endif