This repository has been archived on 2025-01-02. You can view files and clone it, but cannot push or open issues or pull requests.
torsion/User/app_flow.c

60 lines
1.3 KiB
C

#include "main.h"
#include "app.h"
#include "flow.h"
#include "sys.h"
#include "delay.h"
#include "board.h"
extern __IO app_t app;
extern motor_t *motor;
static struct flow fl_adc_inspection; // ADC
static struct flow fl_systom_inspection; // 系统
static struct flow idle_tm; // 空闲任务
static uint8_t adc_inspection(struct flow *fl)
{
FL_HEAD(fl);
for (;;)
{
app.adc.torsion_in13.original_value = adc_get_result_average(IN13);
FL_LOCK_DELAY(fl, FL_CLOCK_100MSEC); /* 延时100毫秒 */
}
FL_TAIL(fl);
}
static uint8_t systom_inspection(struct flow *fl)
{
FL_HEAD(fl);
for (;;)
{
FL_LOCK_DELAY(fl, FL_CLOCK_100MSEC); /* 延时100毫秒 */
}
FL_TAIL(fl);
}
static uint8_t idle_inspection(struct flow *fl)
{
FL_HEAD(fl);
for (;;)
{
cpu_percent = scheduler_time_occupancy_get(1000);
FL_LOCK_DELAY(fl, FL_CLOCK_SEC);
}
FL_TAIL(fl);
}
void flow_start(void)
{
adc_inspection(&fl_adc_inspection); // adc检测
systom_inspection(&fl_systom_inspection); // 系统检测
idle_inspection(&idle_tm); // 空闲任务用来计算CPU占用率
}
void flow_init(void)
{
FL_INIT(&fl_adc_inspection);
FL_INIT(&fl_systom_inspection);
FL_INIT(&idle_tm);
}