TI-RTOS Drivers  tidrivers_full_2_20_00_08
ADC.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, 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  */
108 #ifndef ti_drivers_ADC__include
109 #define ti_drivers_ADC__include
110 
111 #ifdef __cplusplus
112 extern "C" {
113 #endif
114 
115 #include <stdint.h>
116 #include <stdbool.h>
117 #include <stddef.h>
118 
130 #define ADC_CMD_RESERVED (32)
131 
144 #define ADC_STATUS_RESERVED (-32)
145 
152 #define ADC_STATUS_SUCCESS (0)
153 
160 #define ADC_STATUS_ERROR (-1)
161 
169 #define ADC_STATUS_UNDEFINEDCMD (-2)
170 
174 typedef struct ADC_Config *ADC_Handle;
175 
185 typedef struct ADC_Params {
186  void *custom;
188 } ADC_Params;
189 
194 typedef void (*ADC_CloseFxn) (ADC_Handle handle);
195 
200 typedef int_fast16_t (*ADC_ControlFxn) (ADC_Handle handle,
201  uint_fast16_t cmd,
202  void *arg);
203 
208 typedef int_fast16_t (*ADC_ConvertFxn) (ADC_Handle handle, uint16_t *value);
209 
214 typedef uint32_t (*ADC_ConvertRawToMicroVolts)(ADC_Handle handle,
215  uint16_t rawAdcValue);
216 
221 typedef void (*ADC_InitFxn) (ADC_Handle handle);
222 
227 typedef ADC_Handle (*ADC_OpenFxn) (ADC_Handle handle,
228  ADC_Params *params);
229 
235 typedef struct ADC_FxnTable {
238 
241 
244 
247 
250 
253 
254 } ADC_FxnTable;
255 
267 typedef struct ADC_Config {
270 
272  void *object;
273 
275  void const *hwAttrs;
276 } ADC_Config;
277 
278 
279 /*
280  * =============================================================================
281  * Functions
282  * =============================================================================
283  */
293 extern void ADC_close(ADC_Handle handle);
294 
314 extern int_fast16_t ADC_control(ADC_Handle handle, uint_fast16_t cmd, void *arg);
315 
333 int_fast16_t ADC_convert(ADC_Handle handle, uint16_t *value);
334 
349 extern uint32_t ADC_convertRawToMicroVolts(ADC_Handle handle, uint16_t rawAdcValue);
357 void ADC_init(void);
358 
379 ADC_Handle ADC_open(uint_fast16_t index, ADC_Params *params);
380 
390 extern void ADC_Params_init(ADC_Params *params);
391 
392 #ifdef __cplusplus
393 }
394 #endif
395 
396 #endif /* ti_drivers_ADC__include */
void * object
Definition: ADC.h:272
ADC_OpenFxn openFxn
Definition: ADC.h:252
ADC_ConvertFxn convertFxn
Definition: ADC.h:243
int_fast16_t ADC_convert(ADC_Handle handle, uint16_t *value)
Function to perform ADC conversion.
uint32_t ADC_convertRawToMicroVolts(ADC_Handle handle, uint16_t rawAdcValue)
Function performs conversion from raw ADC result to actual value in microvolts.
ADC Parameters.
Definition: ADC.h:185
ADC_ControlFxn controlFxn
Definition: ADC.h:240
void ADC_init(void)
Function to initializes the ADC driver.
void ADC_Params_init(ADC_Params *params)
Function to initialize the ADC_Params struct to its defaults.
ADC_FxnTable const * fxnTablePtr
Definition: ADC.h:269
ADC_Handle(* ADC_OpenFxn)(ADC_Handle handle, ADC_Params *params)
A function pointer to a driver specific implementation of ADC_open().
Definition: ADC.h:227
void(* ADC_CloseFxn)(ADC_Handle handle)
A function pointer to a driver specific implementation of ADC_close().
Definition: ADC.h:194
int_fast16_t ADC_control(ADC_Handle handle, uint_fast16_t cmd, void *arg)
Function performs implementation specific features on a given ADC_Handle.
void const * hwAttrs
Definition: ADC.h:275
ADC_Handle ADC_open(uint_fast16_t index, ADC_Params *params)
Function to initialize the ADC peripheral.
ADC Global configuration.
Definition: ADC.h:267
ADC_InitFxn initFxn
Definition: ADC.h:249
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:208
The definition of a ADC function table that contains the required set of functions to control a speci...
Definition: ADC.h:235
ADC_CloseFxn closeFxn
Definition: ADC.h:237
struct ADC_Config ADC_Config
ADC Global configuration.
ADC_ConvertRawToMicroVolts convertRawToMicroVolts
Definition: ADC.h:246
struct ADC_Config * ADC_Handle
A handle that is returned from a ADC_open() call.
Definition: ADC.h:174
void(* ADC_InitFxn)(ADC_Handle handle)
A function pointer to a driver specific implementation of ADC_init().
Definition: ADC.h:221
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:200
struct ADC_Params ADC_Params
ADC Parameters.
void ADC_close(ADC_Handle handle)
Function to close a ADC driver.
struct ADC_FxnTable ADC_FxnTable
The definition of a ADC function table that contains the required set of functions to control a speci...
uint32_t(* ADC_ConvertRawToMicroVolts)(ADC_Handle handle, uint16_t rawAdcValue)
A function pointer to a driver specific implementation of ADC_convertRawToMicroVolts().
Definition: ADC.h:214
void * custom
Definition: ADC.h:186
Copyright 2016, Texas Instruments Incorporated