Files
youled63d_bluetooth/project/example/ble/ble_peripheral/app/src/timeslice.c
T
moyuhai 966451d245 V1.0
2026-06-11 13:04:09 +08:00

81 lines
2.6 KiB
C

#ifndef _TIMESLICE_C_
#define _TIMESLICE_C_
/*********************************************************************************************************************/
#include "timeslice.h"
#include "stdint.h"
#include "uart.h"
#include "xc_drv_uart.h"
#include "rgblight.h"
#include "timer.h"
/*********************************************************************************************************************/
void rwip_schedule(void);
TASK_COMPONENTS TaskComps[] =
{
{0, 1, 1,rwip_schedule}, //协议栈调度任务
{0, 2, 2, ble_message_process}, //蓝牙处理任务
{0, 5, 5, uar_rdate}, //向手机发送数据
// {0, 25, 25, pga_mic_adc_get_val_demo},// 麦克风采集任务
// {0, 100, 100, ir_message_process}, // 红外遥控处理任务
// {0, 50, 50, app_key_scan},// 按键检测任务
// {0, 300, 300, xc_ota_schedule}, //保存flash数据任务
// {0, 300, 300, app_op_flash}, //保存flash数据数据任务
// {0, 0, 0, app_op_flash_on}, //保存flash数据数据任务
// {0, 60000, 60000, timer_off}, //定时关机任务
// {0, 30000, 30000, auto_mode_add}, //自动循环任务,30s周期
};
/**************************************************************************************
* FunctionName : TaskRemarks()
* Description : 任务标志处理
* EntryParameter : None
* ReturnValue : None
**************************************************************************************/
void TaskRemarks(void)
{
unsigned char i;
for (i=0; i<TASKS_MAX; i++) // 逐个任务时间处理
{
if (TaskComps[i].Timer) // 时间不为0
{
TaskComps[i].Timer--; // 减去一个节拍
if (TaskComps[i].Timer == 0) // 时间减完了
{
TaskComps[i].Timer = TaskComps[i].ItvTime; // 恢复计时器值,从新下一次
TaskComps[i].Run = 1; // 任务可以运行
}
}
}
}
/**************************************************************************************
* FunctionName : TaskProcess()
* Description : 任务处理
* EntryParameter : None
* ReturnValue : None
**************************************************************************************/
void TaskProcess(void)
{
unsigned char i;
for (i=0; i<TASKS_MAX; i++) // 逐个任务时间处理
{
if (TaskComps[i].Run) // 时间不为0
{
TaskComps[i].Run = 0; // 标志清0
TaskComps[i].TaskHook(); // 运行任务
}
}
}
void set_TaskComps_timer(uint8_t index,uint16_t value)
{
TaskComps[index].Timer = value;
}
/*********************************************************************************************************************/
#endif