1 |
/** |
---|
2 |
ADC1 Generated Driver API Header File |
---|
3 |
|
---|
4 |
@Company |
---|
5 |
Microchip Technology Inc. |
---|
6 |
|
---|
7 |
@File Name |
---|
8 |
adc1.h |
---|
9 |
|
---|
10 |
@Summary |
---|
11 |
This is the generated header file for the ADC1 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs |
---|
12 |
|
---|
13 |
@Description |
---|
14 |
This header file provides APIs for driver for ADC1. |
---|
15 |
Generation Information : |
---|
16 |
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2 |
---|
17 |
Device : PIC16F1579 |
---|
18 |
Driver Version : 2.01 |
---|
19 |
The generated drivers are tested against the following: |
---|
20 |
Compiler : XC8 1.45 |
---|
21 |
MPLAB : MPLAB X 4.15 |
---|
22 |
*/ |
---|
23 |
|
---|
24 |
/* |
---|
25 |
(c) 2018 Microchip Technology Inc. and its subsidiaries. |
---|
26 |
|
---|
27 |
Subject to your compliance with these terms, you may use Microchip software and any |
---|
28 |
derivatives exclusively with Microchip products. It is your responsibility to comply with third party |
---|
29 |
license terms applicable to your use of third party software (including open source software) that |
---|
30 |
may accompany Microchip software. |
---|
31 |
|
---|
32 |
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER |
---|
33 |
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY |
---|
34 |
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS |
---|
35 |
FOR A PARTICULAR PURPOSE. |
---|
36 |
|
---|
37 |
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, |
---|
38 |
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND |
---|
39 |
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP |
---|
40 |
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO |
---|
41 |
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL |
---|
42 |
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT |
---|
43 |
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS |
---|
44 |
SOFTWARE. |
---|
45 |
*/ |
---|
46 |
|
---|
47 |
#ifndef ADC1_H |
---|
48 |
#define ADC1_H |
---|
49 |
|
---|
50 |
/** |
---|
51 |
Section: Included Files |
---|
52 |
*/ |
---|
53 |
|
---|
54 |
#include <xc.h> |
---|
55 |
#include <stdint.h> |
---|
56 |
#include <stdbool.h> |
---|
57 |
|
---|
58 |
#ifdef __cplusplus // Provide C++ Compatibility |
---|
59 |
|
---|
60 |
extern "C" { |
---|
61 |
|
---|
62 |
#endif |
---|
63 |
|
---|
64 |
/** |
---|
65 |
Section: Data Types Definitions |
---|
66 |
*/ |
---|
67 |
|
---|
68 |
/** |
---|
69 |
* result size of an A/D conversion |
---|
70 |
*/ |
---|
71 |
|
---|
72 |
typedef uint16_t adc_result_t; |
---|
73 |
|
---|
74 |
/** |
---|
75 |
* result type of a Double ADC conversion |
---|
76 |
*/ |
---|
77 |
typedef struct |
---|
78 |
{ |
---|
79 |
adc_result_t adcResult1; |
---|
80 |
adc_result_t adcResult2; |
---|
81 |
} adc_sync_double_result_t; |
---|
82 |
|
---|
83 |
/** ADC Channel Definition |
---|
84 |
|
---|
85 |
@Summary |
---|
86 |
Defines the channels available for conversion. |
---|
87 |
|
---|
88 |
@Description |
---|
89 |
This routine defines the channels that are available for the module to use. |
---|
90 |
|
---|
91 |
Remarks: |
---|
92 |
None |
---|
93 |
*/ |
---|
94 |
|
---|
95 |
typedef enum |
---|
96 |
{ |
---|
97 |
ADC_BATT = 0x5, |
---|
98 |
channel_Temp = 0x1D, |
---|
99 |
channel_DAC = 0x1E, |
---|
100 |
channel_FVR = 0x1F |
---|
101 |
} adc_channel_t; |
---|
102 |
|
---|
103 |
/** |
---|
104 |
Section: ADC Module APIs |
---|
105 |
*/ |
---|
106 |
|
---|
107 |
/** |
---|
108 |
@Summary |
---|
109 |
Initializes the ADC1 |
---|
110 |
|
---|
111 |
@Description |
---|
112 |
This routine initializes the Initializes the ADC1. |
---|
113 |
This routine must be called before any other ADC1 routine is called. |
---|
114 |
This routine should only be called once during system initialization. |
---|
115 |
|
---|
116 |
@Preconditions |
---|
117 |
None |
---|
118 |
|
---|
119 |
@Param |
---|
120 |
None |
---|
121 |
|
---|
122 |
@Returns |
---|
123 |
None |
---|
124 |
|
---|
125 |
@Comment |
---|
126 |
|
---|
127 |
|
---|
128 |
@Example |
---|
129 |
<code> |
---|
130 |
uint16_t convertedValue; |
---|
131 |
|
---|
132 |
ADC1_Initialize(); |
---|
133 |
convertedValue = ADC1_GetConversionResult(); |
---|
134 |
</code> |
---|
135 |
*/ |
---|
136 |
void ADC1_Initialize(void); |
---|
137 |
|
---|
138 |
/** |
---|
139 |
@Summary |
---|
140 |
Allows selection of a channel for conversion |
---|
141 |
|
---|
142 |
@Description |
---|
143 |
This routine is used to select desired channel for conversion. |
---|
144 |
available |
---|
145 |
|
---|
146 |
@Preconditions |
---|
147 |
ADC1_Initialize() function should have been called before calling this function. |
---|
148 |
|
---|
149 |
@Returns |
---|
150 |
None |
---|
151 |
|
---|
152 |
@Param |
---|
153 |
Pass in required channel number |
---|
154 |
"For available channel refer to enum under adc.h file" |
---|
155 |
|
---|
156 |
@Example |
---|
157 |
<code> |
---|
158 |
uint16_t convertedValue; |
---|
159 |
|
---|
160 |
ADC1_Initialize(); |
---|
161 |
ADC1_SelectChannel(AN1_Channel); |
---|
162 |
ADC1_StartConversion(); |
---|
163 |
convertedValue = ADC1_GetConversionResult(); |
---|
164 |
</code> |
---|
165 |
*/ |
---|
166 |
void ADC1_SelectChannel(adc_channel_t channel); |
---|
167 |
|
---|
168 |
/** |
---|
169 |
@Summary |
---|
170 |
Starts conversion |
---|
171 |
|
---|
172 |
@Description |
---|
173 |
This routine is used to start conversion of desired channel. |
---|
174 |
|
---|
175 |
@Preconditions |
---|
176 |
ADC1_Initialize() function should have been called before calling this function. |
---|
177 |
|
---|
178 |
@Returns |
---|
179 |
None |
---|
180 |
|
---|
181 |
@Param |
---|
182 |
None |
---|
183 |
|
---|
184 |
@Example |
---|
185 |
<code> |
---|
186 |
uint16_t convertedValue; |
---|
187 |
|
---|
188 |
ADC1_Initialize(); |
---|
189 |
ADC1_StartConversion(); |
---|
190 |
convertedValue = ADC1_GetConversionResult(); |
---|
191 |
</code> |
---|
192 |
*/ |
---|
193 |
void ADC1_StartConversion(); |
---|
194 |
|
---|
195 |
/** |
---|
196 |
@Summary |
---|
197 |
Returns true when the conversion is completed otherwise false. |
---|
198 |
|
---|
199 |
@Description |
---|
200 |
This routine is used to determine if conversion is completed. |
---|
201 |
When conversion is complete routine returns true. It returns false otherwise. |
---|
202 |
|
---|
203 |
@Preconditions |
---|
204 |
ADC1_Initialize() and ADC1_StartConversion(adc_channel_t channel) |
---|
205 |
function should have been called before calling this function. |
---|
206 |
|
---|
207 |
@Returns |
---|
208 |
true - If conversion is complete |
---|
209 |
false - If conversion is not completed |
---|
210 |
|
---|
211 |
@Param |
---|
212 |
None |
---|
213 |
|
---|
214 |
@Example |
---|
215 |
<code> |
---|
216 |
uint16_t convertedValue; |
---|
217 |
|
---|
218 |
ADC1_Initialize(); |
---|
219 |
ADC1_StartConversion(AN1_Channel); |
---|
220 |
|
---|
221 |
while(!ADC1_IsConversionDone()); |
---|
222 |
convertedValue = ADC1_GetConversionResult(); |
---|
223 |
</code> |
---|
224 |
*/ |
---|
225 |
bool ADC1_IsConversionDone(); |
---|
226 |
|
---|
227 |
/** |
---|
228 |
@Summary |
---|
229 |
Returns the ADC1 conversion value. |
---|
230 |
|
---|
231 |
@Description |
---|
232 |
This routine is used to get the analog to digital converted value. This |
---|
233 |
routine gets converted values from the channel specified. |
---|
234 |
|
---|
235 |
@Preconditions |
---|
236 |
This routine returns the conversion value only after the conversion is complete. |
---|
237 |
Completion status can be checked using |
---|
238 |
ADC1_IsConversionDone() routine. |
---|
239 |
|
---|
240 |
@Returns |
---|
241 |
Returns the converted value. |
---|
242 |
|
---|
243 |
@Param |
---|
244 |
None |
---|
245 |
|
---|
246 |
@Example |
---|
247 |
<code> |
---|
248 |
uint16_t convertedValue; |
---|
249 |
|
---|
250 |
ADC1_Initialize(); |
---|
251 |
ADC1_StartConversion(AN1_Channel); |
---|
252 |
|
---|
253 |
while(ADC1_IsConversionDone()); |
---|
254 |
|
---|
255 |
convertedValue = ADC1_GetConversionResult(); |
---|
256 |
</code> |
---|
257 |
*/ |
---|
258 |
adc_result_t ADC1_GetConversionResult(void); |
---|
259 |
|
---|
260 |
/** |
---|
261 |
@Summary |
---|
262 |
Returns the ADC1 conversion value |
---|
263 |
also allows selection of a channel for conversion. |
---|
264 |
|
---|
265 |
@Description |
---|
266 |
This routine is used to select desired channel for conversion |
---|
267 |
and to get the analog to digital converted value. |
---|
268 |
|
---|
269 |
@Preconditions |
---|
270 |
ADC1_Initialize() function should have been called before calling this function. |
---|
271 |
|
---|
272 |
@Returns |
---|
273 |
Returns the converted value. |
---|
274 |
|
---|
275 |
@Param |
---|
276 |
Pass in required channel number. |
---|
277 |
"For available channel refer to enum under adc.h file" |
---|
278 |
|
---|
279 |
@Example |
---|
280 |
<code> |
---|
281 |
uint16_t convertedValue; |
---|
282 |
|
---|
283 |
ADC1_Initialize(); |
---|
284 |
|
---|
285 |
conversion = ADC1_GetConversion(AN1_Channel); |
---|
286 |
</code> |
---|
287 |
*/ |
---|
288 |
adc_result_t ADC1_GetConversion(adc_channel_t channel); |
---|
289 |
|
---|
290 |
/** |
---|
291 |
@Summary |
---|
292 |
Acquisition Delay for temperature sensor |
---|
293 |
|
---|
294 |
@Description |
---|
295 |
This routine should be called when temperature sensor is used. |
---|
296 |
|
---|
297 |
@Preconditions |
---|
298 |
ADC1_Initialize() function should have been called before calling this function. |
---|
299 |
|
---|
300 |
@Returns |
---|
301 |
None |
---|
302 |
|
---|
303 |
@Param |
---|
304 |
None |
---|
305 |
|
---|
306 |
@Example |
---|
307 |
<code> |
---|
308 |
uint16_t convertedValue; |
---|
309 |
|
---|
310 |
ADC1_Initialize(); |
---|
311 |
ADC1_StartConversion(); |
---|
312 |
ADC1_temperatureAcquisitionDelay(); |
---|
313 |
convertedValue = ADC1_GetConversionResult(); |
---|
314 |
</code> |
---|
315 |
*/ |
---|
316 |
void ADC1_TemperatureAcquisitionDelay(void); |
---|
317 |
|
---|
318 |
#ifdef __cplusplus // Provide C++ Compatibility |
---|
319 |
|
---|
320 |
} |
---|
321 |
|
---|
322 |
#endif |
---|
323 |
|
---|
324 |
#endif //ADC1_H |
---|
325 |
/** |
---|
326 |
End of File |
---|
327 |
*/ |
---|
328 |
|
---|