1 Star 3 Fork 2

GuanGuan/状态机源码

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
StateMachine.h 885 Bytes
一键复制 编辑 原始数据 按行查看 历史
GuanGuan 提交于 2022-11-08 15:35 +08:00 . 状态机源码
#ifndef _StateMachine_H
#define _StateMachine_H
#include <stdint.h>
typedef enum
{
SM_EVENT_ENTER = 0, //初始化事件
SM_EVENT_EXEC, //执行事件
SM_EVENT_EXIT, //退出状态机
}smEventState;
typedef struct _smEvent_t
{
uint8_t id; //时间id,必须唯一
uint8_t nextEventId; //下个事件的id号
smEventState curState; //当前事件状态
void (*Action)(struct _smEvent_t* thisEvent); //执行函数的指针
}smEvent_t;
typedef struct
{
uint8_t curEventId; //当前时间号
uint8_t eventListCount; //事件个数
smEvent_t* eventList; //事件表
}smCore_t;
void SmEventInit(smEvent_t* pEvent,void (*Action)(smEvent_t *thisEvent), uint8_t eventId);
void SmInit(smCore_t* pSM, smEvent_t* list, uint8_t eventCount);
void SmProcess(smCore_t* pSM);
void SmSetNextEvent(smEvent_t* event, uint8_t nextEventId);
#endif // ! _StateMachine_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/guanmingweiabc/state-machine-source-code.git
git@gitee.com:guanmingweiabc/state-machine-source-code.git
guanmingweiabc
state-machine-source-code
状态机源码
master

搜索帮助