ADCBuf.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  */
130 #ifndef ti_drivers_adcbuf__include
131 #define ti_drivers_adcbuf__include
132 
133 #ifdef __cplusplus
134 extern "C" {
135 #endif
136 
137 #include <stdint.h>
138 
156 #define ADCBuf_CMD_RESERVED (32)
157 
170 #define ADCBuf_STATUS_RESERVED (-32)
171 
181 #define ADCBuf_STATUS_SUCCESS (0)
182 
189 #define ADCBuf_STATUS_ERROR (-1)
190 
198 #define ADCBuf_STATUS_UNDEFINEDCMD (-2)
199 
207 #define ADCBuf_STATUS_UNSUPPORTED (-3)
208 
218 /* Add ADCBUF_CMD_<commands> here */
219 
229 
237 typedef struct ADCBuf_Conversion_ {
239  void *sampleBuffer;
243  void *arg;
244  uint32_t adcChannel;
246 
251 typedef void (*ADCBuf_Callback) (ADCBuf_Handle handle,
252  ADCBuf_Conversion *conversion,
253  void *completedADCBuffer,
254  uint32_t completedChannel);
274 
281 typedef enum ADCBuf_Return_Mode_ {
289 
296 
297 
306 typedef struct ADCBuf_Params_ {
307  uint32_t blockingTimeout;
308  uint32_t samplingFrequency;
309  ADCBuf_Return_Mode returnMode;
311  ADCBuf_Recurrence_Mode recurrenceMode;
312  void *custom;
313 } ADCBuf_Params;
314 
319 typedef void (*ADCBuf_CloseFxn) (ADCBuf_Handle handle);
320 
321 
326 typedef ADCBuf_Handle (*ADCBuf_OpenFxn) (ADCBuf_Handle handle,
327  const ADCBuf_Params *params);
328 
333 typedef int_fast16_t (*ADCBuf_ControlFxn) (ADCBuf_Handle handle,
334  uint_fast8_t cmd,
335  void *arg);
336 /*
337  * @brief A function pointer to a driver specific implementation of
338  * ADCBuf_init().
339  */
340 typedef void (*ADCBuf_InitFxn) (ADCBuf_Handle handle);
341 
346 typedef int_fast16_t (*ADCBuf_ConvertFxn) (ADCBuf_Handle handle,
347  ADCBuf_Conversion conversions[],
348  uint_fast8_t channelCount);
353 typedef int_fast16_t (*ADCBuf_ConvertCancelFxn)(ADCBuf_Handle handle);
354 
359 typedef uint_fast8_t (*ADCBuf_GetResolutionFxn) (ADCBuf_Handle handle);
360 
365 typedef int_fast16_t (*ADCBuf_adjustRawValuesFxn)(ADCBuf_Handle handle,
366  void *sampleBuffer,
367  uint_fast16_t sampleCount,
368  uint32_t adcChannel);
369 
374 typedef int_fast16_t (*ADCBuf_convertAdjustedToMicroVoltsFxn) (ADCBuf_Handle handle,
375  uint32_t adcChannel,
376  void *adjustedSampleBuffer,
377  uint32_t outputMicroVoltBuffer[],
378  uint_fast16_t sampleCount);
379 
385 typedef struct ADCBuf_FxnTable_ {
405 
417 typedef struct ADCBuf_Config_ {
420 
422  void *object;
423 
425  void const *hwAttrs;
426 } ADCBuf_Config;
427 
439 extern void ADCBuf_close(ADCBuf_Handle handle);
440 
441 
461 extern int_fast16_t ADCBuf_control(ADCBuf_Handle handle, uint_fast16_t cmd, void *cmdArg);
462 
471 extern void ADCBuf_init(void);
472 
490 extern void ADCBuf_Params_init(ADCBuf_Params *params);
491 
507 extern ADCBuf_Handle ADCBuf_open(uint_least8_t index, ADCBuf_Params *params);
508 
529 extern int_fast16_t ADCBuf_convert(ADCBuf_Handle handle, ADCBuf_Conversion conversions[], uint_fast8_t channelCount);
530 
544 extern int_fast16_t ADCBuf_convertCancel(ADCBuf_Handle handle);
545 
555 extern uint_fast8_t ADCBuf_getResolution(ADCBuf_Handle handle);
556 
577 extern int_fast16_t ADCBuf_adjustRawValues(ADCBuf_Handle handle, void *sampleBuf, uint_fast16_t sampleCount, uint32_t adcChan);
578 
604 extern int_fast16_t ADCBuf_convertAdjustedToMicroVolts(ADCBuf_Handle handle, uint32_t adcChan, void *adjustedSampleBuffer, uint32_t outputMicroVoltBuffer[], uint_fast16_t sampleCount);
605 
606 #ifdef __cplusplus
607 }
608 #endif
609 #endif /* ti_drivers_adcbuf__include */
Definition: ADCBuf.h:272
void(* ADCBuf_InitFxn)(ADCBuf_Handle handle)
Definition: ADCBuf.h:340
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:374
const ADCBuf_FxnTable * fxnTablePtr
Definition: ADCBuf.h:419
ADCBuf_Return_Mode_
ADC return mode settings.
Definition: ADCBuf.h:281
enum ADCBuf_Recurrence_Mode_ ADCBuf_Recurrence_Mode
ADC trigger mode settings.
struct ADCBuf_FxnTable_ ADCBuf_FxnTable
The definition of an ADCBuf function table that contains the required set of functions to control a s...
uint32_t samplingFrequency
Definition: ADCBuf.h:308
An ADCBuf_Conversion data structure is used with ADCBuf_convert(). It indicates which channel to perf...
Definition: ADCBuf.h:237
ADCBuf_GetResolutionFxn getResolutionFxn
Definition: ADCBuf.h:399
ADCBuf_Recurrence_Mode recurrenceMode
Definition: ADCBuf.h:311
struct ADCBuf_Params_ ADCBuf_Params
ADC Parameters.
void ADCBuf_close(ADCBuf_Handle handle)
Function to close an ADC peripheral specified by the ADC handle.
int_fast16_t ADCBuf_adjustRawValues(ADCBuf_Handle handle, void *sampleBuf, uint_fast16_t sampleCount, uint32_t adcChan)
This function adjusts a raw ADC output buffer such that the result is comparable between devices of t...
enum ADCBuf_Return_Mode_ ADCBuf_Return_Mode
ADC return mode settings.
ADC Parameters.
Definition: ADCBuf.h:306
int_fast16_t ADCBuf_control(ADCBuf_Handle handle, uint_fast16_t cmd, void *cmdArg)
Function performs implementation specific features on a given ADCBuf_Handle.
struct ADCBuf_Config_ * ADCBuf_Handle
A handle that is returned from an ADCBuf_open() call.
Definition: ADCBuf.h:228
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:359
uint16_t samplesRequestedCount
Definition: ADCBuf.h:238
ADCBuf_Callback callbackFxn
Definition: ADCBuf.h:310
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:346
struct ADCBuf_Conversion_ ADCBuf_Conversion
An ADCBuf_Conversion data structure is used with ADCBuf_convert(). It indicates which channel to perf...
void * sampleBufferTwo
Definition: ADCBuf.h:240
ADCBuf_Handle(* ADCBuf_OpenFxn)(ADCBuf_Handle handle, const ADCBuf_Params *params)
A function pointer to a driver specific implementation of ADCBuf_open().
Definition: ADCBuf.h:326
void * object
Definition: ADCBuf.h:422
ADCBuf_Return_Mode returnMode
Definition: ADCBuf.h:309
ADCBuf_CloseFxn closeFxn
Definition: ADCBuf.h:387
ADCBuf_ConvertFxn convertFxn
Definition: ADCBuf.h:395
ADCBuf_Recurrence_Mode_
ADC trigger mode settings.
Definition: ADCBuf.h:261
struct ADCBuf_Config_ ADCBuf_Config
ADCBuf Global configuration.
ADCBuf_adjustRawValuesFxn adjustRawValuesFxn
Definition: ADCBuf.h:401
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:365
The definition of an ADCBuf function table that contains the required set of functions to control a s...
Definition: ADCBuf.h:385
uint32_t blockingTimeout
Definition: ADCBuf.h:307
void const * hwAttrs
Definition: ADCBuf.h:425
Definition: ADCBuf.h:288
int_fast16_t(* ADCBuf_ConvertCancelFxn)(ADCBuf_Handle handle)
A function pointer to a driver specific implementation of ADCBuf_convertCancel(). ...
Definition: ADCBuf.h:353
ADCBuf_OpenFxn openFxn
Definition: ADCBuf.h:393
ADCBuf_ControlFxn controlFxn
Definition: ADCBuf.h:389
ADCBuf Global configuration.
Definition: ADCBuf.h:417
ADCBuf_convertAdjustedToMicroVoltsFxn convertAdjustedToMicroVoltsFxn
Definition: ADCBuf.h:403
uint32_t adcChannel
Definition: ADCBuf.h:244
int_fast16_t ADCBuf_convertAdjustedToMicroVolts(ADCBuf_Handle handle, uint32_t adcChan, 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_ControlFxn)(ADCBuf_Handle handle, uint_fast8_t cmd, void *arg)
A function pointer to a driver specific implementation of ADCBuf_control().
Definition: ADCBuf.h:333
void * sampleBuffer
Definition: ADCBuf.h:239
int_fast16_t ADCBuf_convertCancel(ADCBuf_Handle handle)
This function cancels an ADC conversion that is in progress.
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:251
void(* ADCBuf_CloseFxn)(ADCBuf_Handle handle)
A function pointer to a driver specific implementation of ADCBuf_close().
Definition: ADCBuf.h:319
ADCBuf_InitFxn initFxn
Definition: ADCBuf.h:391
void ADCBuf_Params_init(ADCBuf_Params *params)
This function sets all fields of a specified ADCBuf_Params structure to their default values...
Definition: ADCBuf.h:266
Definition: ADCBuf.h:294
ADCBuf_ConvertCancelFxn convertCancelFxn
Definition: ADCBuf.h:397
void * custom
Definition: ADCBuf.h:312
ADCBuf_Handle ADCBuf_open(uint_least8_t index, ADCBuf_Params *params)
This function opens a given ADCBuf peripheral.
void * arg
Definition: ADCBuf.h:243
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 1995-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale