los_sys.h

浏览该文件的文档。
00001 /*----------------------------------------------------------------------------
00002  * Copyright (c) <2013-2015>, <Huawei Technologies Co., Ltd>
00003  * All rights reserved.
00004  * Redistribution and use in source and binary forms, with or without modification,
00005  * are permitted provided that the following conditions are met:
00006  * 1. Redistributions of source code must retain the above copyright notice, this list of
00007  * conditions and the following disclaimer.
00008  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
00009  * of conditions and the following disclaimer in the documentation and/or other materials
00010  * provided with the distribution.
00011  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
00012  * to endorse or promote products derived from this software without specific prior written
00013  * permission.
00014  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00015  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00016  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
00018  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00021  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00022  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00023  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00024  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025  *---------------------------------------------------------------------------*/
00026 /*----------------------------------------------------------------------------
00027  * Notice of Export Control Law
00028  * ===============================================
00029  * Huawei LiteOS may be subject to applicable export control laws and regulations, which might
00030  * include those applicable to Huawei LiteOS of U.S. and the country in which you are located.
00031  * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such
00032  * applicable export control laws and regulations.
00033  *---------------------------------------------------------------------------*/
00034 
00035 /**@defgroup los_sys System time
00036  * @ingroup kernel
00037  */
00038 
00039 #ifndef _LOS_SYS_H
00040 #define _LOS_SYS_H
00041 
00042 #include "los_base.h"
00043 #include "los_hwi.h"
00044 
00045 #ifdef __cplusplus
00046 #if __cplusplus
00047 extern "C" {
00048 #endif /* __cplusplus */
00049 #endif /* __cplusplus */
00050 
00051 
00052 /**
00053  *@ingroup los_sys
00054  *System time basic function error code: Null pointer.
00055  *
00056  *Value: 0x02000010
00057  *
00058  *Solution: Check whether the input parameter is null.
00059  */
00060 #define LOS_ERRNO_SYS_PTR_NULL                                  LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x10)
00061 
00062 /**
00063  *@ingroup los_sys
00064  *System time basic function error code: Invalid system clock configuration.
00065  *
00066  *Value: 0x02000011
00067  *
00068  *Solution: Configure a valid system clock in los_config.h.
00069  */
00070 #define LOS_ERRNO_SYS_CLOCK_INVALID                             LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x11)
00071 
00072 /**
00073  *@ingroup los_sys
00074  *System time basic function error code: This error code is not in use temporarily.
00075  *
00076  *Value: 0x02000012
00077  *
00078  *Solution: None.
00079  */
00080 #define LOS_ERRNO_SYS_MAXNUMOFCORES_IS_INVALID                  LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x12)
00081 
00082 /**
00083  *@ingroup los_sys
00084  *System time error code: This error code is not in use temporarily.
00085  *
00086  *Value: 0x02000013
00087  *
00088  *Solution: None.
00089  */
00090 #define LOS_ERRNO_SYS_PERIERRCOREID_IS_INVALID                  LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x13)
00091 
00092 /**
00093  *@ingroup los_sys
00094  *System time error code: This error code is not in use temporarily.
00095  *
00096  *Value: 0x02000014
00097  *
00098  *Solution: None.
00099  */
00100 #define LOS_ERRNO_SYS_HOOK_IS_FULL                              LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x14)
00101 
00102 /**
00103  * @ingroup los_typedef
00104  * system time structure.
00105  */
00106 typedef struct tagSysTime
00107 {
00108     UINT16  uwYear;    /**< value 1970 ~ 2038 or 1970 ~ 2100 */
00109     UINT8   ucMonth;   /**< value 1 - 12 */
00110     UINT8   ucDay;     /**< value 1 - 31 */
00111     UINT8   ucHour;    /**< value 0 - 23 */
00112     UINT8   ucMinute;  /**< value 0 - 59 */
00113     UINT8   ucSecond;  /**< value 0 - 59 */
00114     UINT8   ucWeek;    /**< value 0 - 6  */
00115 } SYS_TIME_S;
00116 
00117 /**
00118  *@ingroup los_sys
00119  *@brief Obtain the number of Ticks.
00120  *
00121  *@par Description:
00122  *This API is used to obtain the number of Ticks.
00123  *@attention
00124  *<ul>
00125  *<li>None</li>
00126  *</ul>
00127  *
00128  *@param  None
00129  *
00130  *@retval UINT64 The number of Ticks.
00131  *@par Dependency:
00132  *<ul><li>los_sys.h: the header file that contains the API declaration.</li></ul>
00133  *@see None
00134  *@since Huawei LiteOS V100R001C00
00135  */
00136 extern UINT64 LOS_TickCountGet (VOID);
00137 
00138 /**
00139  *@ingroup los_sys
00140  *@brief Obtain the number of cycles in one second.
00141  *
00142  *@par Description:
00143  *This API is used to obtain the number of cycles in one second.
00144  *@attention
00145  *<ul>
00146  *<li>None</li>
00147  *</ul>
00148  *
00149  *@param  None
00150  *
00151  *@retval UINT32 Number of cycles obtained in one second.
00152  *@par Dependency:
00153  *<ul><li>los_sys.h: the header file that contains the API declaration.</li></ul>
00154  *@see None
00155  *@since Huawei LiteOS V100R001C00
00156  */
00157 extern UINT32 LOS_CyclePerTickGet(VOID);
00158 
00159 /**
00160  *@ingroup los_sys
00161  *@brief Convert Ticks to milliseconds.
00162  *
00163  *@par Description:
00164  *This API is used to convert Ticks to milliseconds.
00165  *@attention
00166  *<ul>
00167  *<li>The number of milliseconds obtained through the conversion is 32-bit.</li>
00168  *</ul>
00169  *
00170  *@param  uwTick  [IN] Number of Ticks. The value range is (0,OS_SYS_CLOCK).
00171  *
00172  *@retval UINT32 Number of milliseconds obtained through the conversion. Ticks are successfully converted to milliseconds.
00173  *@par  Dependency:
00174  *<ul><li>los_sys.h: the header file that contains the API declaration.</li></ul>
00175  *@see LOS_MS2Tick
00176  *@since Huawei LiteOS V100R001C00
00177  */
00178 extern UINT32 LOS_Tick2MS(UINT32 uwTick);
00179 
00180 /**
00181  *@ingroup los_sys
00182  *@brief Convert milliseconds to Ticks.
00183  *
00184  *@par Description:
00185  *This API is used to convert milliseconds to Ticks.
00186  *@attention
00187  *<ul>
00188  *<li>If the parameter passed in is equal to 0xFFFFFFFF, the retval is 0xFFFFFFFF. Pay attention to the value to be converted because data possibly overflows.</li>
00189  *</ul>
00190  *
00191  *@param  uwMillisec  [IN] Number of milliseconds.
00192  *
00193  *@retval UINT32 Number of Ticks obtained through the conversion.
00194  *@par Dependency:
00195  *<ul><li>los_sys.h: the header file that contains the API declaration.</li></ul>
00196  *@see LOS_Tick2MS
00197  *@since Huawei LiteOS V100R001C00
00198  */
00199 extern UINT32 LOS_MS2Tick(UINT32 uwMillisec);
00200 
00201 #ifdef __cplusplus
00202 #if __cplusplus
00203 }
00204 #endif /* __cplusplus */
00205 #endif /* __cplusplus */
00206 
00207 #endif /* _LOS_SYS_H */