• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
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 #ifndef _GPADC_API_H_
16 #define _GPADC_API_H_
17 
18 #include "plf.h"
19 
20 enum {
21     GPADC_SAMPLERATE_DFLT   = 0x02,
22     GPADC_SAMPLERATE_HIGH   = 0x40,
23     GPADC_SAMPLERATE_MID    = 0x80,
24     GPADC_SAMPLERATE_LOW    = 0xF0,
25 };
26 
27 enum {
28     GPADC_TYPE_VBAT = 0,
29     GPADC_TYPE_VIO,
30     GPADC_TYPE_TEMP0,
31 };
32 
33 /**
34  * @brief       Init gpadc func
35  * @param[in]   Gpiob index
36  */
37 void gpadc_init(int gpbidx);
38 
39 /**
40  * @brief       Set smaple rate
41  * @param[in]   Rate val
42  */
43 void gpadc_samplerate_set(int rate);
44 
45 /**
46  * @brief       Free gpadc func
47  * @param[in]   Gpiob index
48  */
49 void gpadc_free(int gpbidx);
50 
51 /**
52  * @brief       Read voltage from gpiob pin
53  * @param[in]   Gpiob index
54  * @return      Voltage value, range: 0 ~ 1175mV
55  */
56 int gpadc_read(int gpbidx);
57 
58 /**
59  * @brief       Measure voltage/temperature
60  * @param[in]   GPADC type
61  * @return      Voltage/temperature value (mV/ C)
62  */
63 int gpadc_measure(int type);
64 
65 #endif /* _GPADC_API_H_ */
66