Files
ETH_TCP_Demo/app/event_handler.h
2026-03-04 08:50:04 +08:00

64 lines
1.4 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* event_handler.h
*
* Created on: 2026-03-04
* Author: RT-Thread
*
* 功能: 事件处理器模块头文件
* 依赖: RT-Thread Nano, osal, event_queue
* 跨平台适配: 基于RT-Thread Nano使用标准API
*/
#ifndef EVENT_HANDLER_H
#define EVENT_HANDLER_H
#include <rtthread.h>
#include "osal.h"
#include "event_queue.h"
/* 事件处理函数类型 */
typedef int (*event_handler_func_t)(event_t *event, void *user_data);
/* 事件处理器结构体 */
typedef struct {
event_handler_func_t handler; /* 事件处理函数 */
void *user_data; /* 用户数据 */
} event_handler_t;
/**
* @brief 初始化事件处理器
* @return 0 成功非0 失败
*/
int event_handler_init(void);
/**
* @brief 注册事件处理器
* @param type 事件类型
* @param handler 事件处理函数
* @param user_data 用户数据
* @return 0 成功非0 失败
*/
int event_handler_register(event_type_t type, event_handler_func_t handler, void *user_data);
/**
* @brief 注销事件处理器
* @param type 事件类型
* @return 0 成功非0 失败
*/
int event_handler_unregister(event_type_t type);
/**
* @brief 处理事件
* @param event 事件指针
* @return 0 成功非0 失败
*/
int event_handler_process(event_t *event);
/**
* @brief 事件分发线程
* @param parameter 线程参数
*/
void event_dispatch_thread(void *parameter);
#endif /* EVENT_HANDLER_H */