• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  *
15  * Description: Provides V100 HAL rtc \n
16  *
17  * History: \n
18  * 2023-03-03, Create file. \n
19  */
20 #ifndef HAL_RTC_V100_H
21 #define HAL_RTC_V100_H
22 
23 #include "hal_rtc.h"
24 
25 #ifdef __cplusplus
26 #if __cplusplus
27 extern "C" {
28 #endif /* __cplusplus */
29 #endif /* __cplusplus */
30 
31 /**
32  * @defgroup drivers_hal_rtc_v100 RTC V100
33  * @ingroup  drivers_hal_rtc
34  * @{
35  */
36 
37 /**
38  * @if Eng
39  * @brief  Definition of the RTC mode.
40  * @else
41  * @brief  RTC模式定义。
42  * @endif
43  */
44 typedef enum control_reg_mode {
45     /** @if Eng  RTC mode: free run mode.
46      *  @else    定时器控制模式:自由运行模式。
47      *  @endif */
48     RTC_MODE_FREE_RUN,
49     /** @if Eng  RTC mode: user define mode.
50      *  @else    定时器控制模式:用户自定义模式。
51      *  @endif */
52     RTC_MODE_USER_DEF
53 } hal_rtc_v100_ctrl_reg_mode_t;
54 
55 /**
56  * @if Eng
57  * @brief  HAL RTC initialize interface.
58  * @param  [in]  index Index of the hardware rtc. For detail, see @ref rtc_index_t.
59  * @param  [in]  callback Callback of RTC.
60  * @retval ERRCODE_SUCC   Success.
61  * @retval Other          Failure. For details, see @ref errcode_t
62  * @else
63  * @brief  HAL层RTC的初始化接口。
64  * @param  [in]  index 硬件定时器索引值,参考 @ref rtc_index_t 。
65  * @param  [in]  callback RTC的回调函数。
66  * @retval ERRCODE_SUCC 成功。
67  * @retval Other        失败,参考 @ref errcode_t 。
68  * @endif
69  */
70 errcode_t hal_rtc_v100_init(rtc_index_t index, hal_rtc_callback_t callback);
71 
72 /**
73  * @if Eng
74  * @brief  HAL RTC deinitialize interface.
75  * @param  [in]  index Index of the hardware rtc. For detail, see @ref rtc_index_t.
76  * @else
77  * @brief  HAL层RTC的去初始化接口。
78  * @param  [in]  index 硬件定时器索引值,参考 @ref rtc_index_t 。
79  * @endif
80  */
81 void hal_rtc_v100_deinit(rtc_index_t index);
82 
83 /**
84  * @if Eng
85  * @brief  HAL RTC start the load count of hardware RTC interface.
86  * @param  [in]  index Index of low layer RTC. For detail, see @ref rtc_index_t.
87  * @else
88  * @brief  HAL层启动硬件定时器计数的接口。
89  * @param  [in]  index RTC底层索引值,参考 @ref rtc_index_t 。
90  * @endif
91  */
92 void hal_rtc_v100_start(rtc_index_t index);
93 
94 /**
95  * @if Eng
96  * @brief  HAL RTC stop the load count of hardware RTC interface.
97  * @param  [in]  index Index of low layer RTC. For detail, see @ref rtc_index_t.
98  * @else
99  * @brief  HAL层停止硬件定时器计数的接口。
100  * @param  [in]  index rtc底层索引值,参考 @ref rtc_index_t 。
101  * @endif
102  */
103 void hal_rtc_v100_stop(rtc_index_t index);
104 
105 /**
106  * @if Eng
107  * @brief  HAL RTC set the load count of hardware RTC interface.
108  * @param  [in]  index Index of low layer RTC. For detail, see @ref rtc_index_t.
109  * @param  [in]  delay_count Time for load count.
110  * @else
111  * @brief  HAL层设置硬件计时器计数的接口。
112  * @param  [in]  index rtc底层索引值,参考 @ref rtc_index_t 。
113  * @param  [in]  delay_count 计时的时间。
114  * @endif
115  */
116 void hal_rtc_v100_config_load(rtc_index_t index, uint64_t delay_count);
117 
118 /**
119  * @if Eng
120  * @brief  HAL RTC get the current value of hardware RTC interface.
121  * @param  [in]  index Index of low layer RTC. For detail, see @ref rtc_index_t.
122  * @return RTC load count.
123  * @else
124  * @brief  HAL层获取硬件当时计时器剩余计数的接口。
125  * @param  [in]  index rtc底层索引值,参考 @ref rtc_index_t 。
126  * @return rtc计数值。
127  * @endif
128  */
129 uint64_t hal_rtc_v100_get_current_value(rtc_index_t index);
130 
131 /**
132  * @if Eng
133  * @brief  HAL RTC get the count of RTC IRQ.
134  * @return RTC irq count.
135  * @else
136  * @brief  HAL层获取RTC发生中断的次数的值。
137  * @return rtc中断计数值。
138  * @endif
139  */
140 uint32_t hal_rtc_v100_get_int_cnt_record(void);
141 
142 /**
143  * @if Eng
144  * @brief  HAL RTC get the current interrupt status of hardware RTC interface.
145  * @param  [in]  index Index of low layer RTC. For detail, see @ref rtc_index_t.
146  * @return RTC load count.
147  * @else
148  * @brief  HAL层获取硬件当时计时器中断状态。
149  * @param  [in]  index rtc底层索引值,参考 @ref rtc_index_t 。
150  * @return rtc计数值。
151  * @endif
152  */
153 uint32_t hal_rtc_v100_get_int_status(rtc_index_t index);
154 
155 /**
156  * @if Eng
157  * @brief  Handler of the RTC interrupt request.
158  * @param  [in]  index Index of the hardware rtc. For detail, see @ref rtc_index_t.
159  * @else
160  * @brief  RTC中断处理函数。
161  * @param  [in]  index 硬件定时器索引值,参考 @ref rtc_index_t 。
162  * @endif
163  */
164 void hal_rtc_v100_irq_handler(rtc_index_t index);
165 
166 /**
167  * @}
168  */
169 
170 #ifdef __cplusplus
171 #if __cplusplus
172 }
173 #endif /* __cplusplus */
174 #endif /* __cplusplus */
175 
176 #endif