gennrally ++. , , , , . , , ( ), .
. , state.h:
enum state {
ST_UNINITIALIZED = 0x01,
ST_INITIALIZED = 0x02,
ST_OPENED = 0x03,
ST_UNBLOCKED = 0x04,
ST_DISPOSED = 0x05
};
statemachine.h :
#ifndef STATEMACHINE_H_INCLUDED
#define STATEMACHINE_H_INCLUDED
#include "port.h"
#include "state.h"
void state_machine(event evt, port_t *port);
#endif
port.h:
#ifndef PORT_H_INCLUDED
#define PORT_H_INCLUDED
#include <stdio.h>
#include "state.h"
typedef struct port_tag port_t;
struct port_tag {
state current_state;
.
.
};
#endif
, , .