ADC.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
112 #ifndef ti_drivers_ADC__include
113 #define ti_drivers_ADC__include
114 
115 #ifdef __cplusplus
116 extern "C" {
117 #endif
118 
119 #include <stdbool.h>
120 #include <stdint.h>
121 
127 #define ADC_convertRawToMicroVolts ADC_convertToMicroVolts
128 
146 #define ADC_CMD_RESERVED (32)
147 
160 #define ADC_STATUS_RESERVED (-32)
161 
170 #define ADC_STATUS_SUCCESS (0)
171 
178 #define ADC_STATUS_ERROR (-1)
179 
187 #define ADC_STATUS_UNDEFINEDCMD (-2)
188 
198 /* Add ADC_CMD_<commands> here */
199 
207 typedef struct ADC_Config_ *ADC_Handle;
208 
218 typedef struct ADC_Params_ {
219  void *custom;
221  bool isProtected;
228 } ADC_Params;
229 
234 typedef void (*ADC_CloseFxn) (ADC_Handle handle);
235 
240 typedef int_fast16_t (*ADC_ControlFxn) (ADC_Handle handle, uint_fast16_t cmd,
241  void *arg);
242 
247 typedef int_fast16_t (*ADC_ConvertFxn) (ADC_Handle handle, uint16_t *value);
248 
253 typedef uint32_t (*ADC_ConvertToMicroVoltsFxn) (ADC_Handle handle,
254  uint16_t adcValue);
255 
260 typedef void (*ADC_InitFxn) (ADC_Handle handle);
261 
266 typedef ADC_Handle (*ADC_OpenFxn) (ADC_Handle handle, ADC_Params *params);
267 
273 typedef struct ADC_FxnTable_ {
276 
279 
282 
285 
288 
291 } ADC_FxnTable;
292 
304 typedef struct ADC_Config_ {
307 
309  void *object;
310 
312  void const *hwAttrs;
313 } ADC_Config;
314 
324 extern void ADC_close(ADC_Handle handle);
325 
345 extern int_fast16_t ADC_control(ADC_Handle handle, uint_fast16_t cmd,
346  void *arg);
347 
365 extern int_fast16_t ADC_convert(ADC_Handle handle, uint16_t *value);
366 
381 extern uint32_t ADC_convertToMicroVolts(ADC_Handle handle,
382  uint16_t adcValue);
383 
391 extern void ADC_init(void);
392 
413 extern ADC_Handle ADC_open(uint_least8_t index, ADC_Params *params);
414 
424 extern void ADC_Params_init(ADC_Params *params);
425 
426 #ifdef __cplusplus
427 }
428 #endif
429 
430 #endif /* ti_drivers_ADC__include */
bool isProtected
Definition: ADC.h:221
ADC Global configuration.
Definition: ADC.h:304
ADC_ConvertFxn convertFxn
Definition: ADC.h:281
int_fast16_t ADC_convert(ADC_Handle handle, uint16_t *value)
Function to perform ADC conversion.
ADC_ControlFxn controlFxn
Definition: ADC.h:278
struct ADC_FxnTable_ ADC_FxnTable
The definition of a ADC function table that contains the required set of functions to control a speci...
void ADC_init(void)
Function to initializes the ADC driver.
uint32_t ADC_convertToMicroVolts(ADC_Handle handle, uint16_t adcValue)
Function performs conversion from ADC result to actual value in microvolts.
void ADC_Params_init(ADC_Params *params)
Function to initialize the ADC_Params struct to its defaults.
ADC_OpenFxn openFxn
Definition: ADC.h:290
ADC_Handle(* ADC_OpenFxn)(ADC_Handle handle, ADC_Params *params)
A function pointer to a driver specific implementation of ADC_open().
Definition: ADC.h:266
ADC_FxnTable const * fxnTablePtr
Definition: ADC.h:306
ADC Parameters.
Definition: ADC.h:218
void(* ADC_CloseFxn)(ADC_Handle handle)
A function pointer to a driver specific implementation of ADC_close().
Definition: ADC.h:234
int_fast16_t ADC_control(ADC_Handle handle, uint_fast16_t cmd, void *arg)
Function performs implementation specific features on a given ADC_Handle.
ADC_Handle ADC_open(uint_least8_t index, ADC_Params *params)
Function to initialize the ADC peripheral.
void const * hwAttrs
Definition: ADC.h:312
void * custom
Definition: ADC.h:219
The definition of a ADC function table that contains the required set of functions to control a speci...
Definition: ADC.h:273
ADC_CloseFxn closeFxn
Definition: ADC.h:275
int_fast16_t(* ADC_ConvertFxn)(ADC_Handle handle, uint16_t *value)
A function pointer to a driver specific implementation of ADC_ConvertFxn().
Definition: ADC.h:247
struct ADC_Config_ ADC_Config
ADC Global configuration.
uint32_t(* ADC_ConvertToMicroVoltsFxn)(ADC_Handle handle, uint16_t adcValue)
A function pointer to a driver specific implementation of ADC_convertToMicroVolts().
Definition: ADC.h:253
ADC_ConvertToMicroVoltsFxn convertToMicroVolts
Definition: ADC.h:284
void * object
Definition: ADC.h:309
ADC_InitFxn initFxn
Definition: ADC.h:287
struct ADC_Config_ * ADC_Handle
A handle that is returned from a ADC_open() call.
Definition: ADC.h:207
struct ADC_Params_ ADC_Params
ADC Parameters.
void(* ADC_InitFxn)(ADC_Handle handle)
A function pointer to a driver specific implementation of ADC_init().
Definition: ADC.h:260
int_fast16_t(* ADC_ControlFxn)(ADC_Handle handle, uint_fast16_t cmd, void *arg)
A function pointer to a driver specific implementation of ADC_control().
Definition: ADC.h:240
void ADC_close(ADC_Handle handle)
Function to close a ADC driver.
© Copyright 1995-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale