1 /*
2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 * Description: oal util interface
15 * Author:
16 */
17
18 #ifndef FRW_UTIL_ROM_H
19 #define FRW_UTIL_ROM_H
20
21 #include "osal_types.h"
22 #include "systick.h"
23 #include "soc_osal.h"
24 #include "oal_types_device_rom.h"
25 #ifdef _PRE_OS_VERSION_NONOS
26 #include "serial_dw.h"
27 #define osal_printf debug_message
28 #else
29 #define osal_printf osal_printk
30 #endif
31
frw_max(osal_u32 a,osal_u32 b)32 static INLINE__ osal_u32 frw_max(osal_u32 a, osal_u32 b)
33 {
34 return a > b ? a : b;
35 }
frw_min(osal_u32 a,osal_u32 b)36 static INLINE__ osal_u32 frw_min(osal_u32 a, osal_u32 b)
37 {
38 return a < b ? a : b;
39 }
40
41 #ifndef _PRE_WLAN_FEATURE_WS73
42 /* 获取毫秒级时间戳 */
osal_dmac_get_time_stamp_ms(osal_void)43 static INLINE__ osal_u64 osal_dmac_get_time_stamp_ms(osal_void)
44 {
45 return uapi_systick_get_us() >> 10; /* 右移10位,用1024换算ms */
46 }
47 /* 获取高精度毫秒级时间戳 */
osal_dmac_get_high_prec_ms(osal_void)48 static INLINE__ osal_u64 osal_dmac_get_high_prec_ms(osal_void)
49 {
50 return uapi_systick_get_us() / 1000; /* 用1000换算ms */
51 }
52 /* 获取31.25微秒级时间戳 */
osal_dmac_get_time_stamp_ts(osal_void)53 static INLINE__ osal_u64 osal_dmac_get_time_stamp_ts(osal_void)
54 {
55 return uapi_systick_get_us();
56 }
57
58 #else
59 /* 获取毫秒级时间戳 */
osal_dmac_get_time_stamp_ms(osal_void)60 static INLINE__ osal_u64 osal_dmac_get_time_stamp_ms(osal_void)
61 {
62 return uapi_get_time_us() >> 10; /* 右移10位,用1024换算ms */
63 }
64 /* 获取高精度毫秒级时间戳 */
osal_dmac_get_high_prec_ms(osal_void)65 static INLINE__ osal_u64 osal_dmac_get_high_prec_ms(osal_void)
66 {
67 return uapi_get_time_us() / 1000; /* 用1000换算ms */
68 }
69 /* 获取31.25微秒级时间戳 */
osal_dmac_get_time_stamp_ts(osal_void)70 static INLINE__ osal_u64 osal_dmac_get_time_stamp_ts(osal_void)
71 {
72 return uapi_get_time_us();
73 }
74 #endif
75
76 osal_s32 osal_atoi(const osal_char *c_string);
77
78 #endif /* end of frw_util_rom.h */
79