1 /* 2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef __FRW_TIMER_H__ 20 #define __FRW_TIMER_H__ 21 22 /* *************************************************************************** 23 1 其他头文件包含 24 **************************************************************************** */ 25 #include "frw_event.h" 26 #include "oal_ext_if.h" 27 #include "oam_ext_if.h" 28 29 #ifdef __cplusplus 30 #if __cplusplus 31 extern "C" { 32 #endif 33 #endif 34 35 /* **************************************************************************** 36 2 宏定义 37 **************************************************************************** */ 38 typedef hi_u32 (*frw_timeout_func)(hi_void *); 39 40 /* **************************************************************************** 41 3 枚举定义 42 **************************************************************************** */ 43 /* **************************************************************************** 44 4 全局变量声明 45 **************************************************************************** */ 46 /* **************************************************************************** 47 5 消息头定义 48 **************************************************************************** */ 49 /* **************************************************************************** 50 6 消息定义 51 **************************************************************************** */ 52 /* **************************************************************************** 53 7 STRUCT定义 54 **************************************************************************** */ 55 typedef struct { 56 hi_u32 handle; 57 hi_void *timeout_arg; /* 超时处理函数入参 */ 58 frw_timeout_func func; /* 超时处理函数 */ 59 hi_u32 time_stamp; /* 定时器启动时间 */ 60 hi_u32 timeout; /* 过多长时间定时器超时 */ 61 hi_u32 timer_id; /* 定时器唯一标识 */ 62 hi_u8 is_deleting; /* 是否需要删除 */ 63 hi_u8 is_registerd; /* 定时器是否已经注册 */ 64 hi_u8 is_periodic; /* 定时器是否为周期的 */ 65 hi_u8 is_enabled :4; /* 定时器是否使能 */ 66 hi_u8 is_running :4; 67 oal_timer_list_stru timer; 68 hi_list entry; /* 定时器链表索引 */ 69 }frw_timeout_stru; 70 71 /* **************************************************************************** 72 8 UNION定义 73 **************************************************************************** */ 74 /* **************************************************************************** 75 9 OTHERS定义 76 **************************************************************************** */ 77 /* **************************************************************************** 78 10 函数声明 79 **************************************************************************** */ 80 hi_void frw_timer_init(hi_void); 81 #ifdef _PRE_HDF_LINUX 82 hi_void frw_timer_timeout_proc_event(oal_timer_list_stru *arg); 83 #else 84 hi_void frw_timer_timeout_proc_event(unsigned long arg); 85 #endif 86 hi_void frw_timer_create_timer(frw_timeout_stru *timeout, 87 frw_timeout_func timeout_func, 88 hi_u32 timeoutval, 89 hi_void *timeout_arg, 90 hi_u8 is_periodic); 91 hi_void frw_timer_immediate_destroy_timer(frw_timeout_stru *timeout); 92 hi_void frw_timer_restart_timer(frw_timeout_stru *timeout, 93 hi_u32 timeoutval, 94 hi_u8 is_periodic); 95 hi_void frw_timer_stop_timer(frw_timeout_stru *timeout); 96 hi_void frw_timer_delete_all_timer(hi_void); 97 98 #ifdef __cplusplus 99 #if __cplusplus 100 } 101 #endif 102 #endif 103 104 #endif /* end of frw_timer.h */ 105