3 void init_fsm(struct fsm *fsm, state_fcn initial_state)
5 fsm->current_state = initial_state;
6 fsm->current_state(fsm, EVENT_ENTRY);
9 void run_fsm(struct fsm *fsm){
10 fsm->last_state = fsm->current_state; // set actual state
11 fsm->current_state(fsm, EVENT_DO); // change parameter
13 if(fsm->last_state != fsm->current_state){ // if state was changed
14 fsm->last_state(fsm, EVENT_EXIT); // finish the old state
15 fsm->current_state(fsm, EVENT_ENTRY); // initialize the new state