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 <stdint.h>
120 #include <stdbool.h>
121 #include <stddef.h>
122 
128 #define ADC_convertRawToMicroVolts ADC_convertToMicroVolts
129 
147 #define ADC_CMD_RESERVED (32)
148 
161 #define ADC_STATUS_RESERVED (-32)
162 
171 #define ADC_STATUS_SUCCESS (0)
172 
179 #define ADC_STATUS_ERROR (-1)
180 
188 #define ADC_STATUS_UNDEFINEDCMD (-2)
189 
199 /* Add ADC_CMD_<commands> here */
200 
208 typedef struct ADC_Config_ *ADC_Handle;
209 
219 typedef struct ADC_Params_ {
220  void *custom;
222  bool isProtected;
229 } ADC_Params;
230 
235 typedef void (*ADC_CloseFxn) (ADC_Handle handle);
236 
241 typedef int_fast16_t (*ADC_ControlFxn) (ADC_Handle handle, uint_fast16_t cmd,
242  void *arg);
243 
248 typedef int_fast16_t (*ADC_ConvertFxn) (ADC_Handle handle, uint16_t *value);
249 
254 typedef uint32_t (*ADC_ConvertToMicroVoltsFxn) (ADC_Handle handle,
255  uint16_t adcValue);
256 
261 typedef void (*ADC_InitFxn) (ADC_Handle handle);
262 
267 typedef ADC_Handle (*ADC_OpenFxn) (ADC_Handle handle, ADC_Params *params);
268 
274 typedef struct ADC_FxnTable_ {
277 
280 
283 
286 
289 
292 } ADC_FxnTable;
293 
305 typedef struct ADC_Config_ {
308 
310  void *object;
311 
313  void const *hwAttrs;
314 } ADC_Config;
315 
325 extern void ADC_close(ADC_Handle handle);
326 
346 extern int_fast16_t ADC_control(ADC_Handle handle, uint_fast16_t cmd,
347  void *arg);
348 
366 extern int_fast16_t ADC_convert(ADC_Handle handle, uint16_t *value);
367 
382 extern uint32_t ADC_convertToMicroVolts(ADC_Handle handle,
383  uint16_t adcValue);
384 
392 extern void ADC_init(void);
393 
414 extern ADC_Handle ADC_open(uint_least8_t index, ADC_Params *params);
415 
425 extern void ADC_Params_init(ADC_Params *params);
426 
427 #ifdef __cplusplus
428 }
429 #endif
430 
431 #endif /* ti_drivers_ADC__include */
bool isProtected
Definition: ADC.h:222
ADC Global configuration.
Definition: ADC.h:305
ADC_ConvertFxn convertFxn
Definition: ADC.h:282
int_fast16_t ADC_convert(ADC_Handle handle, uint16_t *value)
Function to perform ADC conversion.
ADC_ControlFxn controlFxn
Definition: ADC.h:279
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:291
ADC_Handle(* ADC_OpenFxn)(ADC_Handle handle, ADC_Params *params)
A function pointer to a driver specific implementation of ADC_open().
Definition: ADC.h:267
ADC_FxnTable const * fxnTablePtr
Definition: ADC.h:307
ADC Parameters.
Definition: ADC.h:219
void(* ADC_CloseFxn)(ADC_Handle handle)
A function pointer to a driver specific implementation of ADC_close().
Definition: ADC.h:235
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:313
void * custom
Definition: ADC.h:220
The definition of a ADC function table that contains the required set of functions to control a speci...
Definition: ADC.h:274
ADC_CloseFxn closeFxn
Definition: ADC.h:276
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:248
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:254
ADC_ConvertToMicroVoltsFxn convertToMicroVolts
Definition: ADC.h:285
void * object
Definition: ADC.h:310
ADC_InitFxn initFxn
Definition: ADC.h:288
struct ADC_Config_ * ADC_Handle
A handle that is returned from a ADC_open() call.
Definition: ADC.h:208
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:261
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:241
void ADC_close(ADC_Handle handle)
Function to close a ADC driver.
Copyright 2017, Texas Instruments Incorporated