• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2022 Beken Corporation
2 //
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 
15 #pragma once
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include <common/bk_include.h>
22 
23 typedef enum
24 {
25     BK_TIMER_ID0        = 0,//BKTIMER0
26     BK_TIMER_ID1,
27     BK_TIMER_ID2,
28     BK_TIMER_ID3,
29     BK_TIMER_ID4,
30     BK_TIMER_ID5,
31     BK_PWM_TIMER_ID0     = (6),//PWM0
32     BK_PWM_TIMER_ID1,
33     BK_PWM_TIMER_ID2,
34     BK_PWM_TIMER_ID3,
35     BK_PWM_TIMER_ID4,
36     BK_PWM_TIMER_ID5,
37     BK_TIMER_ID_MAX_COUNT
38 }BK_HW_TIMER_INDEX;
39 
40 #define FCLK_PWM_ID           0
41 
42 #if (CONFIG_SOC_BK7271)
43 #define FCLK_TIMER_ID          BKTIMER1
44 #define CAL_TIMER_ID           BKTIMER2
45 #elif (!CONFIG_SOC_BK7231)
46 #define FCLK_TIMER_ID          BKTIMER3
47 #define CAL_TIMER_ID           BKTIMER2
48 #endif
49 
50 #if (CONFIG_RTT)
51 #define rtos_get_ms_per_tick()      (1000 / RT_TICK_PER_SECOND)
52 #define rtos_get_tick_per_second()           (RT_TICK_PER_SECOND)
53 #else
54 #define rtos_get_ms_per_tick()      2
55 #define rtos_get_tick_per_second()           (1000/rtos_get_ms_per_tick())
56 #endif
57 
58 #define TICK_PER_SECOND       rtos_get_tick_per_second()
59 
60 #define BK_MS_TO_TICKS(x)     ((x) / (rtos_get_ms_per_tick()))
61 #define BK_TICKS_TO_MS(x)     ((x) * (rtos_get_ms_per_tick()))
62 
63 
64 UINT32 fclk_get_second(void);
65 void fclk_reset_count(void);
66 void fclk_init(void);
67 UINT32 fclk_from_sec_to_tick(UINT32 sec);
68 UINT32 fclk_cal_endvalue(UINT32 mode);
69 BK_HW_TIMER_INDEX fclk_get_tick_id(void);
70 UINT32 fclk_get_local_tick32(void);
71 UINT64 fclk_get_local_tick64(void);
72 
73 #ifdef __cplusplus
74 }
75 #endif
76