1 /**
2  * \file
3  *
4  * \brief Component description for ADC
5  *
6  * Copyright (c) 2017 Microchip Technology Inc.
7  *
8  * \asf_license_start
9  *
10  * \page License
11  *
12  * SPDX-License-Identifier: Apache-2.0
13  *
14  * Licensed under the Apache License, Version 2.0 (the "License"); you may
15  * not use this file except in compliance with the License.
16  * You may obtain a copy of the Licence at
17  *
18  * http://www.apache.org/licenses/LICENSE-2.0
19  *
20  * Unless required by applicable law or agreed to in writing, software
21  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
22  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23  * See the License for the specific language governing permissions and
24  * limitations under the License.
25  *
26  * \asf_license_stop
27  *
28  */
29 
30 #ifndef _SAMD20_ADC_COMPONENT_
31 #define _SAMD20_ADC_COMPONENT_
32 
33 /* ========================================================================== */
34 /**  SOFTWARE API DEFINITION FOR ADC */
35 /* ========================================================================== */
36 /** \addtogroup SAMD20_ADC Analog Digital Converter */
37 /*@{*/
38 
39 #define ADC_U2204
40 #define REV_ADC                     0x111
41 
42 /* -------- ADC_CTRLA : (ADC Offset: 0x00) (R/W  8) Control A -------- */
43 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
44 typedef union {
45   struct {
46     uint8_t  SWRST:1;          /*!< bit:      0  Software Reset                     */
47     uint8_t  ENABLE:1;         /*!< bit:      1  Enable                             */
48     uint8_t  RUNSTDBY:1;       /*!< bit:      2  Run in Standby                     */
49     uint8_t  :5;               /*!< bit:  3.. 7  Reserved                           */
50   } bit;                       /*!< Structure used for bit  access                  */
51   uint8_t reg;                 /*!< Type      used for register access              */
52 } ADC_CTRLA_Type;
53 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
54 
55 #define ADC_CTRLA_OFFSET            0x00         /**< \brief (ADC_CTRLA offset) Control A */
56 #define ADC_CTRLA_RESETVALUE        _U_(0x00)    /**< \brief (ADC_CTRLA reset_value) Control A */
57 
58 #define ADC_CTRLA_SWRST_Pos         0            /**< \brief (ADC_CTRLA) Software Reset */
59 #define ADC_CTRLA_SWRST             (_U_(0x1) << ADC_CTRLA_SWRST_Pos)
60 #define ADC_CTRLA_ENABLE_Pos        1            /**< \brief (ADC_CTRLA) Enable */
61 #define ADC_CTRLA_ENABLE            (_U_(0x1) << ADC_CTRLA_ENABLE_Pos)
62 #define ADC_CTRLA_RUNSTDBY_Pos      2            /**< \brief (ADC_CTRLA) Run in Standby */
63 #define ADC_CTRLA_RUNSTDBY          (_U_(0x1) << ADC_CTRLA_RUNSTDBY_Pos)
64 #define ADC_CTRLA_MASK              _U_(0x07)    /**< \brief (ADC_CTRLA) MASK Register */
65 
66 /* -------- ADC_REFCTRL : (ADC Offset: 0x01) (R/W  8) Reference Control -------- */
67 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
68 typedef union {
69   struct {
70     uint8_t  REFSEL:4;         /*!< bit:  0.. 3  Reference Selection                */
71     uint8_t  :3;               /*!< bit:  4.. 6  Reserved                           */
72     uint8_t  REFCOMP:1;        /*!< bit:      7  Reference Buffer Offset Compensation Enable */
73   } bit;                       /*!< Structure used for bit  access                  */
74   uint8_t reg;                 /*!< Type      used for register access              */
75 } ADC_REFCTRL_Type;
76 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
77 
78 #define ADC_REFCTRL_OFFSET          0x01         /**< \brief (ADC_REFCTRL offset) Reference Control */
79 #define ADC_REFCTRL_RESETVALUE      _U_(0x00)    /**< \brief (ADC_REFCTRL reset_value) Reference Control */
80 
81 #define ADC_REFCTRL_REFSEL_Pos      0            /**< \brief (ADC_REFCTRL) Reference Selection */
82 #define ADC_REFCTRL_REFSEL_Msk      (_U_(0xF) << ADC_REFCTRL_REFSEL_Pos)
83 #define ADC_REFCTRL_REFSEL(value)   (ADC_REFCTRL_REFSEL_Msk & ((value) << ADC_REFCTRL_REFSEL_Pos))
84 #define   ADC_REFCTRL_REFSEL_INT1V_Val    _U_(0x0)   /**< \brief (ADC_REFCTRL) 1.0V voltage reference */
85 #define   ADC_REFCTRL_REFSEL_INTVCC0_Val  _U_(0x1)   /**< \brief (ADC_REFCTRL) 1/1.48 VDDANA */
86 #define   ADC_REFCTRL_REFSEL_INTVCC1_Val  _U_(0x2)   /**< \brief (ADC_REFCTRL) 1/2 VDDANA (only for VDDANA > 2.0V) */
87 #define   ADC_REFCTRL_REFSEL_AREFA_Val    _U_(0x3)   /**< \brief (ADC_REFCTRL) External reference */
88 #define   ADC_REFCTRL_REFSEL_AREFB_Val    _U_(0x4)   /**< \brief (ADC_REFCTRL) External reference */
89 #define ADC_REFCTRL_REFSEL_INT1V    (ADC_REFCTRL_REFSEL_INT1V_Val  << ADC_REFCTRL_REFSEL_Pos)
90 #define ADC_REFCTRL_REFSEL_INTVCC0  (ADC_REFCTRL_REFSEL_INTVCC0_Val << ADC_REFCTRL_REFSEL_Pos)
91 #define ADC_REFCTRL_REFSEL_INTVCC1  (ADC_REFCTRL_REFSEL_INTVCC1_Val << ADC_REFCTRL_REFSEL_Pos)
92 #define ADC_REFCTRL_REFSEL_AREFA    (ADC_REFCTRL_REFSEL_AREFA_Val  << ADC_REFCTRL_REFSEL_Pos)
93 #define ADC_REFCTRL_REFSEL_AREFB    (ADC_REFCTRL_REFSEL_AREFB_Val  << ADC_REFCTRL_REFSEL_Pos)
94 #define ADC_REFCTRL_REFCOMP_Pos     7            /**< \brief (ADC_REFCTRL) Reference Buffer Offset Compensation Enable */
95 #define ADC_REFCTRL_REFCOMP         (_U_(0x1) << ADC_REFCTRL_REFCOMP_Pos)
96 #define ADC_REFCTRL_MASK            _U_(0x8F)    /**< \brief (ADC_REFCTRL) MASK Register */
97 
98 /* -------- ADC_AVGCTRL : (ADC Offset: 0x02) (R/W  8) Average Control -------- */
99 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
100 typedef union {
101   struct {
102     uint8_t  SAMPLENUM:4;      /*!< bit:  0.. 3  Number of Samples to be Collected  */
103     uint8_t  ADJRES:3;         /*!< bit:  4.. 6  Adjusting Result / Division Coefficient */
104     uint8_t  :1;               /*!< bit:      7  Reserved                           */
105   } bit;                       /*!< Structure used for bit  access                  */
106   uint8_t reg;                 /*!< Type      used for register access              */
107 } ADC_AVGCTRL_Type;
108 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
109 
110 #define ADC_AVGCTRL_OFFSET          0x02         /**< \brief (ADC_AVGCTRL offset) Average Control */
111 #define ADC_AVGCTRL_RESETVALUE      _U_(0x00)    /**< \brief (ADC_AVGCTRL reset_value) Average Control */
112 
113 #define ADC_AVGCTRL_SAMPLENUM_Pos   0            /**< \brief (ADC_AVGCTRL) Number of Samples to be Collected */
114 #define ADC_AVGCTRL_SAMPLENUM_Msk   (_U_(0xF) << ADC_AVGCTRL_SAMPLENUM_Pos)
115 #define ADC_AVGCTRL_SAMPLENUM(value) (ADC_AVGCTRL_SAMPLENUM_Msk & ((value) << ADC_AVGCTRL_SAMPLENUM_Pos))
116 #define   ADC_AVGCTRL_SAMPLENUM_1_Val     _U_(0x0)   /**< \brief (ADC_AVGCTRL) 1 sample */
117 #define   ADC_AVGCTRL_SAMPLENUM_2_Val     _U_(0x1)   /**< \brief (ADC_AVGCTRL) 2 samples */
118 #define   ADC_AVGCTRL_SAMPLENUM_4_Val     _U_(0x2)   /**< \brief (ADC_AVGCTRL) 4 samples */
119 #define   ADC_AVGCTRL_SAMPLENUM_8_Val     _U_(0x3)   /**< \brief (ADC_AVGCTRL) 8 samples */
120 #define   ADC_AVGCTRL_SAMPLENUM_16_Val    _U_(0x4)   /**< \brief (ADC_AVGCTRL) 16 samples */
121 #define   ADC_AVGCTRL_SAMPLENUM_32_Val    _U_(0x5)   /**< \brief (ADC_AVGCTRL) 32 samples */
122 #define   ADC_AVGCTRL_SAMPLENUM_64_Val    _U_(0x6)   /**< \brief (ADC_AVGCTRL) 64 samples */
123 #define   ADC_AVGCTRL_SAMPLENUM_128_Val   _U_(0x7)   /**< \brief (ADC_AVGCTRL) 128 samples */
124 #define   ADC_AVGCTRL_SAMPLENUM_256_Val   _U_(0x8)   /**< \brief (ADC_AVGCTRL) 256 samples */
125 #define   ADC_AVGCTRL_SAMPLENUM_512_Val   _U_(0x9)   /**< \brief (ADC_AVGCTRL) 512 samples */
126 #define   ADC_AVGCTRL_SAMPLENUM_1024_Val  _U_(0xA)   /**< \brief (ADC_AVGCTRL) 1024 samples */
127 #define ADC_AVGCTRL_SAMPLENUM_1     (ADC_AVGCTRL_SAMPLENUM_1_Val   << ADC_AVGCTRL_SAMPLENUM_Pos)
128 #define ADC_AVGCTRL_SAMPLENUM_2     (ADC_AVGCTRL_SAMPLENUM_2_Val   << ADC_AVGCTRL_SAMPLENUM_Pos)
129 #define ADC_AVGCTRL_SAMPLENUM_4     (ADC_AVGCTRL_SAMPLENUM_4_Val   << ADC_AVGCTRL_SAMPLENUM_Pos)
130 #define ADC_AVGCTRL_SAMPLENUM_8     (ADC_AVGCTRL_SAMPLENUM_8_Val   << ADC_AVGCTRL_SAMPLENUM_Pos)
131 #define ADC_AVGCTRL_SAMPLENUM_16    (ADC_AVGCTRL_SAMPLENUM_16_Val  << ADC_AVGCTRL_SAMPLENUM_Pos)
132 #define ADC_AVGCTRL_SAMPLENUM_32    (ADC_AVGCTRL_SAMPLENUM_32_Val  << ADC_AVGCTRL_SAMPLENUM_Pos)
133 #define ADC_AVGCTRL_SAMPLENUM_64    (ADC_AVGCTRL_SAMPLENUM_64_Val  << ADC_AVGCTRL_SAMPLENUM_Pos)
134 #define ADC_AVGCTRL_SAMPLENUM_128   (ADC_AVGCTRL_SAMPLENUM_128_Val << ADC_AVGCTRL_SAMPLENUM_Pos)
135 #define ADC_AVGCTRL_SAMPLENUM_256   (ADC_AVGCTRL_SAMPLENUM_256_Val << ADC_AVGCTRL_SAMPLENUM_Pos)
136 #define ADC_AVGCTRL_SAMPLENUM_512   (ADC_AVGCTRL_SAMPLENUM_512_Val << ADC_AVGCTRL_SAMPLENUM_Pos)
137 #define ADC_AVGCTRL_SAMPLENUM_1024  (ADC_AVGCTRL_SAMPLENUM_1024_Val << ADC_AVGCTRL_SAMPLENUM_Pos)
138 #define ADC_AVGCTRL_ADJRES_Pos      4            /**< \brief (ADC_AVGCTRL) Adjusting Result / Division Coefficient */
139 #define ADC_AVGCTRL_ADJRES_Msk      (_U_(0x7) << ADC_AVGCTRL_ADJRES_Pos)
140 #define ADC_AVGCTRL_ADJRES(value)   (ADC_AVGCTRL_ADJRES_Msk & ((value) << ADC_AVGCTRL_ADJRES_Pos))
141 #define ADC_AVGCTRL_MASK            _U_(0x7F)    /**< \brief (ADC_AVGCTRL) MASK Register */
142 
143 /* -------- ADC_SAMPCTRL : (ADC Offset: 0x03) (R/W  8) Sampling Time Control -------- */
144 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
145 typedef union {
146   struct {
147     uint8_t  SAMPLEN:6;        /*!< bit:  0.. 5  Sampling Time Length               */
148     uint8_t  :2;               /*!< bit:  6.. 7  Reserved                           */
149   } bit;                       /*!< Structure used for bit  access                  */
150   uint8_t reg;                 /*!< Type      used for register access              */
151 } ADC_SAMPCTRL_Type;
152 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
153 
154 #define ADC_SAMPCTRL_OFFSET         0x03         /**< \brief (ADC_SAMPCTRL offset) Sampling Time Control */
155 #define ADC_SAMPCTRL_RESETVALUE     _U_(0x00)    /**< \brief (ADC_SAMPCTRL reset_value) Sampling Time Control */
156 
157 #define ADC_SAMPCTRL_SAMPLEN_Pos    0            /**< \brief (ADC_SAMPCTRL) Sampling Time Length */
158 #define ADC_SAMPCTRL_SAMPLEN_Msk    (_U_(0x3F) << ADC_SAMPCTRL_SAMPLEN_Pos)
159 #define ADC_SAMPCTRL_SAMPLEN(value) (ADC_SAMPCTRL_SAMPLEN_Msk & ((value) << ADC_SAMPCTRL_SAMPLEN_Pos))
160 #define ADC_SAMPCTRL_MASK           _U_(0x3F)    /**< \brief (ADC_SAMPCTRL) MASK Register */
161 
162 /* -------- ADC_CTRLB : (ADC Offset: 0x04) (R/W 16) Control B -------- */
163 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
164 typedef union {
165   struct {
166     uint16_t DIFFMODE:1;       /*!< bit:      0  Differential Mode                  */
167     uint16_t LEFTADJ:1;        /*!< bit:      1  Left Adjusted Result               */
168     uint16_t FREERUN:1;        /*!< bit:      2  Free Running Mode                  */
169     uint16_t CORREN:1;         /*!< bit:      3  Digital Correction Logic Enabled   */
170     uint16_t RESSEL:2;         /*!< bit:  4.. 5  Conversion Result Resolution       */
171     uint16_t :2;               /*!< bit:  6.. 7  Reserved                           */
172     uint16_t PRESCALER:3;      /*!< bit:  8..10  Prescaler Configuration            */
173     uint16_t :5;               /*!< bit: 11..15  Reserved                           */
174   } bit;                       /*!< Structure used for bit  access                  */
175   uint16_t reg;                /*!< Type      used for register access              */
176 } ADC_CTRLB_Type;
177 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
178 
179 #define ADC_CTRLB_OFFSET            0x04         /**< \brief (ADC_CTRLB offset) Control B */
180 #define ADC_CTRLB_RESETVALUE        _U_(0x0000)  /**< \brief (ADC_CTRLB reset_value) Control B */
181 
182 #define ADC_CTRLB_DIFFMODE_Pos      0            /**< \brief (ADC_CTRLB) Differential Mode */
183 #define ADC_CTRLB_DIFFMODE          (_U_(0x1) << ADC_CTRLB_DIFFMODE_Pos)
184 #define ADC_CTRLB_LEFTADJ_Pos       1            /**< \brief (ADC_CTRLB) Left Adjusted Result */
185 #define ADC_CTRLB_LEFTADJ           (_U_(0x1) << ADC_CTRLB_LEFTADJ_Pos)
186 #define ADC_CTRLB_FREERUN_Pos       2            /**< \brief (ADC_CTRLB) Free Running Mode */
187 #define ADC_CTRLB_FREERUN           (_U_(0x1) << ADC_CTRLB_FREERUN_Pos)
188 #define ADC_CTRLB_CORREN_Pos        3            /**< \brief (ADC_CTRLB) Digital Correction Logic Enabled */
189 #define ADC_CTRLB_CORREN            (_U_(0x1) << ADC_CTRLB_CORREN_Pos)
190 #define ADC_CTRLB_RESSEL_Pos        4            /**< \brief (ADC_CTRLB) Conversion Result Resolution */
191 #define ADC_CTRLB_RESSEL_Msk        (_U_(0x3) << ADC_CTRLB_RESSEL_Pos)
192 #define ADC_CTRLB_RESSEL(value)     (ADC_CTRLB_RESSEL_Msk & ((value) << ADC_CTRLB_RESSEL_Pos))
193 #define   ADC_CTRLB_RESSEL_12BIT_Val      _U_(0x0)   /**< \brief (ADC_CTRLB) 12-bit result */
194 #define   ADC_CTRLB_RESSEL_16BIT_Val      _U_(0x1)   /**< \brief (ADC_CTRLB) For averaging mode output */
195 #define   ADC_CTRLB_RESSEL_10BIT_Val      _U_(0x2)   /**< \brief (ADC_CTRLB) 10-bit result */
196 #define   ADC_CTRLB_RESSEL_8BIT_Val       _U_(0x3)   /**< \brief (ADC_CTRLB) 8-bit result */
197 #define ADC_CTRLB_RESSEL_12BIT      (ADC_CTRLB_RESSEL_12BIT_Val    << ADC_CTRLB_RESSEL_Pos)
198 #define ADC_CTRLB_RESSEL_16BIT      (ADC_CTRLB_RESSEL_16BIT_Val    << ADC_CTRLB_RESSEL_Pos)
199 #define ADC_CTRLB_RESSEL_10BIT      (ADC_CTRLB_RESSEL_10BIT_Val    << ADC_CTRLB_RESSEL_Pos)
200 #define ADC_CTRLB_RESSEL_8BIT       (ADC_CTRLB_RESSEL_8BIT_Val     << ADC_CTRLB_RESSEL_Pos)
201 #define ADC_CTRLB_PRESCALER_Pos     8            /**< \brief (ADC_CTRLB) Prescaler Configuration */
202 #define ADC_CTRLB_PRESCALER_Msk     (_U_(0x7) << ADC_CTRLB_PRESCALER_Pos)
203 #define ADC_CTRLB_PRESCALER(value)  (ADC_CTRLB_PRESCALER_Msk & ((value) << ADC_CTRLB_PRESCALER_Pos))
204 #define   ADC_CTRLB_PRESCALER_DIV4_Val    _U_(0x0)   /**< \brief (ADC_CTRLB) Peripheral clock divided by 4 */
205 #define   ADC_CTRLB_PRESCALER_DIV8_Val    _U_(0x1)   /**< \brief (ADC_CTRLB) Peripheral clock divided by 8 */
206 #define   ADC_CTRLB_PRESCALER_DIV16_Val   _U_(0x2)   /**< \brief (ADC_CTRLB) Peripheral clock divided by 16 */
207 #define   ADC_CTRLB_PRESCALER_DIV32_Val   _U_(0x3)   /**< \brief (ADC_CTRLB) Peripheral clock divided by 32 */
208 #define   ADC_CTRLB_PRESCALER_DIV64_Val   _U_(0x4)   /**< \brief (ADC_CTRLB) Peripheral clock divided by 64 */
209 #define   ADC_CTRLB_PRESCALER_DIV128_Val  _U_(0x5)   /**< \brief (ADC_CTRLB) Peripheral clock divided by 128 */
210 #define   ADC_CTRLB_PRESCALER_DIV256_Val  _U_(0x6)   /**< \brief (ADC_CTRLB) Peripheral clock divided by 256 */
211 #define   ADC_CTRLB_PRESCALER_DIV512_Val  _U_(0x7)   /**< \brief (ADC_CTRLB) Peripheral clock divided by 512 */
212 #define ADC_CTRLB_PRESCALER_DIV4    (ADC_CTRLB_PRESCALER_DIV4_Val  << ADC_CTRLB_PRESCALER_Pos)
213 #define ADC_CTRLB_PRESCALER_DIV8    (ADC_CTRLB_PRESCALER_DIV8_Val  << ADC_CTRLB_PRESCALER_Pos)
214 #define ADC_CTRLB_PRESCALER_DIV16   (ADC_CTRLB_PRESCALER_DIV16_Val << ADC_CTRLB_PRESCALER_Pos)
215 #define ADC_CTRLB_PRESCALER_DIV32   (ADC_CTRLB_PRESCALER_DIV32_Val << ADC_CTRLB_PRESCALER_Pos)
216 #define ADC_CTRLB_PRESCALER_DIV64   (ADC_CTRLB_PRESCALER_DIV64_Val << ADC_CTRLB_PRESCALER_Pos)
217 #define ADC_CTRLB_PRESCALER_DIV128  (ADC_CTRLB_PRESCALER_DIV128_Val << ADC_CTRLB_PRESCALER_Pos)
218 #define ADC_CTRLB_PRESCALER_DIV256  (ADC_CTRLB_PRESCALER_DIV256_Val << ADC_CTRLB_PRESCALER_Pos)
219 #define ADC_CTRLB_PRESCALER_DIV512  (ADC_CTRLB_PRESCALER_DIV512_Val << ADC_CTRLB_PRESCALER_Pos)
220 #define ADC_CTRLB_MASK              _U_(0x073F)  /**< \brief (ADC_CTRLB) MASK Register */
221 
222 /* -------- ADC_WINCTRL : (ADC Offset: 0x08) (R/W  8) Window Monitor Control -------- */
223 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
224 typedef union {
225   struct {
226     uint8_t  WINMODE:3;        /*!< bit:  0.. 2  Window Monitor Mode                */
227     uint8_t  :5;               /*!< bit:  3.. 7  Reserved                           */
228   } bit;                       /*!< Structure used for bit  access                  */
229   uint8_t reg;                 /*!< Type      used for register access              */
230 } ADC_WINCTRL_Type;
231 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
232 
233 #define ADC_WINCTRL_OFFSET          0x08         /**< \brief (ADC_WINCTRL offset) Window Monitor Control */
234 #define ADC_WINCTRL_RESETVALUE      _U_(0x00)    /**< \brief (ADC_WINCTRL reset_value) Window Monitor Control */
235 
236 #define ADC_WINCTRL_WINMODE_Pos     0            /**< \brief (ADC_WINCTRL) Window Monitor Mode */
237 #define ADC_WINCTRL_WINMODE_Msk     (_U_(0x7) << ADC_WINCTRL_WINMODE_Pos)
238 #define ADC_WINCTRL_WINMODE(value)  (ADC_WINCTRL_WINMODE_Msk & ((value) << ADC_WINCTRL_WINMODE_Pos))
239 #define   ADC_WINCTRL_WINMODE_DISABLE_Val _U_(0x0)   /**< \brief (ADC_WINCTRL) No window mode (default) */
240 #define   ADC_WINCTRL_WINMODE_MODE1_Val   _U_(0x1)   /**< \brief (ADC_WINCTRL) Mode 1: RESULT > WINLT */
241 #define   ADC_WINCTRL_WINMODE_MODE2_Val   _U_(0x2)   /**< \brief (ADC_WINCTRL) Mode 2: RESULT < WINUT */
242 #define   ADC_WINCTRL_WINMODE_MODE3_Val   _U_(0x3)   /**< \brief (ADC_WINCTRL) Mode 3: WINLT < RESULT < WINUT */
243 #define   ADC_WINCTRL_WINMODE_MODE4_Val   _U_(0x4)   /**< \brief (ADC_WINCTRL) Mode 4: !(WINLT < RESULT < WINUT) */
244 #define ADC_WINCTRL_WINMODE_DISABLE (ADC_WINCTRL_WINMODE_DISABLE_Val << ADC_WINCTRL_WINMODE_Pos)
245 #define ADC_WINCTRL_WINMODE_MODE1   (ADC_WINCTRL_WINMODE_MODE1_Val << ADC_WINCTRL_WINMODE_Pos)
246 #define ADC_WINCTRL_WINMODE_MODE2   (ADC_WINCTRL_WINMODE_MODE2_Val << ADC_WINCTRL_WINMODE_Pos)
247 #define ADC_WINCTRL_WINMODE_MODE3   (ADC_WINCTRL_WINMODE_MODE3_Val << ADC_WINCTRL_WINMODE_Pos)
248 #define ADC_WINCTRL_WINMODE_MODE4   (ADC_WINCTRL_WINMODE_MODE4_Val << ADC_WINCTRL_WINMODE_Pos)
249 #define ADC_WINCTRL_MASK            _U_(0x07)    /**< \brief (ADC_WINCTRL) MASK Register */
250 
251 /* -------- ADC_SWTRIG : (ADC Offset: 0x0C) (R/W  8) Software Trigger -------- */
252 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
253 typedef union {
254   struct {
255     uint8_t  FLUSH:1;          /*!< bit:      0  ADC Conversion Flush               */
256     uint8_t  START:1;          /*!< bit:      1  ADC Start Conversion               */
257     uint8_t  :6;               /*!< bit:  2.. 7  Reserved                           */
258   } bit;                       /*!< Structure used for bit  access                  */
259   uint8_t reg;                 /*!< Type      used for register access              */
260 } ADC_SWTRIG_Type;
261 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
262 
263 #define ADC_SWTRIG_OFFSET           0x0C         /**< \brief (ADC_SWTRIG offset) Software Trigger */
264 #define ADC_SWTRIG_RESETVALUE       _U_(0x00)    /**< \brief (ADC_SWTRIG reset_value) Software Trigger */
265 
266 #define ADC_SWTRIG_FLUSH_Pos        0            /**< \brief (ADC_SWTRIG) ADC Conversion Flush */
267 #define ADC_SWTRIG_FLUSH            (_U_(0x1) << ADC_SWTRIG_FLUSH_Pos)
268 #define ADC_SWTRIG_START_Pos        1            /**< \brief (ADC_SWTRIG) ADC Start Conversion */
269 #define ADC_SWTRIG_START            (_U_(0x1) << ADC_SWTRIG_START_Pos)
270 #define ADC_SWTRIG_MASK             _U_(0x03)    /**< \brief (ADC_SWTRIG) MASK Register */
271 
272 /* -------- ADC_INPUTCTRL : (ADC Offset: 0x10) (R/W 32) Inputs Control -------- */
273 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
274 typedef union {
275   struct {
276     uint32_t MUXPOS:5;         /*!< bit:  0.. 4  Positive MUX Input Selection       */
277     uint32_t :3;               /*!< bit:  5.. 7  Reserved                           */
278     uint32_t MUXNEG:5;         /*!< bit:  8..12  Negative MUX Input Selection       */
279     uint32_t :3;               /*!< bit: 13..15  Reserved                           */
280     uint32_t INPUTSCAN:4;      /*!< bit: 16..19  Number of Input Channels Included in Scan */
281     uint32_t INPUTOFFSET:4;    /*!< bit: 20..23  Positive MUX Setting Offset        */
282     uint32_t GAIN:4;           /*!< bit: 24..27  Gain Factor Selection              */
283     uint32_t :4;               /*!< bit: 28..31  Reserved                           */
284   } bit;                       /*!< Structure used for bit  access                  */
285   uint32_t reg;                /*!< Type      used for register access              */
286 } ADC_INPUTCTRL_Type;
287 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
288 
289 #define ADC_INPUTCTRL_OFFSET        0x10         /**< \brief (ADC_INPUTCTRL offset) Inputs Control */
290 #define ADC_INPUTCTRL_RESETVALUE    _U_(0x00000000) /**< \brief (ADC_INPUTCTRL reset_value) Inputs Control */
291 
292 #define ADC_INPUTCTRL_MUXPOS_Pos    0            /**< \brief (ADC_INPUTCTRL) Positive MUX Input Selection */
293 #define ADC_INPUTCTRL_MUXPOS_Msk    (_U_(0x1F) << ADC_INPUTCTRL_MUXPOS_Pos)
294 #define ADC_INPUTCTRL_MUXPOS(value) (ADC_INPUTCTRL_MUXPOS_Msk & ((value) << ADC_INPUTCTRL_MUXPOS_Pos))
295 #define   ADC_INPUTCTRL_MUXPOS_PIN0_Val   _U_(0x0)   /**< \brief (ADC_INPUTCTRL) ADC AIN0 Pin */
296 #define   ADC_INPUTCTRL_MUXPOS_PIN1_Val   _U_(0x1)   /**< \brief (ADC_INPUTCTRL) ADC AIN1 Pin */
297 #define   ADC_INPUTCTRL_MUXPOS_PIN2_Val   _U_(0x2)   /**< \brief (ADC_INPUTCTRL) ADC AIN2 Pin */
298 #define   ADC_INPUTCTRL_MUXPOS_PIN3_Val   _U_(0x3)   /**< \brief (ADC_INPUTCTRL) ADC AIN3 Pin */
299 #define   ADC_INPUTCTRL_MUXPOS_PIN4_Val   _U_(0x4)   /**< \brief (ADC_INPUTCTRL) ADC AIN4 Pin */
300 #define   ADC_INPUTCTRL_MUXPOS_PIN5_Val   _U_(0x5)   /**< \brief (ADC_INPUTCTRL) ADC AIN5 Pin */
301 #define   ADC_INPUTCTRL_MUXPOS_PIN6_Val   _U_(0x6)   /**< \brief (ADC_INPUTCTRL) ADC AIN6 Pin */
302 #define   ADC_INPUTCTRL_MUXPOS_PIN7_Val   _U_(0x7)   /**< \brief (ADC_INPUTCTRL) ADC AIN7 Pin */
303 #define   ADC_INPUTCTRL_MUXPOS_PIN8_Val   _U_(0x8)   /**< \brief (ADC_INPUTCTRL) ADC AIN8 Pin */
304 #define   ADC_INPUTCTRL_MUXPOS_PIN9_Val   _U_(0x9)   /**< \brief (ADC_INPUTCTRL) ADC AIN9 Pin */
305 #define   ADC_INPUTCTRL_MUXPOS_PIN10_Val  _U_(0xA)   /**< \brief (ADC_INPUTCTRL) ADC AIN10 Pin */
306 #define   ADC_INPUTCTRL_MUXPOS_PIN11_Val  _U_(0xB)   /**< \brief (ADC_INPUTCTRL) ADC AIN11 Pin */
307 #define   ADC_INPUTCTRL_MUXPOS_PIN12_Val  _U_(0xC)   /**< \brief (ADC_INPUTCTRL) ADC AIN12 Pin */
308 #define   ADC_INPUTCTRL_MUXPOS_PIN13_Val  _U_(0xD)   /**< \brief (ADC_INPUTCTRL) ADC AIN13 Pin */
309 #define   ADC_INPUTCTRL_MUXPOS_PIN14_Val  _U_(0xE)   /**< \brief (ADC_INPUTCTRL) ADC AIN14 Pin */
310 #define   ADC_INPUTCTRL_MUXPOS_PIN15_Val  _U_(0xF)   /**< \brief (ADC_INPUTCTRL) ADC AIN15 Pin */
311 #define   ADC_INPUTCTRL_MUXPOS_PIN16_Val  _U_(0x10)   /**< \brief (ADC_INPUTCTRL) ADC AIN16 Pin */
312 #define   ADC_INPUTCTRL_MUXPOS_PIN17_Val  _U_(0x11)   /**< \brief (ADC_INPUTCTRL) ADC AIN17 Pin */
313 #define   ADC_INPUTCTRL_MUXPOS_PIN18_Val  _U_(0x12)   /**< \brief (ADC_INPUTCTRL) ADC AIN18 Pin */
314 #define   ADC_INPUTCTRL_MUXPOS_PIN19_Val  _U_(0x13)   /**< \brief (ADC_INPUTCTRL) ADC AIN19 Pin */
315 #define   ADC_INPUTCTRL_MUXPOS_TEMP_Val   _U_(0x18)   /**< \brief (ADC_INPUTCTRL) Temperature Reference */
316 #define   ADC_INPUTCTRL_MUXPOS_BANDGAP_Val _U_(0x19)   /**< \brief (ADC_INPUTCTRL) Bandgap Voltage */
317 #define   ADC_INPUTCTRL_MUXPOS_SCALEDCOREVCC_Val _U_(0x1A)   /**< \brief (ADC_INPUTCTRL) 1/4  Scaled Core Supply */
318 #define   ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val _U_(0x1B)   /**< \brief (ADC_INPUTCTRL) 1/4  Scaled I/O Supply */
319 #define   ADC_INPUTCTRL_MUXPOS_DAC_Val    _U_(0x1C)   /**< \brief (ADC_INPUTCTRL) DAC Output */
320 #define ADC_INPUTCTRL_MUXPOS_PIN0   (ADC_INPUTCTRL_MUXPOS_PIN0_Val << ADC_INPUTCTRL_MUXPOS_Pos)
321 #define ADC_INPUTCTRL_MUXPOS_PIN1   (ADC_INPUTCTRL_MUXPOS_PIN1_Val << ADC_INPUTCTRL_MUXPOS_Pos)
322 #define ADC_INPUTCTRL_MUXPOS_PIN2   (ADC_INPUTCTRL_MUXPOS_PIN2_Val << ADC_INPUTCTRL_MUXPOS_Pos)
323 #define ADC_INPUTCTRL_MUXPOS_PIN3   (ADC_INPUTCTRL_MUXPOS_PIN3_Val << ADC_INPUTCTRL_MUXPOS_Pos)
324 #define ADC_INPUTCTRL_MUXPOS_PIN4   (ADC_INPUTCTRL_MUXPOS_PIN4_Val << ADC_INPUTCTRL_MUXPOS_Pos)
325 #define ADC_INPUTCTRL_MUXPOS_PIN5   (ADC_INPUTCTRL_MUXPOS_PIN5_Val << ADC_INPUTCTRL_MUXPOS_Pos)
326 #define ADC_INPUTCTRL_MUXPOS_PIN6   (ADC_INPUTCTRL_MUXPOS_PIN6_Val << ADC_INPUTCTRL_MUXPOS_Pos)
327 #define ADC_INPUTCTRL_MUXPOS_PIN7   (ADC_INPUTCTRL_MUXPOS_PIN7_Val << ADC_INPUTCTRL_MUXPOS_Pos)
328 #define ADC_INPUTCTRL_MUXPOS_PIN8   (ADC_INPUTCTRL_MUXPOS_PIN8_Val << ADC_INPUTCTRL_MUXPOS_Pos)
329 #define ADC_INPUTCTRL_MUXPOS_PIN9   (ADC_INPUTCTRL_MUXPOS_PIN9_Val << ADC_INPUTCTRL_MUXPOS_Pos)
330 #define ADC_INPUTCTRL_MUXPOS_PIN10  (ADC_INPUTCTRL_MUXPOS_PIN10_Val << ADC_INPUTCTRL_MUXPOS_Pos)
331 #define ADC_INPUTCTRL_MUXPOS_PIN11  (ADC_INPUTCTRL_MUXPOS_PIN11_Val << ADC_INPUTCTRL_MUXPOS_Pos)
332 #define ADC_INPUTCTRL_MUXPOS_PIN12  (ADC_INPUTCTRL_MUXPOS_PIN12_Val << ADC_INPUTCTRL_MUXPOS_Pos)
333 #define ADC_INPUTCTRL_MUXPOS_PIN13  (ADC_INPUTCTRL_MUXPOS_PIN13_Val << ADC_INPUTCTRL_MUXPOS_Pos)
334 #define ADC_INPUTCTRL_MUXPOS_PIN14  (ADC_INPUTCTRL_MUXPOS_PIN14_Val << ADC_INPUTCTRL_MUXPOS_Pos)
335 #define ADC_INPUTCTRL_MUXPOS_PIN15  (ADC_INPUTCTRL_MUXPOS_PIN15_Val << ADC_INPUTCTRL_MUXPOS_Pos)
336 #define ADC_INPUTCTRL_MUXPOS_PIN16  (ADC_INPUTCTRL_MUXPOS_PIN16_Val << ADC_INPUTCTRL_MUXPOS_Pos)
337 #define ADC_INPUTCTRL_MUXPOS_PIN17  (ADC_INPUTCTRL_MUXPOS_PIN17_Val << ADC_INPUTCTRL_MUXPOS_Pos)
338 #define ADC_INPUTCTRL_MUXPOS_PIN18  (ADC_INPUTCTRL_MUXPOS_PIN18_Val << ADC_INPUTCTRL_MUXPOS_Pos)
339 #define ADC_INPUTCTRL_MUXPOS_PIN19  (ADC_INPUTCTRL_MUXPOS_PIN19_Val << ADC_INPUTCTRL_MUXPOS_Pos)
340 #define ADC_INPUTCTRL_MUXPOS_TEMP   (ADC_INPUTCTRL_MUXPOS_TEMP_Val << ADC_INPUTCTRL_MUXPOS_Pos)
341 #define ADC_INPUTCTRL_MUXPOS_BANDGAP (ADC_INPUTCTRL_MUXPOS_BANDGAP_Val << ADC_INPUTCTRL_MUXPOS_Pos)
342 #define ADC_INPUTCTRL_MUXPOS_SCALEDCOREVCC (ADC_INPUTCTRL_MUXPOS_SCALEDCOREVCC_Val << ADC_INPUTCTRL_MUXPOS_Pos)
343 #define ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC (ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val << ADC_INPUTCTRL_MUXPOS_Pos)
344 #define ADC_INPUTCTRL_MUXPOS_DAC    (ADC_INPUTCTRL_MUXPOS_DAC_Val  << ADC_INPUTCTRL_MUXPOS_Pos)
345 #define ADC_INPUTCTRL_MUXNEG_Pos    8            /**< \brief (ADC_INPUTCTRL) Negative MUX Input Selection */
346 #define ADC_INPUTCTRL_MUXNEG_Msk    (_U_(0x1F) << ADC_INPUTCTRL_MUXNEG_Pos)
347 #define ADC_INPUTCTRL_MUXNEG(value) (ADC_INPUTCTRL_MUXNEG_Msk & ((value) << ADC_INPUTCTRL_MUXNEG_Pos))
348 #define   ADC_INPUTCTRL_MUXNEG_PIN0_Val   _U_(0x0)   /**< \brief (ADC_INPUTCTRL) ADC AIN0 Pin */
349 #define   ADC_INPUTCTRL_MUXNEG_PIN1_Val   _U_(0x1)   /**< \brief (ADC_INPUTCTRL) ADC AIN1 Pin */
350 #define   ADC_INPUTCTRL_MUXNEG_PIN2_Val   _U_(0x2)   /**< \brief (ADC_INPUTCTRL) ADC AIN2 Pin */
351 #define   ADC_INPUTCTRL_MUXNEG_PIN3_Val   _U_(0x3)   /**< \brief (ADC_INPUTCTRL) ADC AIN3 Pin */
352 #define   ADC_INPUTCTRL_MUXNEG_PIN4_Val   _U_(0x4)   /**< \brief (ADC_INPUTCTRL) ADC AIN4 Pin */
353 #define   ADC_INPUTCTRL_MUXNEG_PIN5_Val   _U_(0x5)   /**< \brief (ADC_INPUTCTRL) ADC AIN5 Pin */
354 #define   ADC_INPUTCTRL_MUXNEG_PIN6_Val   _U_(0x6)   /**< \brief (ADC_INPUTCTRL) ADC AIN6 Pin */
355 #define   ADC_INPUTCTRL_MUXNEG_PIN7_Val   _U_(0x7)   /**< \brief (ADC_INPUTCTRL) ADC AIN7 Pin */
356 #define   ADC_INPUTCTRL_MUXNEG_GND_Val    _U_(0x18)   /**< \brief (ADC_INPUTCTRL) Internal ground */
357 #define   ADC_INPUTCTRL_MUXNEG_IOGND_Val  _U_(0x19)   /**< \brief (ADC_INPUTCTRL) IO ground */
358 #define ADC_INPUTCTRL_MUXNEG_PIN0   (ADC_INPUTCTRL_MUXNEG_PIN0_Val << ADC_INPUTCTRL_MUXNEG_Pos)
359 #define ADC_INPUTCTRL_MUXNEG_PIN1   (ADC_INPUTCTRL_MUXNEG_PIN1_Val << ADC_INPUTCTRL_MUXNEG_Pos)
360 #define ADC_INPUTCTRL_MUXNEG_PIN2   (ADC_INPUTCTRL_MUXNEG_PIN2_Val << ADC_INPUTCTRL_MUXNEG_Pos)
361 #define ADC_INPUTCTRL_MUXNEG_PIN3   (ADC_INPUTCTRL_MUXNEG_PIN3_Val << ADC_INPUTCTRL_MUXNEG_Pos)
362 #define ADC_INPUTCTRL_MUXNEG_PIN4   (ADC_INPUTCTRL_MUXNEG_PIN4_Val << ADC_INPUTCTRL_MUXNEG_Pos)
363 #define ADC_INPUTCTRL_MUXNEG_PIN5   (ADC_INPUTCTRL_MUXNEG_PIN5_Val << ADC_INPUTCTRL_MUXNEG_Pos)
364 #define ADC_INPUTCTRL_MUXNEG_PIN6   (ADC_INPUTCTRL_MUXNEG_PIN6_Val << ADC_INPUTCTRL_MUXNEG_Pos)
365 #define ADC_INPUTCTRL_MUXNEG_PIN7   (ADC_INPUTCTRL_MUXNEG_PIN7_Val << ADC_INPUTCTRL_MUXNEG_Pos)
366 #define ADC_INPUTCTRL_MUXNEG_GND    (ADC_INPUTCTRL_MUXNEG_GND_Val  << ADC_INPUTCTRL_MUXNEG_Pos)
367 #define ADC_INPUTCTRL_MUXNEG_IOGND  (ADC_INPUTCTRL_MUXNEG_IOGND_Val << ADC_INPUTCTRL_MUXNEG_Pos)
368 #define ADC_INPUTCTRL_INPUTSCAN_Pos 16           /**< \brief (ADC_INPUTCTRL) Number of Input Channels Included in Scan */
369 #define ADC_INPUTCTRL_INPUTSCAN_Msk (_U_(0xF) << ADC_INPUTCTRL_INPUTSCAN_Pos)
370 #define ADC_INPUTCTRL_INPUTSCAN(value) (ADC_INPUTCTRL_INPUTSCAN_Msk & ((value) << ADC_INPUTCTRL_INPUTSCAN_Pos))
371 #define ADC_INPUTCTRL_INPUTOFFSET_Pos 20           /**< \brief (ADC_INPUTCTRL) Positive MUX Setting Offset */
372 #define ADC_INPUTCTRL_INPUTOFFSET_Msk (_U_(0xF) << ADC_INPUTCTRL_INPUTOFFSET_Pos)
373 #define ADC_INPUTCTRL_INPUTOFFSET(value) (ADC_INPUTCTRL_INPUTOFFSET_Msk & ((value) << ADC_INPUTCTRL_INPUTOFFSET_Pos))
374 #define ADC_INPUTCTRL_GAIN_Pos      24           /**< \brief (ADC_INPUTCTRL) Gain Factor Selection */
375 #define ADC_INPUTCTRL_GAIN_Msk      (_U_(0xF) << ADC_INPUTCTRL_GAIN_Pos)
376 #define ADC_INPUTCTRL_GAIN(value)   (ADC_INPUTCTRL_GAIN_Msk & ((value) << ADC_INPUTCTRL_GAIN_Pos))
377 #define   ADC_INPUTCTRL_GAIN_1X_Val       _U_(0x0)   /**< \brief (ADC_INPUTCTRL) 1x */
378 #define   ADC_INPUTCTRL_GAIN_2X_Val       _U_(0x1)   /**< \brief (ADC_INPUTCTRL) 2x */
379 #define   ADC_INPUTCTRL_GAIN_4X_Val       _U_(0x2)   /**< \brief (ADC_INPUTCTRL) 4x */
380 #define   ADC_INPUTCTRL_GAIN_8X_Val       _U_(0x3)   /**< \brief (ADC_INPUTCTRL) 8x */
381 #define   ADC_INPUTCTRL_GAIN_16X_Val      _U_(0x4)   /**< \brief (ADC_INPUTCTRL) 16x */
382 #define   ADC_INPUTCTRL_GAIN_DIV2_Val     _U_(0xF)   /**< \brief (ADC_INPUTCTRL) 1/2x */
383 #define ADC_INPUTCTRL_GAIN_1X       (ADC_INPUTCTRL_GAIN_1X_Val     << ADC_INPUTCTRL_GAIN_Pos)
384 #define ADC_INPUTCTRL_GAIN_2X       (ADC_INPUTCTRL_GAIN_2X_Val     << ADC_INPUTCTRL_GAIN_Pos)
385 #define ADC_INPUTCTRL_GAIN_4X       (ADC_INPUTCTRL_GAIN_4X_Val     << ADC_INPUTCTRL_GAIN_Pos)
386 #define ADC_INPUTCTRL_GAIN_8X       (ADC_INPUTCTRL_GAIN_8X_Val     << ADC_INPUTCTRL_GAIN_Pos)
387 #define ADC_INPUTCTRL_GAIN_16X      (ADC_INPUTCTRL_GAIN_16X_Val    << ADC_INPUTCTRL_GAIN_Pos)
388 #define ADC_INPUTCTRL_GAIN_DIV2     (ADC_INPUTCTRL_GAIN_DIV2_Val   << ADC_INPUTCTRL_GAIN_Pos)
389 #define ADC_INPUTCTRL_MASK          _U_(0x0FFF1F1F) /**< \brief (ADC_INPUTCTRL) MASK Register */
390 
391 /* -------- ADC_EVCTRL : (ADC Offset: 0x14) (R/W  8) Event Control -------- */
392 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
393 typedef union {
394   struct {
395     uint8_t  STARTEI:1;        /*!< bit:      0  Start Conversion Event In          */
396     uint8_t  SYNCEI:1;         /*!< bit:      1  Synchronization Event In           */
397     uint8_t  :2;               /*!< bit:  2.. 3  Reserved                           */
398     uint8_t  RESRDYEO:1;       /*!< bit:      4  Result Ready Event Out             */
399     uint8_t  WINMONEO:1;       /*!< bit:      5  Window Monitor Event Out           */
400     uint8_t  :2;               /*!< bit:  6.. 7  Reserved                           */
401   } bit;                       /*!< Structure used for bit  access                  */
402   uint8_t reg;                 /*!< Type      used for register access              */
403 } ADC_EVCTRL_Type;
404 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
405 
406 #define ADC_EVCTRL_OFFSET           0x14         /**< \brief (ADC_EVCTRL offset) Event Control */
407 #define ADC_EVCTRL_RESETVALUE       _U_(0x00)    /**< \brief (ADC_EVCTRL reset_value) Event Control */
408 
409 #define ADC_EVCTRL_STARTEI_Pos      0            /**< \brief (ADC_EVCTRL) Start Conversion Event In */
410 #define ADC_EVCTRL_STARTEI          (_U_(0x1) << ADC_EVCTRL_STARTEI_Pos)
411 #define ADC_EVCTRL_SYNCEI_Pos       1            /**< \brief (ADC_EVCTRL) Synchronization Event In */
412 #define ADC_EVCTRL_SYNCEI           (_U_(0x1) << ADC_EVCTRL_SYNCEI_Pos)
413 #define ADC_EVCTRL_RESRDYEO_Pos     4            /**< \brief (ADC_EVCTRL) Result Ready Event Out */
414 #define ADC_EVCTRL_RESRDYEO         (_U_(0x1) << ADC_EVCTRL_RESRDYEO_Pos)
415 #define ADC_EVCTRL_WINMONEO_Pos     5            /**< \brief (ADC_EVCTRL) Window Monitor Event Out */
416 #define ADC_EVCTRL_WINMONEO         (_U_(0x1) << ADC_EVCTRL_WINMONEO_Pos)
417 #define ADC_EVCTRL_MASK             _U_(0x33)    /**< \brief (ADC_EVCTRL) MASK Register */
418 
419 /* -------- ADC_INTENCLR : (ADC Offset: 0x16) (R/W  8) Interrupt Enable Clear -------- */
420 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
421 typedef union {
422   struct {
423     uint8_t  RESRDY:1;         /*!< bit:      0  Result Ready Interrupt Enable      */
424     uint8_t  OVERRUN:1;        /*!< bit:      1  Overrun Interrupt Enable           */
425     uint8_t  WINMON:1;         /*!< bit:      2  Window Monitor Interrupt Enable    */
426     uint8_t  SYNCRDY:1;        /*!< bit:      3  Synchronization Ready Interrupt Enable */
427     uint8_t  :4;               /*!< bit:  4.. 7  Reserved                           */
428   } bit;                       /*!< Structure used for bit  access                  */
429   uint8_t reg;                 /*!< Type      used for register access              */
430 } ADC_INTENCLR_Type;
431 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
432 
433 #define ADC_INTENCLR_OFFSET         0x16         /**< \brief (ADC_INTENCLR offset) Interrupt Enable Clear */
434 #define ADC_INTENCLR_RESETVALUE     _U_(0x00)    /**< \brief (ADC_INTENCLR reset_value) Interrupt Enable Clear */
435 
436 #define ADC_INTENCLR_RESRDY_Pos     0            /**< \brief (ADC_INTENCLR) Result Ready Interrupt Enable */
437 #define ADC_INTENCLR_RESRDY         (_U_(0x1) << ADC_INTENCLR_RESRDY_Pos)
438 #define ADC_INTENCLR_OVERRUN_Pos    1            /**< \brief (ADC_INTENCLR) Overrun Interrupt Enable */
439 #define ADC_INTENCLR_OVERRUN        (_U_(0x1) << ADC_INTENCLR_OVERRUN_Pos)
440 #define ADC_INTENCLR_WINMON_Pos     2            /**< \brief (ADC_INTENCLR) Window Monitor Interrupt Enable */
441 #define ADC_INTENCLR_WINMON         (_U_(0x1) << ADC_INTENCLR_WINMON_Pos)
442 #define ADC_INTENCLR_SYNCRDY_Pos    3            /**< \brief (ADC_INTENCLR) Synchronization Ready Interrupt Enable */
443 #define ADC_INTENCLR_SYNCRDY        (_U_(0x1) << ADC_INTENCLR_SYNCRDY_Pos)
444 #define ADC_INTENCLR_MASK           _U_(0x0F)    /**< \brief (ADC_INTENCLR) MASK Register */
445 
446 /* -------- ADC_INTENSET : (ADC Offset: 0x17) (R/W  8) Interrupt Enable Set -------- */
447 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
448 typedef union {
449   struct {
450     uint8_t  RESRDY:1;         /*!< bit:      0  Result Ready Interrupt Enable      */
451     uint8_t  OVERRUN:1;        /*!< bit:      1  Overrun Interrupt Enable           */
452     uint8_t  WINMON:1;         /*!< bit:      2  Window Monitor Interrupt Enable    */
453     uint8_t  SYNCRDY:1;        /*!< bit:      3  Synchronization Ready Interrupt Enable */
454     uint8_t  :4;               /*!< bit:  4.. 7  Reserved                           */
455   } bit;                       /*!< Structure used for bit  access                  */
456   uint8_t reg;                 /*!< Type      used for register access              */
457 } ADC_INTENSET_Type;
458 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
459 
460 #define ADC_INTENSET_OFFSET         0x17         /**< \brief (ADC_INTENSET offset) Interrupt Enable Set */
461 #define ADC_INTENSET_RESETVALUE     _U_(0x00)    /**< \brief (ADC_INTENSET reset_value) Interrupt Enable Set */
462 
463 #define ADC_INTENSET_RESRDY_Pos     0            /**< \brief (ADC_INTENSET) Result Ready Interrupt Enable */
464 #define ADC_INTENSET_RESRDY         (_U_(0x1) << ADC_INTENSET_RESRDY_Pos)
465 #define ADC_INTENSET_OVERRUN_Pos    1            /**< \brief (ADC_INTENSET) Overrun Interrupt Enable */
466 #define ADC_INTENSET_OVERRUN        (_U_(0x1) << ADC_INTENSET_OVERRUN_Pos)
467 #define ADC_INTENSET_WINMON_Pos     2            /**< \brief (ADC_INTENSET) Window Monitor Interrupt Enable */
468 #define ADC_INTENSET_WINMON         (_U_(0x1) << ADC_INTENSET_WINMON_Pos)
469 #define ADC_INTENSET_SYNCRDY_Pos    3            /**< \brief (ADC_INTENSET) Synchronization Ready Interrupt Enable */
470 #define ADC_INTENSET_SYNCRDY        (_U_(0x1) << ADC_INTENSET_SYNCRDY_Pos)
471 #define ADC_INTENSET_MASK           _U_(0x0F)    /**< \brief (ADC_INTENSET) MASK Register */
472 
473 /* -------- ADC_INTFLAG : (ADC Offset: 0x18) (R/W  8) Interrupt Flag Status and Clear -------- */
474 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
475 typedef union { // __I to avoid read-modify-write on write-to-clear register
476   struct {
477     __I uint8_t  RESRDY:1;         /*!< bit:      0  Result Ready                       */
478     __I uint8_t  OVERRUN:1;        /*!< bit:      1  Overrun                            */
479     __I uint8_t  WINMON:1;         /*!< bit:      2  Window Monitor                     */
480     __I uint8_t  SYNCRDY:1;        /*!< bit:      3  Synchronization Ready              */
481     __I uint8_t  Reserved1:4;      /*!< bit:  4.. 7  Reserved                           */
482   } bit;                       /*!< Structure used for bit  access                  */
483   uint8_t reg;                 /*!< Type      used for register access              */
484 } ADC_INTFLAG_Type;
485 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
486 
487 #define ADC_INTFLAG_OFFSET          0x18         /**< \brief (ADC_INTFLAG offset) Interrupt Flag Status and Clear */
488 #define ADC_INTFLAG_RESETVALUE      _U_(0x00)    /**< \brief (ADC_INTFLAG reset_value) Interrupt Flag Status and Clear */
489 
490 #define ADC_INTFLAG_RESRDY_Pos      0            /**< \brief (ADC_INTFLAG) Result Ready */
491 #define ADC_INTFLAG_RESRDY          (_U_(0x1) << ADC_INTFLAG_RESRDY_Pos)
492 #define ADC_INTFLAG_OVERRUN_Pos     1            /**< \brief (ADC_INTFLAG) Overrun */
493 #define ADC_INTFLAG_OVERRUN         (_U_(0x1) << ADC_INTFLAG_OVERRUN_Pos)
494 #define ADC_INTFLAG_WINMON_Pos      2            /**< \brief (ADC_INTFLAG) Window Monitor */
495 #define ADC_INTFLAG_WINMON          (_U_(0x1) << ADC_INTFLAG_WINMON_Pos)
496 #define ADC_INTFLAG_SYNCRDY_Pos     3            /**< \brief (ADC_INTFLAG) Synchronization Ready */
497 #define ADC_INTFLAG_SYNCRDY         (_U_(0x1) << ADC_INTFLAG_SYNCRDY_Pos)
498 #define ADC_INTFLAG_MASK            _U_(0x0F)    /**< \brief (ADC_INTFLAG) MASK Register */
499 
500 /* -------- ADC_STATUS : (ADC Offset: 0x19) (R/   8) Status -------- */
501 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
502 typedef union {
503   struct {
504     uint8_t  :7;               /*!< bit:  0.. 6  Reserved                           */
505     uint8_t  SYNCBUSY:1;       /*!< bit:      7  Synchronization Busy               */
506   } bit;                       /*!< Structure used for bit  access                  */
507   uint8_t reg;                 /*!< Type      used for register access              */
508 } ADC_STATUS_Type;
509 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
510 
511 #define ADC_STATUS_OFFSET           0x19         /**< \brief (ADC_STATUS offset) Status */
512 #define ADC_STATUS_RESETVALUE       _U_(0x00)    /**< \brief (ADC_STATUS reset_value) Status */
513 
514 #define ADC_STATUS_SYNCBUSY_Pos     7            /**< \brief (ADC_STATUS) Synchronization Busy */
515 #define ADC_STATUS_SYNCBUSY         (_U_(0x1) << ADC_STATUS_SYNCBUSY_Pos)
516 #define ADC_STATUS_MASK             _U_(0x80)    /**< \brief (ADC_STATUS) MASK Register */
517 
518 /* -------- ADC_RESULT : (ADC Offset: 0x1A) (R/  16) Result -------- */
519 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
520 typedef union {
521   struct {
522     uint16_t RESULT:16;        /*!< bit:  0..15  Result Conversion Value            */
523   } bit;                       /*!< Structure used for bit  access                  */
524   uint16_t reg;                /*!< Type      used for register access              */
525 } ADC_RESULT_Type;
526 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
527 
528 #define ADC_RESULT_OFFSET           0x1A         /**< \brief (ADC_RESULT offset) Result */
529 #define ADC_RESULT_RESETVALUE       _U_(0x0000)  /**< \brief (ADC_RESULT reset_value) Result */
530 
531 #define ADC_RESULT_RESULT_Pos       0            /**< \brief (ADC_RESULT) Result Conversion Value */
532 #define ADC_RESULT_RESULT_Msk       (_U_(0xFFFF) << ADC_RESULT_RESULT_Pos)
533 #define ADC_RESULT_RESULT(value)    (ADC_RESULT_RESULT_Msk & ((value) << ADC_RESULT_RESULT_Pos))
534 #define ADC_RESULT_MASK             _U_(0xFFFF)  /**< \brief (ADC_RESULT) MASK Register */
535 
536 /* -------- ADC_WINLT : (ADC Offset: 0x1C) (R/W 16) Window Monitor Lower Threshold -------- */
537 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
538 typedef union {
539   struct {
540     uint16_t WINLT:16;         /*!< bit:  0..15  Window Lower Threshold             */
541   } bit;                       /*!< Structure used for bit  access                  */
542   uint16_t reg;                /*!< Type      used for register access              */
543 } ADC_WINLT_Type;
544 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
545 
546 #define ADC_WINLT_OFFSET            0x1C         /**< \brief (ADC_WINLT offset) Window Monitor Lower Threshold */
547 #define ADC_WINLT_RESETVALUE        _U_(0x0000)  /**< \brief (ADC_WINLT reset_value) Window Monitor Lower Threshold */
548 
549 #define ADC_WINLT_WINLT_Pos         0            /**< \brief (ADC_WINLT) Window Lower Threshold */
550 #define ADC_WINLT_WINLT_Msk         (_U_(0xFFFF) << ADC_WINLT_WINLT_Pos)
551 #define ADC_WINLT_WINLT(value)      (ADC_WINLT_WINLT_Msk & ((value) << ADC_WINLT_WINLT_Pos))
552 #define ADC_WINLT_MASK              _U_(0xFFFF)  /**< \brief (ADC_WINLT) MASK Register */
553 
554 /* -------- ADC_WINUT : (ADC Offset: 0x20) (R/W 16) Window Monitor Upper Threshold -------- */
555 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
556 typedef union {
557   struct {
558     uint16_t WINUT:16;         /*!< bit:  0..15  Window Upper Threshold             */
559   } bit;                       /*!< Structure used for bit  access                  */
560   uint16_t reg;                /*!< Type      used for register access              */
561 } ADC_WINUT_Type;
562 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
563 
564 #define ADC_WINUT_OFFSET            0x20         /**< \brief (ADC_WINUT offset) Window Monitor Upper Threshold */
565 #define ADC_WINUT_RESETVALUE        _U_(0x0000)  /**< \brief (ADC_WINUT reset_value) Window Monitor Upper Threshold */
566 
567 #define ADC_WINUT_WINUT_Pos         0            /**< \brief (ADC_WINUT) Window Upper Threshold */
568 #define ADC_WINUT_WINUT_Msk         (_U_(0xFFFF) << ADC_WINUT_WINUT_Pos)
569 #define ADC_WINUT_WINUT(value)      (ADC_WINUT_WINUT_Msk & ((value) << ADC_WINUT_WINUT_Pos))
570 #define ADC_WINUT_MASK              _U_(0xFFFF)  /**< \brief (ADC_WINUT) MASK Register */
571 
572 /* -------- ADC_GAINCORR : (ADC Offset: 0x24) (R/W 16) Gain Correction -------- */
573 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
574 typedef union {
575   struct {
576     uint16_t GAINCORR:12;      /*!< bit:  0..11  Gain Correction Value              */
577     uint16_t :4;               /*!< bit: 12..15  Reserved                           */
578   } bit;                       /*!< Structure used for bit  access                  */
579   uint16_t reg;                /*!< Type      used for register access              */
580 } ADC_GAINCORR_Type;
581 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
582 
583 #define ADC_GAINCORR_OFFSET         0x24         /**< \brief (ADC_GAINCORR offset) Gain Correction */
584 #define ADC_GAINCORR_RESETVALUE     _U_(0x0000)  /**< \brief (ADC_GAINCORR reset_value) Gain Correction */
585 
586 #define ADC_GAINCORR_GAINCORR_Pos   0            /**< \brief (ADC_GAINCORR) Gain Correction Value */
587 #define ADC_GAINCORR_GAINCORR_Msk   (_U_(0xFFF) << ADC_GAINCORR_GAINCORR_Pos)
588 #define ADC_GAINCORR_GAINCORR(value) (ADC_GAINCORR_GAINCORR_Msk & ((value) << ADC_GAINCORR_GAINCORR_Pos))
589 #define ADC_GAINCORR_MASK           _U_(0x0FFF)  /**< \brief (ADC_GAINCORR) MASK Register */
590 
591 /* -------- ADC_OFFSETCORR : (ADC Offset: 0x26) (R/W 16) Offset Correction -------- */
592 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
593 typedef union {
594   struct {
595     uint16_t OFFSETCORR:12;    /*!< bit:  0..11  Offset Correction Value            */
596     uint16_t :4;               /*!< bit: 12..15  Reserved                           */
597   } bit;                       /*!< Structure used for bit  access                  */
598   uint16_t reg;                /*!< Type      used for register access              */
599 } ADC_OFFSETCORR_Type;
600 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
601 
602 #define ADC_OFFSETCORR_OFFSET       0x26         /**< \brief (ADC_OFFSETCORR offset) Offset Correction */
603 #define ADC_OFFSETCORR_RESETVALUE   _U_(0x0000)  /**< \brief (ADC_OFFSETCORR reset_value) Offset Correction */
604 
605 #define ADC_OFFSETCORR_OFFSETCORR_Pos 0            /**< \brief (ADC_OFFSETCORR) Offset Correction Value */
606 #define ADC_OFFSETCORR_OFFSETCORR_Msk (_U_(0xFFF) << ADC_OFFSETCORR_OFFSETCORR_Pos)
607 #define ADC_OFFSETCORR_OFFSETCORR(value) (ADC_OFFSETCORR_OFFSETCORR_Msk & ((value) << ADC_OFFSETCORR_OFFSETCORR_Pos))
608 #define ADC_OFFSETCORR_MASK         _U_(0x0FFF)  /**< \brief (ADC_OFFSETCORR) MASK Register */
609 
610 /* -------- ADC_CALIB : (ADC Offset: 0x28) (R/W 16) Calibration -------- */
611 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
612 typedef union {
613   struct {
614     uint16_t LINEARITY_CAL:8;  /*!< bit:  0.. 7  Linearity Calibration Value        */
615     uint16_t BIAS_CAL:3;       /*!< bit:  8..10  Bias Calibration Value             */
616     uint16_t :5;               /*!< bit: 11..15  Reserved                           */
617   } bit;                       /*!< Structure used for bit  access                  */
618   uint16_t reg;                /*!< Type      used for register access              */
619 } ADC_CALIB_Type;
620 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
621 
622 #define ADC_CALIB_OFFSET            0x28         /**< \brief (ADC_CALIB offset) Calibration */
623 #define ADC_CALIB_RESETVALUE        _U_(0x0000)  /**< \brief (ADC_CALIB reset_value) Calibration */
624 
625 #define ADC_CALIB_LINEARITY_CAL_Pos 0            /**< \brief (ADC_CALIB) Linearity Calibration Value */
626 #define ADC_CALIB_LINEARITY_CAL_Msk (_U_(0xFF) << ADC_CALIB_LINEARITY_CAL_Pos)
627 #define ADC_CALIB_LINEARITY_CAL(value) (ADC_CALIB_LINEARITY_CAL_Msk & ((value) << ADC_CALIB_LINEARITY_CAL_Pos))
628 #define ADC_CALIB_BIAS_CAL_Pos      8            /**< \brief (ADC_CALIB) Bias Calibration Value */
629 #define ADC_CALIB_BIAS_CAL_Msk      (_U_(0x7) << ADC_CALIB_BIAS_CAL_Pos)
630 #define ADC_CALIB_BIAS_CAL(value)   (ADC_CALIB_BIAS_CAL_Msk & ((value) << ADC_CALIB_BIAS_CAL_Pos))
631 #define ADC_CALIB_MASK              _U_(0x07FF)  /**< \brief (ADC_CALIB) MASK Register */
632 
633 /* -------- ADC_DBGCTRL : (ADC Offset: 0x2A) (R/W  8) Debug Control -------- */
634 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
635 typedef union {
636   struct {
637     uint8_t  DBGRUN:1;         /*!< bit:      0  Debug Run                          */
638     uint8_t  :7;               /*!< bit:  1.. 7  Reserved                           */
639   } bit;                       /*!< Structure used for bit  access                  */
640   uint8_t reg;                 /*!< Type      used for register access              */
641 } ADC_DBGCTRL_Type;
642 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
643 
644 #define ADC_DBGCTRL_OFFSET          0x2A         /**< \brief (ADC_DBGCTRL offset) Debug Control */
645 #define ADC_DBGCTRL_RESETVALUE      _U_(0x00)    /**< \brief (ADC_DBGCTRL reset_value) Debug Control */
646 
647 #define ADC_DBGCTRL_DBGRUN_Pos      0            /**< \brief (ADC_DBGCTRL) Debug Run */
648 #define ADC_DBGCTRL_DBGRUN          (_U_(0x1) << ADC_DBGCTRL_DBGRUN_Pos)
649 #define ADC_DBGCTRL_MASK            _U_(0x01)    /**< \brief (ADC_DBGCTRL) MASK Register */
650 
651 /** \brief ADC hardware registers */
652 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
653 typedef struct {
654   __IO ADC_CTRLA_Type            CTRLA;       /**< \brief Offset: 0x00 (R/W  8) Control A */
655   __IO ADC_REFCTRL_Type          REFCTRL;     /**< \brief Offset: 0x01 (R/W  8) Reference Control */
656   __IO ADC_AVGCTRL_Type          AVGCTRL;     /**< \brief Offset: 0x02 (R/W  8) Average Control */
657   __IO ADC_SAMPCTRL_Type         SAMPCTRL;    /**< \brief Offset: 0x03 (R/W  8) Sampling Time Control */
658   __IO ADC_CTRLB_Type            CTRLB;       /**< \brief Offset: 0x04 (R/W 16) Control B */
659        RoReg8                    Reserved1[0x2];
660   __IO ADC_WINCTRL_Type          WINCTRL;     /**< \brief Offset: 0x08 (R/W  8) Window Monitor Control */
661        RoReg8                    Reserved2[0x3];
662   __IO ADC_SWTRIG_Type           SWTRIG;      /**< \brief Offset: 0x0C (R/W  8) Software Trigger */
663        RoReg8                    Reserved3[0x3];
664   __IO ADC_INPUTCTRL_Type        INPUTCTRL;   /**< \brief Offset: 0x10 (R/W 32) Inputs Control */
665   __IO ADC_EVCTRL_Type           EVCTRL;      /**< \brief Offset: 0x14 (R/W  8) Event Control */
666        RoReg8                    Reserved4[0x1];
667   __IO ADC_INTENCLR_Type         INTENCLR;    /**< \brief Offset: 0x16 (R/W  8) Interrupt Enable Clear */
668   __IO ADC_INTENSET_Type         INTENSET;    /**< \brief Offset: 0x17 (R/W  8) Interrupt Enable Set */
669   __IO ADC_INTFLAG_Type          INTFLAG;     /**< \brief Offset: 0x18 (R/W  8) Interrupt Flag Status and Clear */
670   __I  ADC_STATUS_Type           STATUS;      /**< \brief Offset: 0x19 (R/   8) Status */
671   __I  ADC_RESULT_Type           RESULT;      /**< \brief Offset: 0x1A (R/  16) Result */
672   __IO ADC_WINLT_Type            WINLT;       /**< \brief Offset: 0x1C (R/W 16) Window Monitor Lower Threshold */
673        RoReg8                    Reserved5[0x2];
674   __IO ADC_WINUT_Type            WINUT;       /**< \brief Offset: 0x20 (R/W 16) Window Monitor Upper Threshold */
675        RoReg8                    Reserved6[0x2];
676   __IO ADC_GAINCORR_Type         GAINCORR;    /**< \brief Offset: 0x24 (R/W 16) Gain Correction */
677   __IO ADC_OFFSETCORR_Type       OFFSETCORR;  /**< \brief Offset: 0x26 (R/W 16) Offset Correction */
678   __IO ADC_CALIB_Type            CALIB;       /**< \brief Offset: 0x28 (R/W 16) Calibration */
679   __IO ADC_DBGCTRL_Type          DBGCTRL;     /**< \brief Offset: 0x2A (R/W  8) Debug Control */
680 } Adc;
681 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
682 
683 /*@}*/
684 
685 #endif /* _SAMD20_ADC_COMPONENT_ */
686