b_mod_state
此功能模块提供给用户进行应用的开发:
状态:进入状态时执行的函数、在此状态下执行的函数、离开状态时执行的函数
事件:每个状态可附加一个事件表:事件&事件处理函数
数据结构
typedef void (*pStateEvenHandler_t)(uint32_t event, void *arg);
typedef void (*pStateEnterHandler_t)(uint32_t pre_state);
typedef void (*pStateExitHandler_t)(void);
typedef void (*pStateHandler_t)(void);
typedef struct
{
uint32_t event;
pStateEvenHandler_t handler;
} bStateEvent_t;
typedef struct
{
bStateEvent_t *p_event_table;
uint32_t number;
} bStateEventTable_t;
typedef struct
{
uint32_t state;
pStateEnterHandler_t enter;
pStateExitHandler_t exit;
pStateHandler_t handler;
bStateEventTable_t event_table;
} bStateInfo_t;
接口介绍
#define bSTATE_REG_INSTANCE(state_info) //注册状态信息
int bStateTransfer(uint32_t state); //切换状态
int bStateInvokeEvent(uint32_t event, void *arg); //触发事件
int bGetCurrentState(void); //获取当前状态