1 /* 2 * Copyright (c) 2009-2022 Huawei Technologies Co., Ltd. All rights reserved. 3 * 4 * UniProton is licensed under Mulan PSL v2. 5 * You can use this software according to the terms and conditions of the Mulan PSL v2. 6 * You may obtain a copy of Mulan PSL v2 at: 7 * http://license.coscl.org.cn/MulanPSL2 8 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 9 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 10 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 11 * See the Mulan PSL v2 for more details. 12 * Create: 2009-12-22 13 * Description: 硬件定时器模块的内部头文件 14 */ 15 #ifndef PRT_TIMER_EXTERNAL_H 16 #define PRT_TIMER_EXTERNAL_H 17 18 #include "prt_timer.h" 19 20 /* 21 * 模块间typedef声明 22 */ 23 typedef U32(*TimerCreateFunc)(struct TimerCreatePara *createPara, TimerHandle *tmrHandle); 24 25 typedef U32(*TimerStartFunc)(TimerHandle timerHdl); 26 27 typedef U32(*TimerStopFunc)(TimerHandle timerHdl); 28 29 typedef U32(*TimerDeleteFunc)(TimerHandle timerHdl); 30 31 typedef U32(*TimerRestartFunc)(TimerHandle timerHdl); 32 33 typedef U32(*TimerSetIntervalFunc)(TimerHandle timerHdl, U32 interVal); 34 35 typedef U32(*TimerQueryFunc)(TimerHandle timerHdl, U32 *expireTime); 36 37 /* 定时器函数库 */ 38 struct TagFuncsLibTimer { 39 TimerCreateFunc createTimer; 40 TimerStartFunc startTimer; 41 TimerStopFunc stopTimer; 42 TimerDeleteFunc deleteTimer; 43 TimerRestartFunc restartTimer; 44 TimerSetIntervalFunc setIntervalTimer; 45 TimerQueryFunc timerQuery; 46 }; 47 48 /* 定时器类型 */ 49 enum { 50 TIMER_TYPE_HWTMR, /* 核内私有硬件定时器 */ 51 TIMER_TYPE_SWTMR, /* 软件定时器 */ 52 TIMER_TYPE_INVALID 53 }; 54 55 /* 56 * 模块间全局变量声明 57 */ 58 extern struct TagFuncsLibTimer g_timerApi[TIMER_TYPE_INVALID]; 59 60 #define OS_SWTMR_PRE_FREE 0x40 /* 在软件定时器超时状态下进行删除操作,定时器进入预free态 */ 61 #define OS_SWTMR_PRE_CREATED 0x80 /* 在软件定时器超时状态下进行停止操作,定时器进入预created态 */ 62 #define OS_SWTMR_PRE_RUNNING 0xc0 /* 在软件定时器超时状态下进行删除操作,定时器进入预running态 */ 63 64 #define OS_TIMER_PRE_FREE (OS_SWTMR_PRE_FREE | (U8)OS_TIMER_EXPIRED) 65 #define OS_TIMER_PRE_CREATED (OS_SWTMR_PRE_CREATED | (U8)OS_TIMER_EXPIRED) 66 #define OS_TIMER_PRE_RUNNING (OS_SWTMR_PRE_RUNNING | (U8)OS_TIMER_EXPIRED) 67 68 /* 69 * timerHandle : timeType | timerIndex 70 * [31...28] | [27...28] 71 * timeType : 0, TIMER_TYPE_HWTMR 72 * timeType : 1, TIMER_TYPE_SWTMR 73 * 74 */ 75 #define OS_TIMER_GET_HANDLE(type, index) (((type) << 28) | (index)) 76 #define OS_TIMER_GET_INDEX(handle) ((handle) & 0x0FFFFFFFU) 77 #define OS_TIMER_GET_TYPE(handle) ((handle) >> 28) 78 79 #endif /* PRT_TIMER_EXTERNAL_H */ 80