SimpleLink MCU SDK Driver APIs  tidrivers_msp43x_3_01_01_03
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  */
111 #ifndef ti_drivers_ADC__include
112 #define ti_drivers_ADC__include
113 
114 #ifdef __cplusplus
115 extern "C" {
116 #endif
117 
118 #include <stdint.h>
119 #include <stdbool.h>
120 #include <stddef.h>
121 
139 #define ADC_CMD_RESERVED (32)
140 
153 #define ADC_STATUS_RESERVED (-32)
154 
163 #define ADC_STATUS_SUCCESS (0)
164 
171 #define ADC_STATUS_ERROR (-1)
172 
180 #define ADC_STATUS_UNDEFINEDCMD (-2)
181 
191 /* Add ADC_CMD_<commands> here */
192 
200 typedef struct ADC_Config_ *ADC_Handle;
201 
211 typedef struct ADC_Params_ {
212  void *custom;
214  bool isProtected;
221 } ADC_Params;
222 
227 typedef void (*ADC_CloseFxn) (ADC_Handle handle);
228 
233 typedef int_fast16_t (*ADC_ControlFxn) (ADC_Handle handle, uint_fast16_t cmd,
234  void *arg);
235 
240 typedef int_fast16_t (*ADC_ConvertFxn) (ADC_Handle handle, uint16_t *value);
241 
246 typedef uint32_t (*ADC_ConvertRawToMicroVolts) (ADC_Handle handle,
247  uint16_t rawAdcValue);
248 
253 typedef void (*ADC_InitFxn) (ADC_Handle handle);
254 
259 typedef ADC_Handle (*ADC_OpenFxn) (ADC_Handle handle, ADC_Params *params);
260 
266 typedef struct ADC_FxnTable_ {
269 
272 
275 
278 
281 
284 } ADC_FxnTable;
285 
297 typedef struct ADC_Config_ {
300 
302  void *object;
303 
305  void const *hwAttrs;
306 } ADC_Config;
307 
317 extern void ADC_close(ADC_Handle handle);
318 
338 extern int_fast16_t ADC_control(ADC_Handle handle, uint_fast16_t cmd,
339  void *arg);
340 
358 extern int_fast16_t ADC_convert(ADC_Handle handle, uint16_t *value);
359 
374 extern uint32_t ADC_convertRawToMicroVolts(ADC_Handle handle,
375  uint16_t rawAdcValue);
376 
384 extern void ADC_init(void);
385 
406 extern ADC_Handle ADC_open(uint_least8_t index, ADC_Params *params);
407 
417 extern void ADC_Params_init(ADC_Params *params);
418 
419 #ifdef __cplusplus
420 }
421 #endif
422 
423 #endif /* ti_drivers_ADC__include */
bool isProtected
Definition: ADC.h:214
ADC Global configuration.
Definition: ADC.h:297
ADC_ConvertFxn convertFxn
Definition: ADC.h:274
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_ControlFxn controlFxn
Definition: ADC.h:271
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.
void ADC_Params_init(ADC_Params *params)
Function to initialize the ADC_Params struct to its defaults.
ADC_OpenFxn openFxn
Definition: ADC.h:283
ADC_Handle(* ADC_OpenFxn)(ADC_Handle handle, ADC_Params *params)
A function pointer to a driver specific implementation of ADC_open().
Definition: ADC.h:259
ADC_FxnTable const * fxnTablePtr
Definition: ADC.h:299
ADC Parameters.
Definition: ADC.h:211
void(* ADC_CloseFxn)(ADC_Handle handle)
A function pointer to a driver specific implementation of ADC_close().
Definition: ADC.h:227
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:305
void * custom
Definition: ADC.h:212
The definition of a ADC function table that contains the required set of functions to control a speci...
Definition: ADC.h:266
ADC_CloseFxn closeFxn
Definition: ADC.h:268
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:240
struct ADC_Config_ ADC_Config
ADC Global configuration.
ADC_ConvertRawToMicroVolts convertRawToMicroVolts
Definition: ADC.h:277
void * object
Definition: ADC.h:302
ADC_InitFxn initFxn
Definition: ADC.h:280
struct ADC_Config_ * ADC_Handle
A handle that is returned from a ADC_open() call.
Definition: ADC.h:200
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:253
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:233
void ADC_close(ADC_Handle handle)
Function to close a ADC driver.
uint32_t(* ADC_ConvertRawToMicroVolts)(ADC_Handle handle, uint16_t rawAdcValue)
A function pointer to a driver specific implementation of ADC_convertRawToMicroVolts().
Definition: ADC.h:246
Copyright 2016, Texas Instruments Incorporated