TI-RTOS Drivers  tidrivers_full_2_20_00_08
ADCBuf.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  */
127 #ifndef ti_drivers_adcbuf__include
128 #define ti_drivers_adcbuf__include
129 
130 #ifdef __cplusplus
131 extern "C" {
132 #endif
133 
134 #include <stdint.h>
135 #include <stdbool.h>
136 #include <stddef.h>
137 
149 #define ADCBuf_CMD_RESERVED 32
150 
163 #define ADCBuf_STATUS_RESERVED -32
164 
172 #define ADCBuf_STATUS_SUCCESS 0
173 
180 #define ADCBuf_STATUS_ERROR -1
181 
189 #define ADCBuf_STATUS_UNDEFINEDCMD -2
190 
191 
195 typedef struct ADCBuf_Config *ADCBuf_Handle;
196 
204 typedef struct ADCBuf_Conversion {
206  void *sampleBuffer;
210  void *arg;
211  uint32_t adcChannel;
213 
218 typedef void (*ADCBuf_Callback) (ADCBuf_Handle handle,
219  ADCBuf_Conversion *conversion,
220  void *completedADCBuffer,
221  uint32_t completedChannel);
241 
248 typedef enum ADCBuf_Return_Mode {
256 
263 
264 
273 typedef struct ADCBuf_Params {
274  uint32_t blockingTimeout;
275  uint32_t samplingFrequency;
279  void *custom;
280 } ADCBuf_Params;
281 
286 typedef void (*ADCBuf_CloseFxn) (ADCBuf_Handle handle);
287 
288 
293 typedef ADCBuf_Handle (*ADCBuf_OpenFxn) (ADCBuf_Handle handle,
294  ADCBuf_Params *params);
295 
300 typedef int_fast16_t (*ADCBuf_ControlFxn) (ADCBuf_Handle handle,
301  uint_fast8_t cmd,
302  void *arg);
307 typedef void (*ADCBuf_InitFxn) (ADCBuf_Handle handle);
308 
313 typedef int_fast16_t (*ADCBuf_ConvertFxn) (ADCBuf_Handle handle,
314  ADCBuf_Conversion conversions[],
315  uint_fast8_t channelCount);
320 typedef int_fast16_t (*ADCBuf_ConvertCancelFxn) (ADCBuf_Handle handle);
321 
326 typedef uint_fast8_t (*ADCBuf_GetResolutionFxn) (ADCBuf_Handle handle);
327 
332 typedef int_fast16_t (*ADCBuf_adjustRawValuesFxn) (ADCBuf_Handle handle,
333  void *sampleBuffer,
334  uint_fast16_t sampleCount,
335  uint32_t adcChannel);
336 
341 typedef int_fast16_t (*ADCBuf_convertAdjustedToMicroVoltsFxn) (ADCBuf_Handle handle,
342  uint32_t adcChannel,
343  void *adjustedSampleBuffer,
344  uint32_t outputMicroVoltBuffer[],
345  uint_fast16_t sampleCount);
346 
352 typedef struct ADCBuf_FxnTable {
372 
384 typedef struct ADCBuf_Config {
387 
389  void *object;
390 
392  void const *hwAttrs;
393 } ADCBuf_Config;
394 
406 extern void ADCBuf_close(ADCBuf_Handle handle);
407 
408 
428 extern int_fast16_t ADCBuf_control(ADCBuf_Handle handle, uint_fast8_t cmd, void * arg);
429 
438 extern void ADCBuf_init(void);
439 
457 extern void ADCBuf_Params_init(ADCBuf_Params *params);
458 
474 extern ADCBuf_Handle ADCBuf_open(uint_fast8_t index, ADCBuf_Params *params);
475 
494 extern int_fast16_t ADCBuf_convert(ADCBuf_Handle handle, ADCBuf_Conversion conversions[], uint_fast8_t channelCount);
495 
507 extern int_fast16_t ADCBuf_convertCancel(ADCBuf_Handle handle);
508 
518 extern uint_fast8_t ADCBuf_getResolution(ADCBuf_Handle handle);
519 
538 extern int_fast16_t ADCBuf_adjustRawValues(ADCBuf_Handle handle, void *sampleBuffer, uint_fast16_t sampleCount, uint32_t adcChannel);
539 
562 extern int_fast16_t ADCBuf_convertAdjustedToMicroVolts(ADCBuf_Handle handle, uint32_t adcChannel, void *adjustedSampleBuffer, uint32_t outputMicroVoltBuffer[], uint_fast16_t sampleCount);
563 
564 #ifdef __cplusplus
565 }
566 #endif
567 #endif /* ti_drivers_adcbuf__include */
void(* ADCBuf_InitFxn)(ADCBuf_Handle handle)
A function pointer to a driver specific implementation of ADCBuf_init().
Definition: ADCBuf.h:307
int_fast16_t(* ADCBuf_convertAdjustedToMicroVoltsFxn)(ADCBuf_Handle handle, uint32_t adcChannel, void *adjustedSampleBuffer, uint32_t outputMicroVoltBuffer[], uint_fast16_t sampleCount)
A function pointer to a driver specific implementation of ADCBuf_convertAdjustedToMicroVolts();.
Definition: ADCBuf.h:341
struct ADCBuf_Config ADCBuf_Config
ADCBuf Global configuration.
int_fast16_t ADCBuf_control(ADCBuf_Handle handle, uint_fast8_t cmd, void *arg)
Function performs implementation specific features on a given ADCBuf_Handle.
uint16_t samplesRequestedCount
Definition: ADCBuf.h:205
void * sampleBuffer
Definition: ADCBuf.h:206
void ADCBuf_close(ADCBuf_Handle handle)
Function to close an ADC peripheral specified by the ADC handle.
struct ADCBuf_Config * ADCBuf_Handle
A handle that is returned from an ADCBuf_open() call.
Definition: ADCBuf.h:195
void ADCBuf_init(void)
This function initializes the ADC module. This function must.
uint_fast8_t ADCBuf_getResolution(ADCBuf_Handle handle)
This function returns the resolution in bits of the specified ADC.
uint_fast8_t(* ADCBuf_GetResolutionFxn)(ADCBuf_Handle handle)
A function pointer to a driver specific implementation of ADCBuf_GetResolution();.
Definition: ADCBuf.h:326
int_fast16_t(* ADCBuf_ConvertFxn)(ADCBuf_Handle handle, ADCBuf_Conversion conversions[], uint_fast8_t channelCount)
A function pointer to a driver specific implementation of ADCBuf_convert().
Definition: ADCBuf.h:313
uint32_t blockingTimeout
Definition: ADCBuf.h:274
struct ADCBuf_Conversion ADCBuf_Conversion
An ADCBuf_Conversion data structure is used with ADCBuf_convert(). It indicates which channel to perf...
uint32_t samplingFrequency
Definition: ADCBuf.h:275
Definition: ADCBuf.h:233
ADCBuf_InitFxn initFxn
Definition: ADCBuf.h:358
uint32_t adcChannel
Definition: ADCBuf.h:211
struct ADCBuf_Params ADCBuf_Params
ADC Parameters.
void const * hwAttrs
Definition: ADCBuf.h:392
void * custom
Definition: ADCBuf.h:279
ADC Parameters.
Definition: ADCBuf.h:273
ADCBuf_ConvertFxn convertFxn
Definition: ADCBuf.h:362
struct ADCBuf_FxnTable ADCBuf_FxnTable
The definition of an ADCBuf function table that contains the required set of functions to control a s...
int_fast16_t(* ADCBuf_adjustRawValuesFxn)(ADCBuf_Handle handle, void *sampleBuffer, uint_fast16_t sampleCount, uint32_t adcChannel)
A function pointer to a driver specific implementation of ADCBuf_adjustRawValues();.
Definition: ADCBuf.h:332
const ADCBuf_FxnTable * fxnTablePtr
Definition: ADCBuf.h:386
The definition of an ADCBuf function table that contains the required set of functions to control a s...
Definition: ADCBuf.h:352
int_fast16_t(* ADCBuf_ConvertCancelFxn)(ADCBuf_Handle handle)
A function pointer to a driver specific implementation of ADCBuf_convertCancel(). ...
Definition: ADCBuf.h:320
int_fast16_t ADCBuf_convertAdjustedToMicroVolts(ADCBuf_Handle handle, uint32_t adcChannel, void *adjustedSampleBuffer, uint32_t outputMicroVoltBuffer[], uint_fast16_t sampleCount)
This function converts a raw ADC output value to a value scaled in micro volts.
int_fast16_t ADCBuf_adjustRawValues(ADCBuf_Handle handle, void *sampleBuffer, uint_fast16_t sampleCount, uint32_t adcChannel)
This function adjusts a raw ADC output buffer such that the result is comparable between devices of t...
ADCBuf_GetResolutionFxn getResolutionFxn
Definition: ADCBuf.h:366
ADCBuf_Recurrence_Mode
ADC trigger mode settings.
Definition: ADCBuf.h:228
ADCBuf_OpenFxn openFxn
Definition: ADCBuf.h:360
ADCBuf_Return_Mode
ADC return mode settings.
Definition: ADCBuf.h:248
ADCBuf_CloseFxn closeFxn
Definition: ADCBuf.h:354
ADCBuf_ConvertCancelFxn convertCancelFxn
Definition: ADCBuf.h:364
int_fast16_t(* ADCBuf_ControlFxn)(ADCBuf_Handle handle, uint_fast8_t cmd, void *arg)
A function pointer to a driver specific implementation of ADCBuf_control().
Definition: ADCBuf.h:300
ADCBuf_Recurrence_Mode recurrenceMode
Definition: ADCBuf.h:278
Definition: ADCBuf.h:255
ADCBuf_convertAdjustedToMicroVoltsFxn convertAdjustedToMicroVoltsFxn
Definition: ADCBuf.h:370
int_fast16_t ADCBuf_convertCancel(ADCBuf_Handle handle)
This function cancels an ADC conversion that is in progress.
void * arg
Definition: ADCBuf.h:210
void(* ADCBuf_Callback)(ADCBuf_Handle handle, ADCBuf_Conversion *conversion, void *completedADCBuffer, uint32_t completedChannel)
The definition of a callback function used by the ADC driver when used in ADCBuf_RETURN_MODE_CALLBACK...
Definition: ADCBuf.h:218
void(* ADCBuf_CloseFxn)(ADCBuf_Handle handle)
A function pointer to a driver specific implementation of ADCBuf_close().
Definition: ADCBuf.h:286
ADCBuf Global configuration.
Definition: ADCBuf.h:384
Definition: ADCBuf.h:261
An ADCBuf_Conversion data structure is used with ADCBuf_convert(). It indicates which channel to perf...
Definition: ADCBuf.h:204
Definition: ADCBuf.h:239
ADCBuf_Handle ADCBuf_open(uint_fast8_t index, ADCBuf_Params *params)
This function opens a given ADCBuf peripheral.
void ADCBuf_Params_init(ADCBuf_Params *params)
This function sets all fields of a specified ADCBuf_Params structure to their default values...
ADCBuf_Callback callbackFxn
Definition: ADCBuf.h:277
ADCBuf_adjustRawValuesFxn adjustRawValuesFxn
Definition: ADCBuf.h:368
ADCBuf_ControlFxn controlFxn
Definition: ADCBuf.h:356
void * object
Definition: ADCBuf.h:389
void * sampleBufferTwo
Definition: ADCBuf.h:207
ADCBuf_Return_Mode returnMode
Definition: ADCBuf.h:276
ADCBuf_Handle(* ADCBuf_OpenFxn)(ADCBuf_Handle handle, ADCBuf_Params *params)
A function pointer to a driver specific implementation of ADCBuf_open().
Definition: ADCBuf.h:293
int_fast16_t ADCBuf_convert(ADCBuf_Handle handle, ADCBuf_Conversion conversions[], uint_fast8_t channelCount)
This function starts a set of conversions on one or more channels.
Copyright 2016, Texas Instruments Incorporated