简单状态机
2015-09-29 14:21 NJSEU 阅读(213) 评论(0) 编辑 收藏 举报typedef enum _states
{
UPDATE_STATUS = 1,
CMD_INPUT,
CHECK,
DONE
}Tstates;
typedef Tstates(*Procedure) (void);
Tstates cur_state;
Tstates fsm_update_state(void)
{
return CMD_INPUT;
};
Tstates fsm_cmd_input(void)
{
return CHECK;
};
Tstates fsm_check(void)
{
return DONE;
};
Procedure Steps[] =
{
fsm_update_state,
fsm_cmd_input,
fsm_check,
};
void UT_FSM(void)
{
cur_state = UPDATE_STATUS;
while(DONE != cur_state)
{
cur_state = Steps[cur_state]();
}
}
http://www.360doc.com/content/11/1116/19/2660674_164890407.shtml#