1 /*
2  * Copyright (c) 2020-2021, BLUETRUM Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef AB32VG1_HAL_ADC_H__
8 #define AB32VG1_HAL_ADC_H__
9 
10 #include "ab32vg1_hal_def.h"
11 
12 /**
13  * @defgroup ADC_channels
14  * @{
15  */
16 #define ADC_CHANNEL_0       (1u <<  0)      /* PA5  */
17 #define ADC_CHANNEL_1       (1u <<  1)      /* PA6  */
18 #define ADC_CHANNEL_2       (1u <<  2)      /* PA7  */
19 #define ADC_CHANNEL_3       (1u <<  3)      /* PB1  */
20 #define ADC_CHANNEL_4       (1u <<  4)      /* PB2  */
21 #define ADC_CHANNEL_5       (1u <<  5)      /* PB3  */
22 #define ADC_CHANNEL_6       (1u <<  6)      /* PB4  */
23 #define ADC_CHANNEL_7       (1u <<  7)      /* PE5  */
24 #define ADC_CHANNEL_8       (1u <<  8)      /* PE6  */
25 #define ADC_CHANNEL_9       (1u <<  9)      /* PE7  */
26 #define ADC_CHANNEL_10      (1u << 10)      /* PF2  */
27 #define ADC_CHANNEL_11      (1u << 11)      /* VRTC */
28 #define ADC_CHANNEL_12      (1u << 12)      /* WKO  */
29 #define ADC_CHANNEL_13      (1u << 13)      /* BGOP */
30 #define ADC_CHANNEL_14      (1u << 14)      /* VBAT */
31 #define ADC_CHANNEL_15      (1u << 15)      /* VUSB */
32 /**
33  * @}
34  *
35  */
36 
37 /**
38  * @brief Enable ADC
39  *
40  * @param enable
41  */
42 void hal_adc_enable(uint8_t enable);
43 
44 /**
45  * @brief Starts conversion of the channels
46  *
47  * @param channel @ref ADC_channels
48  */
49 void hal_adc_start(uint32_t channel);
50 
51 /**
52  * @brief Poll for conversion complete
53  *
54  * @param timeout Timeout value in millisecond
55  * @return hal_error_t
56  */
57 hal_error_t hal_adc_poll_for_conversion(uint32_t timeout);
58 
59 #endif
60