![]() |
![]() |
TI-RTOS Drivers
tidrivers_full_2_20_01_10
|
ADCBuf driver implementation for a CC26XX analog-to-digital converter.
============================================================================
The ADCBuf header file should be included in an application as follows:
This is a CC26XX specific implementation of the generic TI-RTOS ADCBuf driver. The generic ADCBuf API specified in ti/drivers/ADCBuf.h should be called by the application, not the device specific implementation in ti/drivers/adcbuf/ADCBufCC26XX. The board file defines the device specific configuration and casting in the general API ensures the correct device specific functions are called. You should specify an ADCBufCC26XX_ParamsExtension in the custom field of the ADCBuf_Params that suits your application. The default settings work for many, but not all, usecases.
A timer and the DMA are used to trigger the ADC and fill a buffer in the background (in hardware) at a specified frequency. The application may execute other tasks while the hardware handles the conversions. In contrast to the standard ti/drivers/ADC driver, this driver allows for precise sampling of waveforms.
Driver | Number of samples needed in one call |
---|---|
ADC.h | 1 |
ADCBuf.h | > 1 |
This ADCBuf driver provides an API interface to using the analog-to-digital converter directly from the CM3 without going through the sensor controller. The sensor controller can still use the ADC, support for sharing the ADC resource between the sensor controller and the CM3 is built into the driver. There is a hardware semaphore that the driver must aqcuire before beginning any number of conversions. This same hardware semaphore also prevents the simultaneous use of this driver and the basic ADC driver.
The ADC drivers supports making between one and 1024 measurements once or continuous measuring with returned buffer sizes between one and 1024 measurements.
The application should call ADCBuf_init() once by the application to set the isOpened flag to false, indicating that the driver is ready to use.
The ADC driver is opened by calling ADCBuf_open() which will set up interrupts and configure the internal components of the driver. However, the ADC hardware or analog pins are not yet configured, since the sensor controller or basic ADC driver might be using the ADC.
In order to perform an ADC conversion, the application should call ADCBuf_convert(). This call will request the ADC resource, configure the ADC, set up the DMA and GPTimer, and perform the requested ADC conversions on the selected DIO or internal signal. The DIO or interrnal signal is defined by the ADCBuf_Conversion structure in the application code and adcBufCC26xxObjects in the board file. If the sensor controller is using the ADC when the driver requests it at the start of the ADC_convert() call, the conversion will fail and return false. The ADC resource may be pre-acquired by calling the control function ADCBufCC26XX_CMD_ACQUIRE_ADC_SEMAPHORE. It will be released again automatically after the next conversion completes.
In both ADCBufCC26XX_SAMPING_MODE_SYNCHRONOUS mode and ADCBufCC26XX_SAMPING_MODE_ASYNCHRONOUS mode, enough sampling time must be provided between conversions that each measurement may be completed before the next trigger arrives.
Below is a table of the supported ADC IO pins for each package size, for both CC26xx and CC13xx. It maps a DIO to its corresponding driverlib define for the CompBInput that it is hardwired to. This table can be used to create virtual channel entries in the ADCBufCC26XX_adcChannelLut table in the board file.
DIO | CC26xx 7x7 AUXIO CompBInput | CC13xx 7x7 AUXIO CompBInput | CC26xx 5x5 AUXIO CompBInput | CC13xx 5x5 AUXIO CompBInput | CC26xx 4x4 AUXIO CompBInput | CC13xx 4x4 AUXIO CompBInput |
---|---|---|---|---|---|---|
0 | No | No | No | No | No | No |
1 | No | No | No | No | No | No |
2 | No | No | No | No | No | No |
3 | No | No | No | No | No | No |
4 | No | No | No | No | No | No |
5 | No | No | No | No | ADC_COMPB_IN_AUXIO7 | ADC_COMPB_IN_AUXIO7 |
6 | No | No | No | No | ADC_COMPB_IN_AUXIO6 | ADC_COMPB_IN_AUXIO6 |
7 | No | No | ADC_COMPB_IN_AUXIO7 | ADC_COMPB_IN_AUXIO7 | ADC_COMPB_IN_AUXIO5 | ADC_COMPB_IN_AUXIO5 |
8 | No | No | ADC_COMPB_IN_AUXIO6 | ADC_COMPB_IN_AUXIO6 | ADC_COMPB_IN_AUXIO4 | ADC_COMPB_IN_AUXIO4 |
9 | No | No | ADC_COMPB_IN_AUXIO5 | ADC_COMPB_IN_AUXIO5 | ADC_COMPB_IN_AUXIO3 | ADC_COMPB_IN_AUXIO3 |
10 | No | No | ADC_COMPB_IN_AUXIO4 | ADC_COMPB_IN_AUXIO4 | No | No |
11 | No | No | ADC_COMPB_IN_AUXIO3 | ADC_COMPB_IN_AUXIO3 | No | No |
12 | No | No | ADC_COMPB_IN_AUXIO2 | ADC_COMPB_IN_AUXIO2 | No | No |
13 | No | No | ADC_COMPB_IN_AUXIO1 | ADC_COMPB_IN_AUXIO1 | No | No |
14 | No | No | ADC_COMPB_IN_AUXIO0 | ADC_COMPB_IN_AUXIO0 | No | No |
15-22 | No | No | No | No | No | No |
23 | ADC_COMPB_IN_AUXIO7 | ADC_COMPB_IN_AUXIO7 | No | No | No | No |
24 | ADC_COMPB_IN_AUXIO6 | ADC_COMPB_IN_AUXIO6 | No | No | No | No |
25 | ADC_COMPB_IN_AUXIO5 | ADC_COMPB_IN_AUXIO5 | No | No | No | No |
26 | ADC_COMPB_IN_AUXIO4 | ADC_COMPB_IN_AUXIO4 | No | No | No | No |
27 | ADC_COMPB_IN_AUXIO3 | ADC_COMPB_IN_AUXIO3 | No | No | No | No |
28 | ADC_COMPB_IN_AUXIO2 | ADC_COMPB_IN_AUXIO2 | No | No | No | No |
29 | ADC_COMPB_IN_AUXIO1 | ADC_COMPB_IN_AUXIO1 | No | No | No | No |
30 | ADC_COMPB_IN_AUXIO0 | ADC_COMPB_IN_AUXIO0 | No | No | No | No |
Below is a table of internal signals that can be measured using the ADC. Since we are not connecting to a DIO, there is no DIO to internal signal mapping. The DIO field in the channel lookup table should be marked PIN_UNASSIGNED. This table can be used to create virtual channel entries in the ADCBufCC26XX_adcChannelLut table in the board file.
DIO | Internal Signal CompBInput |
---|---|
PIN_UNASSIGNED | ADC_COMPB_IN_DCOUPL |
PIN_UNASSIGNED | ADC_COMPB_IN_VSS |
PIN_UNASSIGNED | ADC_COMPB_IN_VDDS |
The following errors may occur when opening the ADC without assertions enabled:
The following errors may occur when requesting an ADC conversion:
The TI-RTOS power management framework will try to put the device into the most power efficient mode whenever possible. Please see the technical reference manual for further details on each power mode.
While converting, the ADCBufCC26XX driver sets a power constraint to keep the device out of standby. When the conversion has finished, the power constraint is released. The driver also sets a dependency on the DMA to enable background transfers from the ADC FIFO to memory and to clear the GPTimer interrupt. The following statements are valid:
API function | Description |
---|---|
ADCBuf_init() | Initialize ADC driver |
ADCBuf_open() | Open the ADC driver and configure driver |
ADCBuf_convert() | Perform ADC conversion |
ADCBuf_convertCancel() | Cancel ongoing ADC conversion |
ADCBuf_close() | Close ADC driver |
ADCBuf_Params_init() | Initialise ADCBuf_Params structure to default values |
ADCBuf_getResolution() | Get the resolution of the ADC of the current device |
ADCBuf_adjustRawValues() | Adjust the values in a returned buffer for manufacturing tolerances |
ADCBuf_convertAdjustedToMicroVolts | Convert a buffer of adjusted values to microvolts |
ADCBuf_control() | Execute device specific functions |
TBD
Perform one conversion on Board_ADCCHANNEL_A1 in ADCBuf_RETURN_MODE_BLOCKING.
The ADC driver interface produces log statements if instrumentation is enabled.
Diagnostics Mask | Log details |
---|---|
Diags_USER1 | basic ADCBuf operations performed |
Diags_USER2 | detailed ADCBuf operations performed |
#include <stdint.h>
#include <stdbool.h>
#include <ti/drivers/ADCBuf.h>
#include <ti/drivers/PIN.h>
#include <ti/drivers/pin/PINCC26XX.h>
#include <ti/drivers/dma/UDMACC26XX.h>
#include <ti/drivers/timer/GPTimerCC26XX.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.h>
#include <driverlib/aux_adc.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Swi.h>
Go to the source code of this file.
Data Structures | |
struct | ADCBufCC26XX_AdcChannelLutEntry |
Table entry that maps a virtual adc channel to a dio and its corresponding internal analogue signal. More... | |
struct | ADCBufCC26XX_ParamsExtension |
CC26XX specfic extension to ADCBuf_Params. More... | |
struct | ADCBufCC26XX_HWAttrs |
ADCBufCC26XX Hardware Attributes. More... | |
struct | ADCBufCC26XX_Object |
ADCBufCC26XX Object. More... | |
Macros | |
#define | ti_sysbios_family_arm_m3_Hwi__nolocalnames |
#define | ADCBufCC26XX_CMD_ACQUIRE_ADC_SEMAPHORE ADCBuf_CMD_RESERVED + 1 |
This control function acquires the semaphore that arbitrates access to the ADC between the CM3 and the sensor controller. More... | |
#define | ADCBufCC26XX_CMD_KEEP_ADC_SEMAPHORE ADCBuf_CMD_RESERVED + 2 |
This function makes the ADC driver keep the ADC semaphore until released. More... | |
#define | ADCBufCC26XX_CMD_KEEP_ADC_SEMAPHORE_DISABLE ADCBuf_CMD_RESERVED + 3 |
This function makes the ADC driver no longer keep the ADC semaphore until released. More... | |
#define | ADCBufCC26XX_CMD_RELEASE_ADC_SEMAPHORE ADCBuf_CMD_RESERVED + 4 |
This function releases the ADC semaphore. More... | |
#define | ADCBufCC26XX_RESOLUTION 12 |
Resolution in bits of the CC26XX ADC. More... | |
#define | ADCBufCC26XX_BYTES_PER_SAMPLE 2 |
Typedefs | |
typedef enum ADCBufCC26XX_Sampling_Mode | ADCBufCC26XX_Sampling_Mode |
Specifies whether the internal reference of the ADC is sourced from the battery voltage or a fixed internal source. More... | |
typedef enum ADCBufCC26XX_Sampling_Duration | ADCBufCC26XX_Sampling_Duration |
Amount of time the ADC spends sampling the analogue input. More... | |
typedef enum ADCBufCC26XX_Reference_Source | ADCBufCC26XX_Reference_Source |
Specifies whether the internal reference of the ADC is sourced from the battery voltage or a fixed internal source. More... | |
typedef struct ADCBufCC26XX_AdcChannelLutEntry | ADCBufCC26XX_AdcChannelLutEntry |
Table entry that maps a virtual adc channel to a dio and its corresponding internal analogue signal. More... | |
typedef struct ADCBufCC26XX_ParamsExtension | ADCBufCC26XX_ParamsExtension |
CC26XX specfic extension to ADCBuf_Params. More... | |
typedef struct ADCBufCC26XX_HWAttrs | ADCBufCC26XX_HWAttrs |
ADCBufCC26XX Hardware Attributes. More... | |
typedef struct ADCBufCC26XX_Object | ADCBufCC26XX_Object |
ADCBufCC26XX Object. More... | |
typedef struct ADCBufCC26XX_Object * | ADCBufCC26XX_Handle |
Enumerations | |
enum | ADCBufCC26XX_Sampling_Mode { ADCBufCC26XX_SAMPING_MODE_SYNCHRONOUS, ADCBufCC26XX_SAMPING_MODE_ASYNCHRONOUS } |
Specifies whether the internal reference of the ADC is sourced from the battery voltage or a fixed internal source. More... | |
enum | ADCBufCC26XX_Sampling_Duration { ADCBufCC26XX_SAMPLING_DURATION_2P7_US = AUXADC_SAMPLE_TIME_2P7_US, ADCBufCC26XX_SAMPLING_DURATION_5P3_US = AUXADC_SAMPLE_TIME_5P3_US, ADCBufCC26XX_SAMPLING_DURATION_10P6_US = AUXADC_SAMPLE_TIME_10P6_US, ADCBufCC26XX_SAMPLING_DURATION_21P3_US = AUXADC_SAMPLE_TIME_21P3_US, ADCBufCC26XX_SAMPLING_DURATION_42P6_US = AUXADC_SAMPLE_TIME_42P6_US, ADCBufCC26XX_SAMPLING_DURATION_85P3_US = AUXADC_SAMPLE_TIME_85P3_US, ADCBufCC26XX_SAMPLING_DURATION_170_US = AUXADC_SAMPLE_TIME_170_US, ADCBufCC26XX_SAMPLING_DURATION_341_US = AUXADC_SAMPLE_TIME_341_US, ADCBufCC26XX_SAMPLING_DURATION_682_US = AUXADC_SAMPLE_TIME_682_US, ADCBufCC26XX_SAMPLING_DURATION_1P37_MS = AUXADC_SAMPLE_TIME_1P37_MS, ADCBufCC26XX_SAMPLING_DURATION_2P73_MS = AUXADC_SAMPLE_TIME_2P73_MS, ADCBufCC26XX_SAMPLING_DURATION_5P46_MS = AUXADC_SAMPLE_TIME_5P46_MS, ADCBufCC26XX_SAMPLING_DURATION_10P9_MS = AUXADC_SAMPLE_TIME_10P9_MS } |
Amount of time the ADC spends sampling the analogue input. More... | |
enum | ADCBufCC26XX_Reference_Source { ADCBufCC26XX_FIXED_REFERENCE = AUXADC_REF_FIXED, ADCBufCC26XX_VDDS_REFERENCE = AUXADC_REF_VDDS_REL } |
Specifies whether the internal reference of the ADC is sourced from the battery voltage or a fixed internal source. More... | |
Variables | |
const ADCBuf_FxnTable | ADCBufCC26XX_fxnTable |
#define ti_sysbios_family_arm_m3_Hwi__nolocalnames |
#define ADCBufCC26XX_RESOLUTION 12 |
Resolution in bits of the CC26XX ADC.
#define ADCBufCC26XX_BYTES_PER_SAMPLE 2 |
typedef enum ADCBufCC26XX_Sampling_Mode ADCBufCC26XX_Sampling_Mode |
Specifies whether the internal reference of the ADC is sourced from the battery voltage or a fixed internal source.
The CC26XX ADC can operate in two different ways with regards to the sampling phase of the ADC conversion process:
In ADCBufCC26XX_SYNCHRONOUS mode, the ADC goes into IDLE in between conversions and uses less power. The minimum sample time for full precision in ADCBufCC26XX_SAMPING_MODE_SYNCHRONOUS is dependent on the input load.
Amount of time the ADC spends sampling the analogue input.
The analogue to digital conversion process consists of two phases in the CC26XX ADC, the sampling and conversion phases. During the sampling phase, the ADC samples the analogue input signal. Larger input loads require longer sample times for the most accurate results. In ADCBufCC26XX_SAMPING_MODE_SYNCHRONOUS mode, this enum specifies the sampling times available.
Specifies whether the internal reference of the ADC is sourced from the battery voltage or a fixed internal source.
typedef struct ADCBufCC26XX_AdcChannelLutEntry ADCBufCC26XX_AdcChannelLutEntry |
Table entry that maps a virtual adc channel to a dio and its corresponding internal analogue signal.
Non-dio signals can be used as well. To do this, compBInput is set to the driverlib define corresponding to the desired non-dio signal and dio is set to PIN_UNASSIGNED.
typedef struct ADCBufCC26XX_ParamsExtension ADCBufCC26XX_ParamsExtension |
CC26XX specfic extension to ADCBuf_Params.
To use non-default CC26XX specific parameters when calling ADCBuf_open(), a pointer to an instance of this struct must be specified in ADCBuf_Params::custom. Alternatively, these values can be set using the control function after calling ADCBuf_open().
typedef struct ADCBufCC26XX_HWAttrs ADCBufCC26XX_HWAttrs |
ADCBufCC26XX Hardware Attributes.
These fields are used by driverlib APIs and therefore must be populated by driverlib macro definitions. For CC26xxWare these definitions are found in:
A sample structure is shown below:
typedef struct ADCBufCC26XX_Object ADCBufCC26XX_Object |
ADCBufCC26XX Object.
The application must not access any member variables of this structure!
typedef struct ADCBufCC26XX_Object * ADCBufCC26XX_Handle |
Specifies whether the internal reference of the ADC is sourced from the battery voltage or a fixed internal source.
The CC26XX ADC can operate in two different ways with regards to the sampling phase of the ADC conversion process:
In ADCBufCC26XX_SYNCHRONOUS mode, the ADC goes into IDLE in between conversions and uses less power. The minimum sample time for full precision in ADCBufCC26XX_SAMPING_MODE_SYNCHRONOUS is dependent on the input load.
Enumerator | |
---|---|
ADCBufCC26XX_SAMPING_MODE_SYNCHRONOUS | |
ADCBufCC26XX_SAMPING_MODE_ASYNCHRONOUS |
Amount of time the ADC spends sampling the analogue input.
The analogue to digital conversion process consists of two phases in the CC26XX ADC, the sampling and conversion phases. During the sampling phase, the ADC samples the analogue input signal. Larger input loads require longer sample times for the most accurate results. In ADCBufCC26XX_SAMPING_MODE_SYNCHRONOUS mode, this enum specifies the sampling times available.
Specifies whether the internal reference of the ADC is sourced from the battery voltage or a fixed internal source.
Enumerator | |
---|---|
ADCBufCC26XX_FIXED_REFERENCE | |
ADCBufCC26XX_VDDS_REFERENCE |
const ADCBuf_FxnTable ADCBufCC26XX_fxnTable |