1 /* ---------------------------------------------------------------------------- 2 * Copyright (c) Huawei Technologies Co., Ltd. 2013-2018. All rights reserved. 3 * Description: Tick 4 * Redistribution and use in source and binary forms, with or without modification, 5 * are permitted provided that the following conditions are met: 6 * 1. Redistributions of source code must retain the above copyright notice, this list of 7 * conditions and the following disclaimer. 8 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 * of conditions and the following disclaimer in the documentation and/or other materials 10 * provided with the distribution. 11 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 * to endorse or promote products derived from this software without specific prior written 13 * permission. 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * --------------------------------------------------------------------------- */ 26 27 /** 28 * @defgroup los_tick Tick 29 * @ingroup kernel 30 */ 31 32 #ifndef _LOS_TICK_H 33 #define _LOS_TICK_H 34 35 #include "los_errno.h" 36 37 #ifdef __cplusplus 38 #if __cplusplus 39 extern "C" { 40 #endif /* __cplusplus */ 41 #endif /* __cplusplus */ 42 43 /** 44 * @ingroup los_tick 45 * Define the type of the platform tick handler function. 46 * 47 */ 48 typedef VOID (*PLATFORM_TICK_HANDLER)(VOID); 49 extern PLATFORM_TICK_HANDLER g_tickHandler; 50 51 /** 52 * @ingroup los_tick 53 * Define the type of the platform tick handler function. 54 * 55 */ 56 typedef VOID (*PLATFORM_GET_CYCLE_FUNC)(UINT32 *cntHi, UINT32 *cntLo); 57 extern PLATFORM_GET_CYCLE_FUNC g_cycleGetFunc; 58 59 /** 60 * @ingroup los_tick 61 * Tick error code: The Tick configuration is incorrect. 62 * 63 * Value: 0x02000400 64 * 65 * Solution: Change values of the OS_SYS_CLOCK and LOSCFG_BASE_CORE_TICK_PER_SECOND 66 * system time configuration modules in Los_config.h. 67 */ 68 #define LOS_ERRNO_TICK_CFG_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x00) 69 70 /** 71 * @ingroup los_tick 72 * Tick error code: This error code is not in use temporarily. 73 * 74 * Value: 0x02000401 75 * 76 * Solution: None. 77 */ 78 #define LOS_ERRNO_TICK_NO_HWTIMER LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x01) 79 80 /** 81 * @ingroup los_tick 82 * Tick error code: The number of Ticks is too small. 83 * 84 * Value: 0x02000402 85 * 86 * Solution: Change values of the OS_SYS_CLOCK and LOSCFG_BASE_CORE_TICK_PER_SECOND 87 * system time configuration modules. 88 */ 89 #define LOS_ERRNO_TICK_PER_SEC_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x02) 90 91 /** 92 * @ingroup los_tick 93 * @brief: System clock get function. 94 * 95 * @par Description: 96 * This API is used to get system clock. 97 * 98 * @attention: 99 * <ul><li>None.</li></ul> 100 * 101 * @param: None. 102 * 103 * @retval: system clock. 104 * 105 * @par Dependency: 106 * <ul><li>los_tick.h: the header file that contains the API declaration.</li></ul> 107 * @see None. 108 * 109 * */ 110 extern UINT32 LOS_SysClockGet(VOID); 111 112 #ifdef __cplusplus 113 #if __cplusplus 114 } 115 #endif /* __cplusplus */ 116 #endif /* __cplusplus */ 117 118 #endif /* _LOS_TICK_H */ 119