ADCBuf Driver

The ADCBuf header file should be included in an application as follows:

#include <ti/drivers/ADCBuf.h>

Operation

The ADCBuf driver in TI-RTOS samples an analogue waveform at a specified frequency. The resulting samples are transferred to a buffer provided by the application. The driver can either take n samples once, or continuously sample by double-buffering and providing a callback to process each finished buffer.

The APIs in this driver serve as an interface to a typical TI-RTOS application. The specific peripheral implementations are responsible to create all the SYS/BIOS specific primitives to allow for thread-safe operation.

The platform specific ADCBUF file present in the ti/drivers/adcbuf/platform directory. This file is built as a part of the ADCBUF Library for the specific platform.

Opening the driver

ADCBuf_Handle adcBufHandle;
ADCBuf_Params adcBufParams;
ADCBuf_Params_init(&adcBufParams);
adcBufHandle = ADCBuf_open(Board_ADCBuf0, &adcBufParams);

Making a conversion

In this context, a conversion refers to taking multiple ADC samples and transferring them to an application-provided buffer. To start a conversion, the application must configure an ADCBuf_Conversion struct and call ADCBuf_convert(). In blocking mode, ADCBuf_convert() will return when the conversion is finished and the desired number of samples have been made. In callback mode, ADCBuf_convert() will return immediately and the application will get a callback when the conversion is done.

ADCBuf_Conversion blockingConversion;
blockingConversion.arg = NULL;
blockingConversion.adcChannel = Board_ADCCHANNEL_A1;
blockingConversion.sampleBuffer = sampleBufferOnePtr;
blockingConversion.sampleBufferTwo = NULL;
blockingConversion.samplesRequestedCount = ADCBUFFERSIZE;
if (!ADCBuf_convert(adcBuf, &continuousConversion, 1)) {
// handle error
}

Canceling a conversion

ADCBuf_convertCancel() is used to cancel an ADCBuf conversion when the driver is used in ADCBuf_RETURN_MODE_CALLBACK.

Calling this API while no conversion is in progress has no effect. If a conversion is in progress, it is canceled and the provided callback function is called.

In ADCBuf_RECURRENCE_MODE_CONTINUOUS, this function must be called to stop the conversion. The driver will continue providing callbacks with fresh samples until thie ADCBuf_convertCancel() function is called. The callback function is not called after ADCBuf_convertCancel() while in ADCBuf_RECURRENCE_MODE_CONTINUOUS.

Implementation

This module serves as the main interface for TI-RTOS applications. Its purpose is to redirect the module's APIs to specific peripheral implementations which are specified using a pointer to an ADCBuf_FxnTable.

The ADCBuf driver interface module is joined (at link time) to a NULL-terminated array of ADCBuf_Config data structures named ADCBuf_config. ADCBuf_config is implemented in the application with each entry being an instance of an ADCBuf peripheral. Each entry in ADCBuf_config contains a:

Instrumentation

The ADCBuf driver interface produces log statements if instrumentation is enabled.

Diagnostics Mask Log details
Diags_USER1 basic operations performed
Diags_USER2 detailed operations performed


Copyright 2018, Texas Instruments Incorporated