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 <driver/hal/hal_adc_types.h> 18 #include <components/log.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 typedef struct { 25 uint32_t adc_isr_cnt; 26 uint32_t adc_rx_total_cnt; 27 uint32_t adc_rx_succ_cnt; 28 uint32_t adc_rx_drop_cnt; 29 } adc_statis_t; 30 31 32 #if CONFIG_ADC_STATIS 33 #define ADC_STATIS_ADD(_statis, _v) do{\ 34 (_statis) += (_v);\ 35 } while(0) 36 37 bk_err_t adc_statis_init(void); 38 adc_statis_t* adc_statis_get_statis(void); 39 void adc_statis_dump(void); 40 #else 41 #define ADC_STATIS_SET(_id, _v) 42 #define ADC_STATIS_ADD(_statis, _v) 43 #define adc_statis_init() 44 #define adc_statis_get_statis(id) NULL 45 #define adc_statis_dump(id) 46 #endif 47 48 #define ADC_STATIS_INC(_statis) ADC_STATIS_ADD((_statis), 1) 49 50 #ifdef __cplusplus 51 } 52 #endif 53