• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 // Copyright (C) 2022 Beken Corporation
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 #include "sys_rtos.h"
16 #include "bk_fake_clock.h"
17 #include "bk_timer.h"
18 #include "bk_icu.h"
19 #include "bk_drv_model.h"
20 #include "bk_uart.h"
21 #include <os/os.h>
22 #include <components/system.h>
23 
24 #include <components/log.h>
25 #include "bk_ps_time.h"
26 
27 #include "bk_wdt.h"
28 #include <driver/timer.h>
29 #include "tick_timer_id.h"
30 
31 #define TAG "tick"
32 
33 static int s_tick_timer_id = TICK_TIMER_ID;
34 
bk_get_tick_timer_id(void)35 int bk_get_tick_timer_id(void)
36 {
37 	return s_tick_timer_id;
38 }
39 
bk_tick_init(void)40 int bk_tick_init(void)
41 {
42 	s_tick_timer_id = TICK_TIMER_ID;
43 	bk_timer_start(s_tick_timer_id, bk_get_ms_per_tick(), (timer_isr_t)bk_tick_handle);
44 
45 #if CONFIG_TICK_CALI
46 	extern uint32_t bk_cal_init(uint32_t setting); //TODO fix it
47 	bk_cal_init(0);
48 #endif
49 	return BK_OK;
50 }
51 
bk_tick_reload(uint32_t time_ms)52 int bk_tick_reload(uint32_t time_ms)
53 {
54 	bk_timer_start(s_tick_timer_id, time_ms, (timer_isr_t)bk_tick_handle);
55 	return BK_OK;
56 }