1 /*
2  * Copyright (c) 2006-2022, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date         Author      Notes
8  * 2011-02-21   onelife     Initial creation for EFM32
9  * 2011-07-14   onelife     Add multiple channels support for scan mode
10  */
11 
12 #ifndef __DRV_ADC_H__
13 #define __DRV_ADC_H__
14 
15 /* Includes ------------------------------------------------------------------*/
16 /* Exported types ------------------------------------------------------------*/
17 struct efm32_adc_device_t
18 {
19     ADC_TypeDef             *adc_device;
20     rt_uint8_t              mode;
21     rt_uint8_t              singleCount;
22     rt_uint8_t              singleDmaChannel;
23     rt_uint8_t              scanCount;
24     rt_uint8_t              scanDmaChannel;
25 };
26 
27 struct efm32_adc_control_single_t
28 {
29     rt_uint8_t              count;
30     rt_uint8_t              dmaChannel;
31     ADC_InitSingle_TypeDef  *init;
32 };
33 
34 struct efm32_adc_control_scan_t
35 {
36     rt_uint8_t              count;
37     rt_uint8_t              dmaChannel;
38     ADC_InitScan_TypeDef    *init;
39 };
40 
41 struct efm32_adc_control_t
42 {
43     rt_uint8_t              mode;
44     struct efm32_adc_control_scan_t     scan;
45     struct efm32_adc_control_single_t   single;
46 };
47 
48 struct efm32_adc_result_t
49 {
50     rt_uint8_t              mode;
51     void                    *buffer;
52 };
53 
54 /* Exported constants --------------------------------------------------------*/
55 /* Exported macro ------------------------------------------------------------*/
56 #define ADC_MODE_SINGLE         (0x01)
57 #define ADC_MODE_SCAN           (0x02)
58 #define ADC_MODE_TAILGATE       (0x04)
59 #define ADC_OP_SINGLE_REPEAT    (0x10)
60 #define ADC_OP_SCAN_REPEAT      (0x20)
61 #define ADC_MASK_MODE           (0x0f)
62 #define ADC_MASK_OP             (0xf0)
63 
64 /* Exported functions ------------------------------------------------------- */
65 void rt_hw_adc_init(void);
66 
67 #endif /*__DRV_ADC_H__ */
68