SimpleLink MCU SDK Driver APIs  tidrivers_msp43x_3_01_01_03
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  */
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 #include <stdbool.h>
139 #include <stddef.h>
140 
158 #define ADCBuf_CMD_RESERVED (32)
159 
172 #define ADCBuf_STATUS_RESERVED (-32)
173 
183 #define ADCBuf_STATUS_SUCCESS (0)
184 
191 #define ADCBuf_STATUS_ERROR (-1)
192 
200 #define ADCBuf_STATUS_UNDEFINEDCMD (-2)
201 
209 #define ADCBuf_STATUS_UNSUPPORTED (-3)
210 
220 /* Add ADCBUF_CMD_<commands> here */
221 
231 
239 typedef struct ADCBuf_Conversion_ {
241  void *sampleBuffer;
245  void *arg;
246  uint32_t adcChannel;
248 
253 typedef void (*ADCBuf_Callback) (ADCBuf_Handle handle,
254  ADCBuf_Conversion *conversion,
255  void *completedADCBuffer,
256  uint32_t completedChannel);
276 
283 typedef enum ADCBuf_Return_Mode_ {
291 
298 
299 
308 typedef struct ADCBuf_Params_ {
309  uint32_t blockingTimeout;
310  uint32_t samplingFrequency;
314  void *custom;
315 } ADCBuf_Params;
316 
321 typedef void (*ADCBuf_CloseFxn) (ADCBuf_Handle handle);
322 
323 
328 typedef ADCBuf_Handle (*ADCBuf_OpenFxn) (ADCBuf_Handle handle,
329  const ADCBuf_Params *params);
330 
335 typedef int_fast16_t (*ADCBuf_ControlFxn) (ADCBuf_Handle handle,
336  uint_fast8_t cmd,
337  void *arg);
338 /*
339  * @brief A function pointer to a driver specific implementation of
340  * ADCBuf_init().
341  */
342 typedef void (*ADCBuf_InitFxn) (ADCBuf_Handle handle);
343 
348 typedef int_fast16_t (*ADCBuf_ConvertFxn) (ADCBuf_Handle handle,
349  ADCBuf_Conversion conversions[],
350  uint_fast8_t channelCount);
355 typedef int_fast16_t (*ADCBuf_ConvertCancelFxn)(ADCBuf_Handle handle);
356 
361 typedef uint_fast8_t (*ADCBuf_GetResolutionFxn) (ADCBuf_Handle handle);
362 
367 typedef int_fast16_t (*ADCBuf_adjustRawValuesFxn)(ADCBuf_Handle handle,
368  void *sampleBuffer,
369  uint_fast16_t sampleCount,
370  uint32_t adcChannel);
371 
376 typedef int_fast16_t (*ADCBuf_convertAdjustedToMicroVoltsFxn) (ADCBuf_Handle handle,
377  uint32_t adcChannel,
378  void *adjustedSampleBuffer,
379  uint32_t outputMicroVoltBuffer[],
380  uint_fast16_t sampleCount);
381 
387 typedef struct ADCBuf_FxnTable_ {
407 
419 typedef struct ADCBuf_Config_ {
422 
424  void *object;
425 
427  void const *hwAttrs;
428 } ADCBuf_Config;
429 
441 extern void ADCBuf_close(ADCBuf_Handle handle);
442 
443 
463 extern int_fast16_t ADCBuf_control(ADCBuf_Handle handle, uint_fast16_t cmd, void *cmdArg);
464 
473 extern void ADCBuf_init(void);
474 
492 extern void ADCBuf_Params_init(ADCBuf_Params *params);
493 
509 extern ADCBuf_Handle ADCBuf_open(uint_least8_t index, ADCBuf_Params *params);
510 
529 extern int_fast16_t ADCBuf_convert(ADCBuf_Handle handle, ADCBuf_Conversion conversions[], uint_fast8_t channelCount);
530 
542 extern int_fast16_t ADCBuf_convertCancel(ADCBuf_Handle handle);
543 
553 extern uint_fast8_t ADCBuf_getResolution(ADCBuf_Handle handle);
554 
573 extern int_fast16_t ADCBuf_adjustRawValues(ADCBuf_Handle handle, void *sampleBuf, uint_fast16_t sampleCount, uint32_t adcChan);
574 
597 extern int_fast16_t ADCBuf_convertAdjustedToMicroVolts(ADCBuf_Handle handle, uint32_t adcChan, void *adjustedSampleBuffer, uint32_t outputMicroVoltBuffer[], uint_fast16_t sampleCount);
598 
599 #ifdef __cplusplus
600 }
601 #endif
602 #endif /* ti_drivers_adcbuf__include */
Definition: ADCBuf.h:274
void(* ADCBuf_InitFxn)(ADCBuf_Handle handle)
Definition: ADCBuf.h:342
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:376
const ADCBuf_FxnTable * fxnTablePtr
Definition: ADCBuf.h:421
ADCBuf_Return_Mode_
ADC return mode settings.
Definition: ADCBuf.h:283
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:310
An ADCBuf_Conversion data structure is used with ADCBuf_convert(). It indicates which channel to perf...
Definition: ADCBuf.h:239
ADCBuf_GetResolutionFxn getResolutionFxn
Definition: ADCBuf.h:401
ADCBuf_Recurrence_Mode recurrenceMode
Definition: ADCBuf.h:313
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:308
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:230
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:361
uint16_t samplesRequestedCount
Definition: ADCBuf.h:240
ADCBuf_Callback callbackFxn
Definition: ADCBuf.h:312
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:348
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:242
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:328
void * object
Definition: ADCBuf.h:424
ADCBuf_Return_Mode returnMode
Definition: ADCBuf.h:311
ADCBuf_CloseFxn closeFxn
Definition: ADCBuf.h:389
ADCBuf_ConvertFxn convertFxn
Definition: ADCBuf.h:397
ADCBuf_Recurrence_Mode_
ADC trigger mode settings.
Definition: ADCBuf.h:263
struct ADCBuf_Config_ ADCBuf_Config
ADCBuf Global configuration.
ADCBuf_adjustRawValuesFxn adjustRawValuesFxn
Definition: ADCBuf.h:403
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:367
The definition of an ADCBuf function table that contains the required set of functions to control a s...
Definition: ADCBuf.h:387
uint32_t blockingTimeout
Definition: ADCBuf.h:309
void const * hwAttrs
Definition: ADCBuf.h:427
Definition: ADCBuf.h:290
int_fast16_t(* ADCBuf_ConvertCancelFxn)(ADCBuf_Handle handle)
A function pointer to a driver specific implementation of ADCBuf_convertCancel(). ...
Definition: ADCBuf.h:355
ADCBuf_OpenFxn openFxn
Definition: ADCBuf.h:395
ADCBuf_ControlFxn controlFxn
Definition: ADCBuf.h:391
ADCBuf Global configuration.
Definition: ADCBuf.h:419
ADCBuf_convertAdjustedToMicroVoltsFxn convertAdjustedToMicroVoltsFxn
Definition: ADCBuf.h:405
uint32_t adcChannel
Definition: ADCBuf.h:246
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:335
void * sampleBuffer
Definition: ADCBuf.h:241
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:253
void(* ADCBuf_CloseFxn)(ADCBuf_Handle handle)
A function pointer to a driver specific implementation of ADCBuf_close().
Definition: ADCBuf.h:321
ADCBuf_InitFxn initFxn
Definition: ADCBuf.h:393
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:268
Definition: ADCBuf.h:296
ADCBuf_ConvertCancelFxn convertCancelFxn
Definition: ADCBuf.h:399
void * custom
Definition: ADCBuf.h:314
ADCBuf_Handle ADCBuf_open(uint_least8_t index, ADCBuf_Params *params)
This function opens a given ADCBuf peripheral.
void * arg
Definition: ADCBuf.h:245
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