MAX32665 SDK Documentation  0.2
Software Development Kit Overview and API Documentation
adc.h
1 
6 /* ****************************************************************************
7  * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
23  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  *
27  * Except as contained in this notice, the name of Maxim Integrated
28  * Products, Inc. shall not be used except as stated in the Maxim Integrated
29  * Products, Inc. Branding Policy.
30  *
31  * The mere transfer of this software does not imply any licenses
32  * of trade secrets, proprietary technology, copyrights, patents,
33  * trademarks, maskwork rights, or any other form of intellectual
34  * property whatsoever. Maxim Integrated Products, Inc. retains all
35  * ownership rights.
36  *
37  * $Date: 2019-01-31 10:54:56 -0600 (Thu, 31 Jan 2019) $
38  * $Revision: 40661 $
39  *
40  *************************************************************************** */
41 
42 /* Define to prevent redundant inclusion */
43 #ifndef _ADC_H_
44 #define _ADC_H_
45 
46 /* **** Includes **** */
47 #include <stdint.h>
48 #include "adc_regs.h"
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
59 /***************************************************************************************************************
60  DATA STRUCTURES FOR ADC INITIALIZATION
61 ***************************************************************************************************************/
65 typedef enum {
66  ADC_CH_0 = MXC_V_ADC_CTRL_CH_SEL_AIN0, // Select Channel 0
67  ADC_CH_1 = MXC_V_ADC_CTRL_CH_SEL_AIN1, // Select Channel 1
68  ADC_CH_2 = MXC_V_ADC_CTRL_CH_SEL_AIN2, // Select Channel 2
69  ADC_CH_3 = MXC_V_ADC_CTRL_CH_SEL_AIN3, // Select Channel 3
70  ADC_CH_4 = MXC_V_ADC_CTRL_CH_SEL_AIN4, // Select Channel 4
71  ADC_CH_5 = MXC_V_ADC_CTRL_CH_SEL_AIN5 , // Select Channel 5
72  ADC_CH_6 = MXC_V_ADC_CTRL_CH_SEL_AIN6, // Select Channel 6
73  ADC_CH_7 = MXC_V_ADC_CTRL_CH_SEL_AIN7, // Select Channel 7
74  ADC_CH_VCOREA = MXC_V_ADC_CTRL_CH_SEL_VCOREA, // Vcorea
75  ADC_CH_VCOREB = MXC_V_ADC_CTRL_CH_SEL_VCOREB, // Vcoreb
76  ADC_CH_VRXOUT = MXC_V_ADC_CTRL_CH_SEL_VRXOUT, // Vrxout
77  ADC_CH_VTXOUT = MXC_V_ADC_CTRL_CH_SEL_VTXOUT, // Vtxout
78  ADC_CH_VDDA = MXC_V_ADC_CTRL_CH_SEL_VDDA, // Vdda
79  ADC_CH_VDDB = MXC_V_ADC_CTRL_CH_SEL_VDDB, // Vddb divided by 4
80  ADC_CH_VDDIO = MXC_V_ADC_CTRL_CH_SEL_VDDIO, // Vddio divided by 4
81  ADC_CH_VDDIOH = MXC_V_ADC_CTRL_CH_SEL_VDDIOH, // Vddioh divided by 4
82  ADC_CH_VREGI = MXC_V_ADC_CTRL_CH_SEL_VREGI, // VregI divided by 4
84 
88 typedef enum {
89  ADC_LIMIT_0, // ADC Limit Register 0
90  ADC_LIMIT_1, // ADC Limit Register 1
91  ADC_LIMIT_2, // ADC Limit Register 2
92  ADC_LIMIT_3, // ADC Limit Register 3
93  ADC_LIMIT_MAX // Number of Limit registers
95 
96 /***************************************************************************************************************
97  DRIVER EXPOSED API's
98 ***************************************************************************************************************/
105 int ADC_Init(unsigned divisor, const sys_cfg_adc_t* sys_cfg);
106 
113 void ADC_StartConvert(mxc_adc_chsel_t channel, unsigned int adc_scale, unsigned int ref_scale);
114 
121 int ADC_GetData(uint16_t *outdata);
122 
134 int ADC_SetLimit(mxc_adc_limitsel_t unit, mxc_adc_chsel_t channel, unsigned int low_enable,
135  unsigned int low_limit, unsigned int high_enable, unsigned int high_limit);
136 
142 uint32_t ADC_GetFlags(void);
143 
150 void ADC_ClearFlags(uint32_t mask);
151 
157 uint32_t ADC_GetStatus(void);
158 
164 void ADC_EnableINT(uint32_t mask);
165 
171 void ADC_DisableINT(uint32_t mask);
172 
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 #endif /* _ADC_H_ */
uint32_t ADC_GetFlags(void)
Get interrupt flags.
void ADC_StartConvert(mxc_adc_chsel_t channel, unsigned int adc_scale, unsigned int ref_scale)
Start ADC conversion on the selected channel.
#define MXC_V_ADC_CTRL_CH_SEL_VCOREB
CTRL_CH_SEL_VCOREB Value.
Definition: adc_regs.h:157
void ADC_DisableINT(uint32_t mask)
Disable ADC interrupts based on mask.
#define MXC_V_ADC_CTRL_CH_SEL_AIN2
CTRL_CH_SEL_AIN2 Value.
Definition: adc_regs.h:143
#define MXC_V_ADC_CTRL_CH_SEL_VDDIOH
CTRL_CH_SEL_VDDIOH Value.
Definition: adc_regs.h:169
#define MXC_V_ADC_CTRL_CH_SEL_AIN6
CTRL_CH_SEL_AIN6 Value.
Definition: adc_regs.h:151
int ADC_GetData(uint16_t *outdata)
Gets the result from the previous ADC conversion.
#define MXC_V_ADC_CTRL_CH_SEL_AIN7
CTRL_CH_SEL_AIN7 Value.
Definition: adc_regs.h:153
void ADC_ClearFlags(uint32_t mask)
Clear interrupt flag(s) using the mask parameter.
#define MXC_V_ADC_CTRL_CH_SEL_VRXOUT
CTRL_CH_SEL_VRXOUT Value.
Definition: adc_regs.h:159
mxc_adc_chsel_t
Enumeration type for the ADC Input Channels.
Definition: adc.h:65
#define MXC_V_ADC_CTRL_CH_SEL_VDDIO
CTRL_CH_SEL_VDDIO Value.
Definition: adc_regs.h:167
#define MXC_V_ADC_CTRL_CH_SEL_VDDB
CTRL_CH_SEL_VDDB Value.
Definition: adc_regs.h:165
void ADC_EnableINT(uint32_t mask)
Enables the ADC interrupts specified by the mask parameter.
#define MXC_V_ADC_CTRL_CH_SEL_AIN1
CTRL_CH_SEL_AIN1 Value.
Definition: adc_regs.h:141
#define MXC_V_ADC_CTRL_CH_SEL_VREGI
CTRL_CH_SEL_VREGI Value.
Definition: adc_regs.h:171
#define MXC_V_ADC_CTRL_CH_SEL_AIN3
CTRL_CH_SEL_AIN3 Value.
Definition: adc_regs.h:145
#define MXC_V_ADC_CTRL_CH_SEL_AIN0
CTRL_CH_SEL_AIN0 Value.
Definition: adc_regs.h:139
#define MXC_V_ADC_CTRL_CH_SEL_VCOREA
CTRL_CH_SEL_VCOREA Value.
Definition: adc_regs.h:155
#define MXC_V_ADC_CTRL_CH_SEL_AIN5
CTRL_CH_SEL_AIN5 Value.
Definition: adc_regs.h:149
int ADC_Init(unsigned divisor, const sys_cfg_adc_t *sys_cfg)
Initialize the ADC hardware.
#define MXC_V_ADC_CTRL_CH_SEL_VTXOUT
CTRL_CH_SEL_VTXOUT Value.
Definition: adc_regs.h:161
#define MXC_V_ADC_CTRL_CH_SEL_AIN4
CTRL_CH_SEL_AIN4 Value.
Definition: adc_regs.h:147
#define MXC_V_ADC_CTRL_CH_SEL_VDDA
CTRL_CH_SEL_VDDA Value.
Definition: adc_regs.h:163
uint32_t ADC_GetStatus(void)
Get the Status of the ADC.
int ADC_SetLimit(mxc_adc_limitsel_t unit, mxc_adc_chsel_t channel, unsigned int low_enable, unsigned int low_limit, unsigned int high_enable, unsigned int high_limit)
Set the data limits for an ADC channel monitor.
mxc_adc_limitsel_t
Enumeration type for the ADC limit register to set.
Definition: adc.h:88