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 #define TIMER_DEV_NAME "bk_timer" 22 23 #define BK_TIMER_FAILURE (1) 24 #define BK_TIMER_SUCCESS (0) 25 26 #define TIMER_CMD_MAGIC (0xe340000) 27 enum 28 { 29 CMD_TIMER_UNIT_ENABLE = TIMER_CMD_MAGIC + 1, 30 CMD_TIMER_UNIT_DISABLE, 31 CMD_TIMER_INIT_PARAM, 32 CMD_TIMER_INIT_PARAM_US, 33 CMD_TIMER_READ_CNT 34 }; 35 36 enum 37 { 38 BKTIMER0 = 0, 39 BKTIMER1, 40 BKTIMER2, 41 BKTIMER3, 42 BKTIMER4, 43 BKTIMER5, 44 BKTIMER_COUNT 45 }; 46 47 typedef void (*TFUNC)(UINT8); 48 49 typedef struct 50 { 51 UINT8 channel; 52 UINT8 div; 53 UINT32 period; 54 TFUNC t_Int_Handler; 55 } timer_param_t; 56 57 //TODO what's the relationship with bk_timer_start/stop??? 58 void bk_timer_init(void); 59 void bk_timer_exit(void); 60 void bk_timer_isr(void); 61 62 #ifdef __cplusplus 63 } 64 #endif 65