• 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 #include "hal_config.h"
18 #include "aon_rtc_hw.h"
19 #include "aon_rtc_ll.h"
20 #include <driver/hal/hal_aon_rtc_types.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #define AON_RTC_HAL_UNIT_NUM (SOC_AON_RTC_UNIT_NUM)
27 
28 typedef struct {
29 	aon_rtc_hw_t *hw;	//just pointer to the AON RTC HW REGs base address, no needs to alloc memory
30 	aon_rtc_unit_t id;
31 } aon_rtc_hal_t;
32 
33 void aon_rtc_hal_enable(aon_rtc_hal_t *hal);
34 void aon_rtc_hal_disable(aon_rtc_hal_t *hal);
35 bool aon_rtc_hal_is_enable(aon_rtc_hal_t *hal);
36 void aon_rtc_hal_stop_counter(aon_rtc_hal_t *hal);
37 void aon_rtc_hal_start_counter(aon_rtc_hal_t *hal);
38 bool aon_rtc_hal_is_counter_stop(aon_rtc_hal_t *hal);
39 void aon_rtc_hal_reset_counter(aon_rtc_hal_t *hal);
40 void aon_rtc_hal_clear_reset_counter(aon_rtc_hal_t *hal);
41 bool aon_rtc_hal_is_counter_reset(aon_rtc_hal_t *hal);
42 void aon_rtc_hal_set_tick_val(aon_rtc_hal_t *hal, uint32_t val);
43 uint32_t aon_rtc_hal_get_tick_val(aon_rtc_hal_t *hal);
44 void aon_rtc_hal_enable_tick_int(aon_rtc_hal_t *hal);
45 void aon_rtc_hal_disable_tick_int(aon_rtc_hal_t *hal);
46 bool aon_rtc_hal_is_tick_int_enable(aon_rtc_hal_t *hal);
47 bool aon_rtc_hal_get_tick_int_status(aon_rtc_hal_t *hal);
48 void aon_rtc_hal_clear_tick_int_status(aon_rtc_hal_t *hal);
49 void aon_rtc_hal_set_upper_val(aon_rtc_hal_t *hal, uint32_t up_val);
50 uint32_t aon_rtc_hal_get_upper_val(aon_rtc_hal_t *hal);
51 void aon_rtc_hal_enable_upper_int(aon_rtc_hal_t *hal);
52 void aon_rtc_hal_disable_upper_int(aon_rtc_hal_t *hal);
53 bool aon_rtc_hal_is_upper_int_enable(aon_rtc_hal_t *hal);
54 bool aon_rtc_hal_get_upper_int_status(aon_rtc_hal_t *hal);
55 void aon_rtc_hal_clear_upper_int_status(aon_rtc_hal_t *hal);
56 uint32_t aon_rtc_hal_get_counter_val(aon_rtc_hal_t *hal);
57 uint32_t aon_rtc_hal_get_upper_val_lpo(aon_rtc_hal_t *hal);
58 uint32_t aon_rtc_hal_get_tick_val_lpo(aon_rtc_hal_t *hal);
59 bk_err_t aon_rtc_hal_init(aon_rtc_hal_t *hal);
60 bk_err_t aon_rtc_hal_deinit(aon_rtc_hal_t *hal);
61 bk_err_t aon_rtc_hal_tick_init();
62 bk_err_t aon_rtc_hal_open_rtc_wakeup(uint32_t period);
63 uint32_t aon_rtc_hal_get_current_tick();
64 #if CFG_HAL_DEBUG_AON_RTC
65 void aon_rtc_struct_dump(void);
66 #else
67 #define aon_rtc_struct_dump()
68 #endif
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 
75 
76