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 /* * 20 * @defgroup iot_time System Clock 21 * @ingroup osa 22 */ 23 #ifndef __HI_TIME_H__ 24 #define __HI_TIME_H__ 25 #include <hi_types_base.h> 26 27 /* * 28 * @ingroup iot_time 29 * @brief Delay, in microseconds.CNcomment:延时,微秒级。CNend 30 * 31 * @par 描述: 32 * Delay operation implemented by software based on the system clock, blocking the CPU. 33 CNcomment:延时操作,阻塞CPU。CNend 34 * 35 * @attention This API cannot be used for a long time in an interrupt.CNcomment:不允许中断中使用。CNend 36 * 37 * @param us [IN] type #hi_u32,delay period (unit: microsecond). 38 CNcomment:延时时间(单位:μs)。CNend 39 * 40 * @retval None 41 * @par 依赖: 42 * @li hi_time.h:Describes system time APIs.CNcomment:文件包含系统时间相关接口。CNend 43 * @see None 44 * @since Hi3861_V100R001C00 45 */ 46 hi_void hi_udelay(hi_u32 us); 47 48 /* * 49 * @ingroup iot_time 50 * @brief Obtains the tick value of the system (32-bit).CNcomment:获取系统tick值(32bit)。CNend 51 * 52 * @par 描述: 53 * Obtains the tick value of the system (32-bit).CNcomment:获取系统tick值(32bit)。CNend 54 * 55 * @attention None 56 * @param None 57 * 58 * @retval #hi_u32 Tick value of the system.CNcomment:系统tick值。CNend 59 * @par 依赖: 60 * @li hi_time.h:Describes system time APIs.CNcomment:文件包含系统时间相关接口。CNend 61 * @since Hi3861_V100R001C00 62 */ 63 hi_u32 hi_get_tick(hi_void); 64 65 /* * 66 * @ingroup iot_time 67 * @brief Obtains the tick value of the system (64-bit).CNcomment:获取系统tick值(64bit)。CNend 68 * 69 * @par 描述: 70 * Obtains the tick value of the system (64-bit).CNcomment:获取系统tick值(64bit)。CNend 71 * 72 * @attention The hi_mdm_time.h file must be included where the API is called. Otherwise, the API is considered not 73 * declared, and the tick value is returned as an int type, resulting in a truncation error. 74 CNcomment:该接口调用处必须包含头文件hi_time.h,否则按照未声明接口处理,会将tick值当做int类型返回,产生截断错误。CNend 75 * @param None 76 * 77 * @retval #hi_u64 Tick value of the system.CNcomment:系统tick值。CNend 78 * @par 依赖: 79 * @li hi_time.h:Describes system time APIs.CNcomment:文件包含系统时间相关接口。CNend 80 * @since Hi3861_V100R001C00 81 */ 82 hi_u64 hi_get_tick64(hi_void); 83 84 85 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) 86 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)) 87 /* * 88 * @ingroup iot_time 89 * @brief Obtains the system time (unit: s).CNcomment:获取系统时间(单位:s)。CNend 90 * 91 * @par 描述: 92 * Obtains the system time (unit: s).CNcomment:获取系统时间(单位:s)。CNend 93 * 94 * @attention None 95 * @param None 96 * 97 * @retval #hi_u32 System time.CNcomment:系统时间。CNend 98 * @retval #HI_ERR_FAILURE failed to be obtained. CNcomment:获取时间失败。CNend 99 * @par 依赖: 100 * @li hi_time.h:Describes system time APIs.CNcomment:文件包含系统时间相关接口。CNend 101 * @since Hi3861_V100R001C00 102 */ 103 hi_u32 hi_get_seconds(hi_void); 104 105 /* * 106 * @ingroup iot_time 107 * @brief Obtains the system time (unit: us).CNcomment:获取系统时间(单位:us)。CNend 108 * 109 * @par 描述: 110 * Obtains the system time (unit: us).CNcomment:获取系统时间(单位:us)。CNend 111 * 112 * @attention None 113 * @param None 114 * 115 * @retval #hi_u64 System time.CNcomment:系统时间。CNend 116 * @retval #HI_ERR_FAILURE failed to be obtained. CNcomment:获取时间失败。CNend 117 * @par 依赖: 118 * @li hi_time.h:Describes system time APIs.CNcomment:文件包含系统时间相关接口。CNend 119 * @since Hi3861_V100R001C00 120 */ 121 hi_u64 hi_get_us(hi_void); 122 123 /* * 124 * @ingroup iot_time 125 * @brief Obtains the real time of the system (unit: s).CNcomment:获取系统实时时间(单位:s)。CNend 126 * 127 * @par 描述: 128 * Obtains the real time of the system (unit: s).CNcomment:获取系统实时时间(单位:s)。CNend 129 * 130 * @attention None 131 * @param None 132 * 133 * @retval #hi_u32 Real time of the system.CNcomment: 系统实时时间。CNend 134 * @retval #HI_ERR_FAILURE failed to be obtained. CNcomment:获取时间失败。CNend 135 * @par 依赖: 136 * @li hi_time.h:Describes system time APIs.CNcomment:文件包含系统时间相关接口。CNend 137 * @since Hi3861_V100R001C00 138 */ 139 hi_u32 hi_get_real_time(hi_void); 140 141 /* * 142 * @ingroup iot_time 143 * @brief Sets the real time of the system.CNcomment:设置系统实时时间。CNend 144 * 145 * @par 描述: 146 * Sets the real time of the system.CNcomment:设置系统实时时间。CNend 147 * 148 * @attention None 149 * @param seconds [IN] type #hi_u32,set the real time of the system to this value. 150 CNcomment:将系统实时时间设置为该值。CNend 151 * 152 * @retval #HI_ERR_SUCCESS Success. 153 * @retval #HI_ERR_FAILURE Failure. 154 * @par 依赖: 155 * @li hi_time.h:Describes system time APIs.CNcomment:文件包含系统时间相关接口。CNend 156 * @since Hi3861_V100R001C00 157 */ 158 hi_u32 hi_set_real_time(hi_u32 seconds); 159 #endif 160 #endif 161 162 #endif 163