• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: Tick interrupt implementation
14  */
15 #include "prt_tick_internal.h"
16 
17 /* Tick中断对应的硬件定时器ID */
18 OS_SEC_L4_DATA U16 g_tickHwTimerIndex = OS_MAX_U16;
19 OS_SEC_BSS U32 g_cyclePerTick;
20 
21 /*
22  * 描述:注册Tick中断模块信息
23  */
OsTickRegister(struct TickModInfo * modInfo)24 OS_SEC_L4_TEXT U32 OsTickRegister(struct TickModInfo *modInfo)
25 {
26     g_tickModInfo.tickPerSecond = modInfo->tickPerSecond;
27     g_tickModInfo.tickPriority = modInfo->tickPriority;
28 
29     return OS_OK;
30 }
31 
32 /*
33  * 描述:Tick中断的处理函数
34  */
OsTickHookDispatcher(void)35 OS_SEC_L0_TEXT void OsTickHookDispatcher(void)
36 {
37     OS_MHOOK_ACTIVATE_PARA0(OS_HOOK_TICK_ENTRY);
38     OsTickDispatcher();
39     OS_MHOOK_ACTIVATE_PARA0(OS_HOOK_TICK_EXIT);
40 }
41 
42 /*
43  * 描述:初始化Tick中断模块
44  */
OsTickConfigInit(void)45 OS_SEC_L4_TEXT U32 OsTickConfigInit(void)
46 {
47     if ((g_tickModInfo.tickPerSecond == 0) || (g_tickModInfo.tickPerSecond > g_systemClock)) {
48         return OS_ERRNO_TICK_PER_SECOND_ERROR;
49     }
50 
51     g_cyclePerTick = g_systemClock / (g_tickModInfo.tickPerSecond);
52 
53     if (OS_IS_TICK_PERIOD_INVALID(g_cyclePerTick)) {
54         return OS_ERRNO_TICK_PERIOD;
55     }
56 
57     g_tickDispatcher = OsTickHookDispatcher;
58 
59     return OS_HW_TICK_INIT();
60 }
61 
62 /*
63  * 描述:启动Tick中断
64  */
OsTickStart(void)65 OS_SEC_L4_TEXT U32 OsTickStart(void)
66 {
67     return OS_OK;
68 }
69 
70