motor_cs103/User/application/app.c

69 lines
1.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "app.h"
#include "board.h"
#include "flow.h"
static struct flow business_fw; // 业务流程
static struct flow idle_fw; // 空闲任务
app_t app;
static uint8_t business_inspection(struct flow *fl)
{
FL_HEAD(fl);
for (;;)
{
FL_LOCK_DELAY(fl, FL_CLOCK_100MSEC);
}
FL_TAIL(fl);
}
/**
* @brief 对流量进行空闲检查
*
* 该函数会对传入的流量结构体进行空闲检查。
*
* @param fl 指向流量结构体的指针
*
* @return 返回值始终为0该函数不返回实际值
*/
static uint8_t idle_inspection(struct flow *fl)
{
FL_HEAD(fl);
for (;;)
{
GPIO_TOGGLE(LED_BLUE_GPIO_Port, LED_BLUE_Pin);
FL_LOCK_DELAY(fl, FL_CLOCK_SEC);
}
FL_TAIL(fl);
}
/**
* @brief 运行应用程序
*
* 该函数用于启动应用程序的运行。
*
* @details 此函数会调用 idle_inspection 函数,传入 idle_fw 作为参数。
* idle_inspection 函数的具体作用需参考其实现细节。
*/
void app_run(void)
{
business_inspection(&business_fw); // 业务流程检测
idle_inspection(&idle_fw);
}
/**
* @brief 初始化应用程序
*
* 初始化应用程序,包括启动空闲任务。
*/
void app_init(void)
{
FL_INIT(&business_fw); // 业务流程
FL_INIT(&idle_fw); // 空闲任务
ENABLE_TIM(TASK_TIM);
ENABLE_TIM(WORK_TIM);
}