SAIL API Guide
Data Structures | Macros | Typedefs | Enumerations | Functions
ads7142.h File Reference

Detailed Description

ADS7142 Nanopower, Dual-channel Programmable Sensor Monitor.

============================================================================

The ADS7142 is a Nanopower, Dual-channel Programmable Sensor Monitor. It is interfaced to the MCU using I2C. It has two input channels which can operate seperately as well as together. It supports various operation modes which are:

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

Operation

The ADS7142 driver simplifies using a ADS7142 Nanopower, Dual-channel Programmable Sensor Monitor. A ADS7142_config array should be defined by the application. The ADS7142_config array should contain pointers to a defined ADS7142_HwAttrs and allocated array for the ADS7142_Object structures. ADS7142_init() must be called prior to using ADS7142_open().

The APIs in this driver serve as an interface to a DPL(Driver Porting Layer) The specific implementations are responsible for creating all the RTOS specific primitives to allow for thread-safe operation.

This driver has no dynamic memory allocation.

Defining ADS7142_Config, ADS7142_Object and ADS7142_HwAttrs

Each structure must be defined by the application. The following example is for a MSP432 in which an ADS7142 sensor monitor is setup. The following declarations are placed in "MSP_EXP432P401R.h" and "MSP_EXP432P401R.c" respectively.

"MSP_EXP432P401R.h"

typedef enum MSP_EXP432P401R_ADS7142Name {
MSP_EXP432P401R_ADS7142_0 = 0,
MSP_EXP432P401R_ADS7142COUNT
} MSP_EXP432P401R_ADS7142Name;

"MSP_EXP432P401R.c"

ADS7142_Object ADS7142_object[MSP_EXP432P401R_ADS7142COUNT];
const ADS7142_HWAttrs ADS7142_hwAttrs[MSP_EXP432P401R_ADS7142COUNT] = {
{
.alertGPIOIndex = MSP_EXP432P401R_ADS7142_INT0,
.dataReadyGPIOIndex = MSP_EXP432P401R_ADS7142_INT1
},
};
{
.hwAttrs = (void *)&ADS7142_hwAttrs[0],
.objects = (void *)&ADS7142_object[0],
},
{NULL, NULL},
};
const uint_least8_t ADS7142_count = MSP_EXP432P401R_ADS7142COUNT;

Setting up GPIO configurations

The following example is for a MSP432. Each ADS7142 sensor monitor needs two GPIO pins for Busy/RDY and ALERT callbacks. The following definitions are in "MSP_EXP432P401R.h" and "MSP_EXP432P401R.c" respectively. This example uses GPIO pins 5.0 and 3.7. The GPIO_CallbackFxn table must contain as many indices as GPIO_CallbackFxns specified by the application. For each data ready and alert pin used, an index should be allocated as NULL.

Opening a ADS7142 with default parameters

The ADS7142_open() call must be made in a task context.


#include <stdbool.h>
#include <ti/drivers/I2C.h>
#include <ti/drivers/GPIO.h>

Go to the source code of this file.

Data Structures

struct  ADS7142_Config
 ADS7142 configuration. More...
 
struct  ADS7142_HWAttrs
 Hardware specific settings for a ADS7142 sensor monitor. More...
 
struct  ADS7142_Object
 Members should not be accessed by the application. More...
 
struct  ADS7142_thresholds
 ADS7142 channel thresholds. More...
 
struct  ADS7142_Params
 ADS7142 Parameters. More...
 

Macros

#define ADS7142_REG_WKEY   0x17U
 
#define ADS7142_REG_DEVICE_RESET   0x14U
 
#define ADS7142_REG_OFFSET_CAL   0x15U
 
#define ADS7142_OPMODE_SEL   0x1CU
 
#define ADS7142_REG_OPMODE_I2CMODE_STATUS   0x00U
 
#define ADS7142_REG_CHANNEL_INPUT_CFG   0x24U
 
#define ADS7142_REG_AUTO_SEQ_CHEN   0x20U
 
#define ADS7142_REG_START_SEQUENCE   0x1EU
 
#define ADS7142_REG_ABORT_SEQUENCE   0x1FU
 
#define ADS7142_REG_SEQUENCE_STATUS   0x04U
 
#define ADS7142_REG_OSC_SEL   0x18U
 
#define ADS7142_REG_nCLK_SEL   0x19U
 
#define ADS7142_REG_DATA_BUFFER_OPMODE   0x2CU
 
#define ADS7142_REG_DOUT_FORMAT_CFG   0x28U
 
#define ADS7142_REG_DATA_BUFFER_STATUS   0x01U
 
#define ADS7142_REG_ACC_EN   0x30U
 
#define ADS7142_REG_ACC_EN_OFF   0x00U
 
#define ADS7142_REG_ACC_CH0_LSB   0x08U
 
#define ADS7142_REG_ACC_CH0_MSB   0x09U
 
#define ADS7142_REG_ACC_CH1_LSB   0x0AU
 
#define ADS7142_REG_ACC_CH1_MSB   0x0BU
 
#define ADS7142_REG_ACCUMULATOR_STATUS   0x02U /*Provides the present status of Accumulator (Read only) *Bits 3-0 of this register yield the number of accumulations completed until the last finished conversion*/
 
#define ADS7142_REG_ALERT_DWC_EN   0x37U
 
#define ADS7142_REG_ALERT_CHEN   0x34U
 
#define ADS7142_REG_DWC_HTH_CH0_MSB   0x39U
 
#define ADS7142_REG_DWC_HTH_CH0_LSB   0x38U
 
#define ADS7142_REG_DWC_LTH_CH0_MSB   0x3BU
 
#define ADS7142_REG_DWC_LTH_CH0_LSB   0x3AU
 
#define ADS7142_REG_DWC_HYS_CH0   0x40U
 
#define ADS7142_REG_DWC_HTH_CH1_MSB   0x3DU
 
#define ADS7142_REG_DWC_HTH_CH1_LSB   0x3CU
 
#define ADS7142_REG_DWC_LTH_CH1_MSB   0x3FU
 
#define ADS7142_REG_DWC_LTH_CH1_LSB   0x3EU
 
#define ADS7142_REG_DWC_HYS_CH1   0x41U
 
#define ADS7142_REG_ALERT_TRIG_CH_ID   0x03U
 
#define ADS7142_REG_ALERT_LOW_FLAGS   0x0CU
 
#define ADS7142_REG_ALERT_HIGH_FLAGS   0x0EU
 
#define ADS7142_VAL_WKEY_RESET   0x00U
 
#define ADS7142_VAL_WKEY_DEVICE_RESET   0x0AU
 
#define ADS7142_VAL_DEVICE_RESET_RESET   0x01U
 
#define ADS7142_VAL_OPMODE_SEL_MAN_MODE_AUTO_SEQ_EN   0x04U
 
#define ADS7142_VAL_OPMODE_SEL_AUTONOMOUS_MODE   0x06U
 
#define ADS7142_VAL_OPMODE_SEL_HIGH_PRECISION_MODE   0x07U
 
#define ADS7142_VAL_OPMODE_I2CMODE_HS_1   0x08U
 
#define ADS7142_VAL_OPMODE_I2CMODE_HS_2   0x0FU
 
#define ADS7142_VAL_TRIG_OFFCAL   0x01U
 
#define ADS7142_VAL_START_SEQUENCE   0x01U
 
#define ADS7142_VAL_ABORT_SEQUENCE   0x01U
 
#define ADS7142_VAL_DOUT_FORMAT_CFG_DOUT_FORMAT0   0x00U
 
#define ADS7142_VAL_DOUT_FORMAT_CFG_DOUT_FORMAT1   0x01U
 
#define ADS7142_VAL_DOUT_FORMAT_CFG_DOUT_FORMAT2   0x02U
 
#define ADS7142_VAL_DOUT_FORMAT_CFG_DOUT_FORMAT3   0x03U
 
#define ADS7142_VAL_ACC_EN   0x0FU
 
#define ADS7142_VAL_ALERT_DWC_BLOCK_ENABLE   0x01U
 
#define ADS7142_VAL_ALERT_DWC_BLOCK_DISABLE   0x00U
 
#define ADS7142_VAL_ALERT_EN_CH0   0x01U
 
#define ADS7142_VAL_ALERT_EN_CH1   0x02U
 
#define ADS7142_VAL_ALERT_EN_CH0_CH1   0x03U
 
#define SINGLE_REG_READ   0x10U
 
#define SINGLE_REG_WRITE   0x08U
 

Typedefs

typedef struct ADS7142_ConfigADS7142_Handle
 A handle that is returned from a ADS7142_open() call. More...
 
typedef enum ADS7142_channelConfig ADS7142_channelConfig
 ADS7142 channel configuration. More...
 
typedef enum ADS7142_slaveAddress ADS7142_slaveAddress
 ADS7142 I2C slave addresses. More...
 
typedef enum ADS7142_opMode ADS7142_opMode
 ADS7142 operation mode selection. More...
 
typedef enum ADS7142_channelSelect ADS7142_channelSelect
 ADS7142 autosequencing channel selection. More...
 
typedef enum ADS7142_oscSelect ADS7142_oscSelect
 ADS7142 oscillator selection. More...
 
typedef enum ADS7142_autonomousSubModes ADS7142_autonomousSubModes
 ADS7142 Autonomous-submodes selection. More...
 
typedef struct ADS7142_Config ADS7142_Config
 ADS7142 configuration. More...
 
typedef struct ADS7142_HWAttrs ADS7142_HWAttrs
 Hardware specific settings for a ADS7142 sensor monitor. More...
 
typedef struct ADS7142_Object ADS7142_Object
 Members should not be accessed by the application. More...
 
typedef struct ADS7142_thresholds ADS7142_thresholds
 ADS7142 channel thresholds. More...
 
typedef struct ADS7142_Params ADS7142_Params
 ADS7142 Parameters. More...
 

Enumerations

enum  ADS7142_channelConfig { ADS7142_channelConfig_DCSE = 0x00U, ADS7142_channelConfig_SCSE = 0x01U, ADS7142_channelConfig_SCPD = 0x02U }
 ADS7142 channel configuration. More...
 
enum  ADS7142_slaveAddress {
  ADS7142_SA1 = 0x1FU, ADS7142_SA2 = 0x1EU, ADS7142_SA3 = 0x1DU, ADS7142_SA4 = 0x1CU,
  ADS7142_SA5 = 0x18U, ADS7142_SA6 = 0x19U, ADS7142_SA7 = 0x1AU, ADS7142_SA8 = 0x1BU
}
 ADS7142 I2C slave addresses. More...
 
enum  ADS7142_opMode { ADS7142_opMode_manual = 0U, ADS7142_opMode_autonomous = 1U, ADS7142_opMode_highPrecision = 2U }
 ADS7142 operation mode selection. More...
 
enum  ADS7142_channelSelect { ADS7142_channelSelect_CH0 = 0x01U, ADS7142_channelSelect_CH1 = 0x02U, ADS7142_channelSelect_CH0_CH1 = 0x03U }
 ADS7142 autosequencing channel selection. More...
 
enum  ADS7142_oscSelect { ADS7142_oscSelect_LPO = 0x01U, ADS7142_oscSelect_HSO = 0x00U }
 ADS7142 oscillator selection. More...
 
enum  ADS7142_autonomousSubModes { ADS7142_autonomousSubModes_preAlert = 0x04U, ADS7142_autonomousSubModes_postAlert = 0x06U, ADS7142_autonomousSubModes_startBurst = 0x01U, ADS7142_autonomousSubModes_stopBurst = 0x00U }
 ADS7142 Autonomous-submodes selection. More...
 

Functions

void ADS7142_init ()
 Function to initialize ADS7142 driver. More...
 
void ADS7142_initParams (ADS7142_Params *params)
 Function to initialize a ADS7142_Params struct to its defaults. More...
 
ADS7142_Handle ADS7142_open (unsigned int ADS7142Index, ADS7142_Params *params, I2C_Handle i2cHandle)
 Function to open a given ADS7142 sensor monitor. More...
 
bool ADS7142_close (ADS7142_Handle handle)
 Function to close a ADS7142 sensor monitor specified by the ADS7142 handle. More...
 
bool ADS7142_calibrate (ADS7142_Handle handle)
 Function to calibrate a ADS7142 sensor monitor specified by the ADS7142 handle. More...
 
bool ADS7142_selectAutonomousSubMode (ADS7142_Handle handle, ADS7142_autonomousSubModes mode)
 Function to select submode of Autonomous mode of a ADS7142 sensor. More...
 
bool ADS7142_setThresholds (ADS7142_Handle handle, ADS7142_thresholds *thresholdValues)
 Function to set thresholds while running Alert Diagnostics in a ADS7142 sensor. More...
 
void ADS7142_getAlertFlagStatus (ADS7142_Handle handle, uint8_t *lowFlagStatus, uint8_t *highFlagStatus)
 Function to get the status of ALert flags of ADS7142. More...
 
bool ADS7142_clearAlertFlags (ADS7142_Handle handle)
 Function to clear the alert flags of ADS7142. More...
 
ADS7142_opMode ADS7142_getopMode (ADS7142_Handle)
 Function to get the opMode of ADS7142. More...
 
ADS7142_autonomousSubModes ADS7142_getsubMode (ADS7142_Handle)
 Function to get the Autonomous-subMode of ADS7142. More...
 
bool ADS7142_selectChannelConfig (ADS7142_Handle handle, ADS7142_channelConfig channelConfig)
 function to select Channel configuration More...
 
bool ADS7142_selectOpMode (ADS7142_Handle handle, ADS7142_opMode mode, ADS7142_channelSelect channel, ADS7142_oscSelect osc)
 function to select opeMode of ADS7142. More...
 
bool ADS7142_readDataInManualMode (ADS7142_Handle handle, uint16_t numConversion, uint8_t *data)
 function to read data in manual mode operation. More...
 
bool ADS7142_abortSequence (ADS7142_Handle handle)
 function to abort sequence of operation. More...
 
bool ADS7142_startSequence (ADS7142_Handle handle)
 function to start sequence of operation. More...
 
bool ADS7142_readAccumulator (ADS7142_Handle handle, uint16_t *accCH0, uint16_t *accCH1)
 function to read the ADS7142 accumulator data. More...
 
bool ADS7142_disableDWCAlert (ADS7142_Handle handle)
 function to disable DWC in ADS7142 More...
 
bool ADS7142_enableDWCAlert (ADS7142_Handle handle)
 function to enable DWC in ADS7142 More...
 
bool ADS7142_readDataBuffer (ADS7142_Handle handle, uint16_t *data)
 function to read the data buffer. More...
 
bool ADS7142_writeRegisterSingle (ADS7142_Handle handle, uint8_t data, uint8_t registerAddress)
 Write function for advanced users. This is not thread safe. More...
 
bool ADS7142_readRegisterSingle (ADS7142_Handle handle, uint8_t *data, uint8_t registerAddress)
 Read function for advanced users. More...
 

Typedef Documentation

§ ADS7142_Handle

typedef struct ADS7142_Config* ADS7142_Handle

A handle that is returned from a ADS7142_open() call.

§ ADS7142_channelConfig

ADS7142 channel configuration.

This enumeration defines the number of channel configurations available for manual mode operations of ADS7142 sensor monitor.The supported configurations are:

  • Double channel, single ended.
  • Single Channel, single ended.
  • Single Channel, pseudo differential.

§ ADS7142_slaveAddress

ADS7142 I2C slave addresses.

§ ADS7142_opMode

ADS7142 operation mode selection.

This enumeration defines the operation modes available for ADS7142. configurations are:

  • Manual Mode.
  • Autonomous Mode.
  • High-Precision Mode.

§ ADS7142_channelSelect

ADS7142 autosequencing channel selection.

This enumeration defines the channel options available for autosequencing operation. configurations are:

  • CH0 Only.
  • CH1 Only
  • CH0 and CH1 both.

§ ADS7142_oscSelect

ADS7142 oscillator selection.

This enumeration defines the options available for selection of internal oscillator during sequencing. configurations are:

  • Low Power Oscillator.
  • High Speed Oscillator.

§ ADS7142_autonomousSubModes

ADS7142 Autonomous-submodes selection.

This enumeration defines the options of autonomous mode operations supported by ADS7142 sensor monitor. The supported modes are:

  • Autonomous mode with pre-alert.
  • Autonomous mode with post-alert.
  • Autonomous mode with start-burst.
  • Autonomous mode with stop-burst.

§ ADS7142_Config

ADS7142 configuration.

The ADS7142_Config structure contains a set of pointers used to characterize the ADS7142 driver implementation.

This structure needs to be defined and provided by the application.

§ ADS7142_HWAttrs

Hardware specific settings for a ADS7142 sensor monitor.

This structure should be defined and provided by the application. The gpioIndex should be defined in accordance of the GPIO driver. The pin must be configured as GPIO_CFG_INPUT and GPIO_CFG_IN_INT_FALLING.

§ ADS7142_Object

Members should not be accessed by the application.

§ ADS7142_thresholds

ADS7142 channel thresholds.

ADS7142 channel thresholds are used to give the value of thresholds while using Alert Diagnostic modes

§ ADS7142_Params

ADS7142 Parameters.

ADS7142 parameters are used with the ADS7142_open() call. Default values for these parameters are set using ADS7142_initParams(). It contains the callbacks for two GPIO callbacks present on ADS7142 BoosterPack.

See also
ADS7142_initParams()

Enumeration Type Documentation

§ ADS7142_channelConfig

ADS7142 channel configuration.

This enumeration defines the number of channel configurations available for manual mode operations of ADS7142 sensor monitor.The supported configurations are:

  • Double channel, single ended.
  • Single Channel, single ended.
  • Single Channel, pseudo differential.
Enumerator
ADS7142_channelConfig_DCSE 

Double channel, single ended.

ADS7142_channelConfig_SCSE 

Single Channel, single ended

ADS7142_channelConfig_SCPD 

Single Channel, pseudo differential.

§ ADS7142_slaveAddress

ADS7142 I2C slave addresses.

Enumerator
ADS7142_SA1 

R1=0, R2=DNP

ADS7142_SA2 

R1=11, R2=DNP

ADS7142_SA3 

R1=33, R2=DNP

ADS7142_SA4 

R1=100, R2=DNP

ADS7142_SA5 

R1=DNP, R2=DNP

ADS7142_SA6 

R1=DNP, R2=11

ADS7142_SA7 

R1=DNP, R2=33

ADS7142_SA8 

R1=DNP, R2=100

§ ADS7142_opMode

ADS7142 operation mode selection.

This enumeration defines the operation modes available for ADS7142. configurations are:

  • Manual Mode.
  • Autonomous Mode.
  • High-Precision Mode.
Enumerator
ADS7142_opMode_manual 

Manual Mode.

ADS7142_opMode_autonomous 

Autonomous Mode.

ADS7142_opMode_highPrecision 

High-Precision Mode.

§ ADS7142_channelSelect

ADS7142 autosequencing channel selection.

This enumeration defines the channel options available for autosequencing operation. configurations are:

  • CH0 Only.
  • CH1 Only
  • CH0 and CH1 both.
Enumerator
ADS7142_channelSelect_CH0 

CH0 Only.

ADS7142_channelSelect_CH1 

CH1 Only

ADS7142_channelSelect_CH0_CH1 

CH0 and CH1 both.

§ ADS7142_oscSelect

ADS7142 oscillator selection.

This enumeration defines the options available for selection of internal oscillator during sequencing. configurations are:

  • Low Power Oscillator.
  • High Speed Oscillator.
Enumerator
ADS7142_oscSelect_LPO 

Low Power Oscillator.

ADS7142_oscSelect_HSO 

High Speed Oscillator.

§ ADS7142_autonomousSubModes

ADS7142 Autonomous-submodes selection.

This enumeration defines the options of autonomous mode operations supported by ADS7142 sensor monitor. The supported modes are:

  • Autonomous mode with pre-alert.
  • Autonomous mode with post-alert.
  • Autonomous mode with start-burst.
  • Autonomous mode with stop-burst.
Enumerator
ADS7142_autonomousSubModes_preAlert 

Autonomous mode with pre-alert.

ADS7142_autonomousSubModes_postAlert 

Autonomous mode with post-alert.

ADS7142_autonomousSubModes_startBurst 

Autonomous mode with start-burst.

ADS7142_autonomousSubModes_stopBurst 

Autonomous mode with stop-burst.

Function Documentation

§ ADS7142_init()

void ADS7142_init ( )

Function to initialize ADS7142 driver.

This function will initialize the ADS7142 driver.

§ ADS7142_initParams()

void ADS7142_initParams ( ADS7142_Params params)

Function to initialize a ADS7142_Params struct to its defaults.

Parameters
paramsA pointer to ADS7142_Params structure for initialization.

Default values are: dataReadyCallbackFxn = NULL alertCallbackFxn = NULL

References ADS7142_defaultParams.

§ ADS7142_open()

ADS7142_Handle ADS7142_open ( unsigned int  ADS7142Index,
ADS7142_Params params,
I2C_Handle  i2cHandle 
)

Function to open a given ADS7142 sensor monitor.

Function to initialize a given ADS7142 sensor specified by the particular index value. This function must be called from a thread context. If one intends to use the data ready pin and the alert pin, two callBack functions must be specified in the ADS7142_Params structure. Additionally, two gpioInduces must be setup and specified in the ADS7142_HWAttrs structure.

The I2C controller must be operating in BLOCKING mode. Failure to ensure the I2C_Handle is in BLOCKING mode will result in undefined behavior.

The user should ensure that each sensor has its own slaveAddress, gpioIndex (if alarming) and ADS7142Index.

Precondition
ADS7142_init() has to be called first
Parameters
ADS7142IndexLogical sensor number for the ADS7142 indexed into the ADS7142_config table
i2cHandleAn I2C_Handle opened in BLOCKING mode
Returns
A ADS7142_Handle on success, or a NULL on failure.
See also
ADS7142_init()
ADS7142_close()

References ADS7142_count, ADS7142_Object::alertCallbackFxn, ADS7142_Params::alertCallbackFxn, ADS7142_Object::dataReadyCallbackFxn, ADS7142_Params::dataReadyCallbackFxn, ADS7142_Object::i2cHandle, and ADS7142_Config::object.

§ ADS7142_close()

bool ADS7142_close ( ADS7142_Handle  handle)

Function to close a ADS7142 sensor monitor specified by the ADS7142 handle.

The ADS7142 hardware will be placed in a low power state in which ADC conversions are disabled. If there is GPIO pin configured to DRDY(data ready) then GPIO pin interrupts will be disabled. The I2C handle is not affected.

Precondition
ADS7142_open() had to be called first.
Parameters
handleA ADS7142_Handle returned from ADS7142_open()
Returns
true on success or false upon failure.

§ ADS7142_calibrate()

bool ADS7142_calibrate ( ADS7142_Handle  handle)

Function to calibrate a ADS7142 sensor monitor specified by the ADS7142 handle.

Any running sequence is aborted and BUSY/RDY pin is brought down to low. The offset is calibrated as well. Calibrate function should be called before changing modes or on startup.

Precondition
ADS7142_open() had to be called first.
Parameters
handleA ADS7142_Handle returned from ADS7142_open()
Returns
true on success or false upon failure.

References ADS7142_abortSequence(), ADS7142_clearAlertFlags(), ADS7142_REG_OFFSET_CAL, ADS7142_VAL_TRIG_OFFCAL, and ADS7142_writeRegisterSingle().

§ ADS7142_selectAutonomousSubMode()

bool ADS7142_selectAutonomousSubMode ( ADS7142_Handle  handle,
ADS7142_autonomousSubModes  mode 
)

Function to select submode of Autonomous mode of a ADS7142 sensor.

The user can select between one of the modes from

  • Pre-Alert Mode
  • Post-Alert Mode
  • Start Burst Mode
  • Stop Burst Mode
Precondition
ADS7142_open() had to be called first.
Parameters
handleA ADS7142_Handle returned from ADS7142_open()
modeA mode selected from the enumeration ADS7142_autonomousSubModes
Returns
true on success or false upon failure.

References ADS7142_readRegisterSingle(), ADS7142_REG_DATA_BUFFER_OPMODE, ADS7142_writeRegisterSingle(), ADS7142_HWAttrs::dataReadyGPIOIndex, ADS7142_Config::hwAttrs, ADS7142_Config::object, and ADS7142_Object::subMode.

§ ADS7142_setThresholds()

bool ADS7142_setThresholds ( ADS7142_Handle  handle,
ADS7142_thresholds thresholdValues 
)

Function to set thresholds while running Alert Diagnostics in a ADS7142 sensor.

The user should call this function to set the thresholds before starting sequence in Alert Diagnostics mode. The user needs to set the high and low thresholds for CH0 and CH1. The thresholds are in order of

  • lowThresholdCH0
  • lowThresholdCH1
  • highThresholdCH0
  • highThresholdCH1
Precondition
ADS7142_open() had to be called first.
Parameters
handleA ADS7142_Handle returned from ADS7142_open()
thresholdValuesA structure that contains threshold values in above order
Returns
true on success or false upon failure.

References ADS7142_channelSelect_CH0, ADS7142_channelSelect_CH0_CH1, ADS7142_channelSelect_CH1, ADS7142_REG_DWC_HTH_CH0_LSB, ADS7142_REG_DWC_HTH_CH0_MSB, ADS7142_REG_DWC_HTH_CH1_LSB, ADS7142_REG_DWC_HTH_CH1_MSB, ADS7142_REG_DWC_HYS_CH0, ADS7142_REG_DWC_HYS_CH1, ADS7142_REG_DWC_LTH_CH0_LSB, ADS7142_REG_DWC_LTH_CH0_MSB, ADS7142_REG_DWC_LTH_CH1_LSB, ADS7142_REG_DWC_LTH_CH1_MSB, ADS7142_writeRegisterSingle(), ADS7142_Object::channel, ADS7142_HWAttrs::dataReadyGPIOIndex, ADS7142_thresholds::highThresholdCH0, ADS7142_thresholds::highThresholdCH1, ADS7142_Config::hwAttrs, ADS7142_thresholds::lowThresholdCH0, ADS7142_thresholds::lowThresholdCH1, and ADS7142_Config::object.

§ ADS7142_getAlertFlagStatus()

void ADS7142_getAlertFlagStatus ( ADS7142_Handle  handle,
uint8_t *  lowFlagStatus,
uint8_t *  highFlagStatus 
)

Function to get the status of ALert flags of ADS7142.

The user can call this function to get the status of low and high alert flags. The alert flags convey the channels on which the thresholds have been crossed. lowFlagStatus conveys that the low thresholds have been passed while the highFlagStatus conveys that the high thresholds have been passed. The following numbers represent the channels in which the thresholds have passed

  • 1(01b) == Channel 0
  • 2(10b) == Channel 1
  • 3(11b) == Channel 0 and Channel 1
Precondition
ADS7142_open() had to be called first.
Parameters
handleA ADS7142_Handle returned from ADS7142_open()
lowFlagStatusVariable to store the status of low alert flag
highFlagStatusVariable to store the status of high alert flag
Returns
true on success or false upon failure.

References ADS7142_readRegisterSingle(), ADS7142_REG_ALERT_HIGH_FLAGS, ADS7142_REG_ALERT_LOW_FLAGS, ADS7142_HWAttrs::dataReadyGPIOIndex, and ADS7142_Config::hwAttrs.

§ ADS7142_clearAlertFlags()

bool ADS7142_clearAlertFlags ( ADS7142_Handle  handle)

Function to clear the alert flags of ADS7142.

The user can call this function to clear the alert flags when using Alert Diagnostics mode. Alert flags are set when the thresholds are crossed at the enabled channels. It is the responsibility of user to clear these flags.

Precondition
ADS7142_open() had to be called first.
Parameters
handleA ADS7142_Handle returned from ADS7142_open()
Returns
true on success or false on failure.

References ADS7142_REG_ALERT_HIGH_FLAGS, ADS7142_REG_ALERT_LOW_FLAGS, ADS7142_writeRegisterSingle(), ADS7142_HWAttrs::dataReadyGPIOIndex, and ADS7142_Config::hwAttrs.

Referenced by ADS7142_calibrate().

§ ADS7142_getopMode()

ADS7142_opMode ADS7142_getopMode ( ADS7142_Handle  )

Function to get the opMode of ADS7142.

The user can call this function to get the current opmode of ADS7142.

Precondition
ADS7142_open() had to be called first.
Parameters
handleA ADS7142_Handle returned from ADS7142_open()
Returns
ADS7142_opMode.

References ADS7142_Config::object, and ADS7142_Object::opMode.

§ ADS7142_getsubMode()

ADS7142_autonomousSubModes ADS7142_getsubMode ( ADS7142_Handle  )

Function to get the Autonomous-subMode of ADS7142.

The user can call this function to get the current Autonomous submode of ADS7142.

Precondition
ADS7142_open() had to be called first.
Parameters
handleA ADS7142_Handle returned from ADS7142_open()
Returns
ADS7142_autonomousSubModes.

References ADS7142_Config::object, and ADS7142_Object::subMode.

§ ADS7142_selectChannelConfig()

bool ADS7142_selectChannelConfig ( ADS7142_Handle  handle,
ADS7142_channelConfig  channelConfig 
)

function to select Channel configuration

Function used to select one of the three Channel Configuration

Parameters
handleA ADS7142_Handle
channelConfigA ADS7142_channelConfig enumeration to select between channel configuration options.
Returns
true on success or false upon failure.

References ADS7142_readRegisterSingle(), ADS7142_REG_CHANNEL_INPUT_CFG, ADS7142_writeRegisterSingle(), ADS7142_Object::configMode, ADS7142_HWAttrs::dataReadyGPIOIndex, ADS7142_Config::hwAttrs, and ADS7142_Config::object.

§ ADS7142_selectOpMode()

bool ADS7142_selectOpMode ( ADS7142_Handle  handle,
ADS7142_opMode  mode,
ADS7142_channelSelect  channel,
ADS7142_oscSelect  osc 
)

function to select opeMode of ADS7142.

Function used to select one of the three opModes of ADS7142. The user can select from these modes.

  • Manual Mode
  • Autonomous Mode
  • High Precision Mode
Parameters
handleA ADS7142_Handle
modeA ADS7142_opMode enumeration to select opModes.

#param channel A ADS7142_channelSelect to select channels for autosequencing.

Parameters
modeA ADS7142_oscSelect enumeration to select oscillator.
Returns
true on success or false upon failure.

References ADS7142_channelConfig_SCPD, ADS7142_channelConfig_SCSE, ADS7142_channelSelect_CH1, ADS7142_opMode_autonomous, ADS7142_opMode_highPrecision, ADS7142_opMode_manual, ADS7142_OPMODE_SEL, ADS7142_readRegisterSingle(), ADS7142_REG_ACC_EN, ADS7142_REG_AUTO_SEQ_CHEN, ADS7142_REG_DOUT_FORMAT_CFG, ADS7142_REG_nCLK_SEL, ADS7142_REG_OSC_SEL, ADS7142_VAL_ACC_EN, ADS7142_VAL_DOUT_FORMAT_CFG_DOUT_FORMAT0, ADS7142_VAL_OPMODE_SEL_AUTONOMOUS_MODE, ADS7142_VAL_OPMODE_SEL_HIGH_PRECISION_MODE, ADS7142_VAL_OPMODE_SEL_MAN_MODE_AUTO_SEQ_EN, ADS7142_writeRegisterSingle(), ADS7142_Object::channel, ADS7142_Object::configMode, ADS7142_HWAttrs::dataReadyGPIOIndex, ADS7142_Config::hwAttrs, ADS7142_Config::object, and ADS7142_Object::opMode.

§ ADS7142_readDataInManualMode()

bool ADS7142_readDataInManualMode ( ADS7142_Handle  handle,
uint16_t  numConversion,
uint8_t *  data 
)

function to read data in manual mode operation.

Function used to read data in the manual mode operation for ADS7142 driver. When two channels are enabled, the data alternates between Channel 0 Channel 1.

Parameters
handleA ADS7142_Handle
numConversionA variable to determine the number of conversions. The numConversion variable is two times the number of conversions required by user.
dataA pointer to variable that stores the result of conversions.
Returns
true on success or false upon failure.

References ADS7142_abortSequence(), ADS7142_Config::hwAttrs, and ADS7142_Config::object.

§ ADS7142_abortSequence()

bool ADS7142_abortSequence ( ADS7142_Handle  handle)

function to abort sequence of operation.

Function used to abort sequence of operation. It brings the Busy/RDY pin of ADS7142 driver low.

Parameters
handleA ADS7142_Handle
Returns
true on success or false upon failure.

References ADS7142_readRegisterSingle(), ADS7142_REG_ABORT_SEQUENCE, ADS7142_VAL_ABORT_SEQUENCE, and ADS7142_writeRegisterSingle().

Referenced by ADS7142_calibrate(), and ADS7142_readDataInManualMode().

§ ADS7142_startSequence()

bool ADS7142_startSequence ( ADS7142_Handle  handle)

function to start sequence of operation.

Function used to start sequence of operation. It brings the Busy/RDY pin of ADS7142 driver high.

Parameters
handleA ADS7142_Handle
Returns
true on success or false upon failure.

References ADS7142_opMode_manual, ADS7142_readRegisterSingle(), ADS7142_REG_START_SEQUENCE, ADS7142_VAL_START_SEQUENCE, ADS7142_writeRegisterSingle(), ADS7142_Object::dataReadyCallbackFxn, ADS7142_HWAttrs::dataReadyGPIOIndex, ADS7142_Config::hwAttrs, ADS7142_Config::object, and ADS7142_Object::opMode.

§ ADS7142_readAccumulator()

bool ADS7142_readAccumulator ( ADS7142_Handle  handle,
uint16_t *  accCH0,
uint16_t *  accCH1 
)

function to read the ADS7142 accumulator data.

Function used to read the data of accumulator when the mode of operation of ADS7142 driver is High Precision Mode.

Parameters
handleA ADS7142_Handle
accCH0A variable to store the 16 bit accumulation of CH0.
accCH1A variable to store the 16 bit accumulation of CH1.
Returns
true on success or false upon failure.

References ADS7142_channelSelect_CH0, ADS7142_channelSelect_CH1, ADS7142_readRegisterSingle(), ADS7142_REG_ACC_CH0_LSB, ADS7142_REG_ACC_CH0_MSB, ADS7142_REG_ACC_CH1_LSB, ADS7142_REG_ACC_CH1_MSB, ADS7142_Object::channel, ADS7142_HWAttrs::dataReadyGPIOIndex, ADS7142_Config::hwAttrs, and ADS7142_Config::object.

§ ADS7142_disableDWCAlert()

bool ADS7142_disableDWCAlert ( ADS7142_Handle  handle)

function to disable DWC in ADS7142

Function used to disable the digital window comparator of ADS7142.

Parameters
handleA ADS7142_Handle
Returns
true on success or false upon failure.

References ADS7142_readRegisterSingle(), ADS7142_REG_ALERT_DWC_EN, ADS7142_writeRegisterSingle(), ADS7142_HWAttrs::alertGPIOIndex, ADS7142_HWAttrs::dataReadyGPIOIndex, and ADS7142_Config::hwAttrs.

§ ADS7142_enableDWCAlert()

bool ADS7142_enableDWCAlert ( ADS7142_Handle  handle)

function to enable DWC in ADS7142

Function used to enable the digital window comparator of ADS7142.

Parameters
handleA ADS7142_Handle
Returns
true on success or false upon failure.

References ADS7142_readRegisterSingle(), ADS7142_REG_ALERT_CHEN, ADS7142_REG_ALERT_DWC_EN, ADS7142_writeRegisterSingle(), ADS7142_Object::alertCallbackFxn, ADS7142_HWAttrs::alertGPIOIndex, ADS7142_Object::channel, ADS7142_HWAttrs::dataReadyGPIOIndex, ADS7142_Config::hwAttrs, and ADS7142_Config::object.

§ ADS7142_readDataBuffer()

bool ADS7142_readDataBuffer ( ADS7142_Handle  handle,
uint16_t *  data 
)

function to read the data buffer.

Function used to read the data buffer when mode of operation of ADS7142 driver is Autonomous Mode.

Parameters
handleA ADS7142_Handle
dataA pointer to variable to store the results of conversion from data buffer
Returns
true on success or false upon failure.

References ADS7142_Config::hwAttrs, and ADS7142_Config::object.

§ ADS7142_writeRegisterSingle()

bool ADS7142_writeRegisterSingle ( ADS7142_Handle  handle,
uint8_t  data,
uint8_t  registerAddress 
)

Write function for advanced users. This is not thread safe.

When writing to a handle, it is possible to overwrite data written by another thread.

For example: Thread A and B are writing to the configuration register. Thread A has a higher priority than THread B. Thread B is running and reads the configuration register. Thread A then preempts Thread B and reads the configuration register, performs a logical OR and writes to the configuration register. Thread B then resumes execution and performs its logical OR and writes to the configuration register–overwriting the data written by Thread A.

Such instances can be prevented through the use of Semaphores. Below is an example which utilizes an initialized Semaphore_handle, ADS7142Lock.

if (0 == sem_wait(&ADS7142Lock))
{
//Perform read/write operations
sem_post(ADS7142Lock);
}
else
{
//handle error scenario
}
Parameters
handleA ADS7142_Handle
dataA uint16_t containing the 1 byte to be written to the ADS7142 sensor.
registerAddressRegister address.
Returns
true on success or false upon failure.

References ADS7142_Config::hwAttrs, ADS7142_Config::object, and SINGLE_REG_WRITE.

Referenced by ADS7142_abortSequence(), ADS7142_calibrate(), ADS7142_clearAlertFlags(), ADS7142_disableDWCAlert(), ADS7142_enableDWCAlert(), ADS7142_selectAutonomousSubMode(), ADS7142_selectChannelConfig(), ADS7142_selectOpMode(), ADS7142_setThresholds(), and ADS7142_startSequence().

§ ADS7142_readRegisterSingle()

bool ADS7142_readRegisterSingle ( ADS7142_Handle  handle,
uint8_t *  data,
uint8_t  registerAddress 
)

Read function for advanced users.

Parameters
handleA ADS7142_Handle
registerAddressRegister address
dataA pointer to a data variable in which received data will be written to. Must be 8 bits.
Returns
true on success or false upon failure.

References ADS7142_Config::hwAttrs, ADS7142_Config::object, and SINGLE_REG_READ.

Referenced by ADS7142_abortSequence(), ADS7142_disableDWCAlert(), ADS7142_enableDWCAlert(), ADS7142_getAlertFlagStatus(), ADS7142_readAccumulator(), ADS7142_selectAutonomousSubMode(), ADS7142_selectChannelConfig(), ADS7142_selectOpMode(), and ADS7142_startSequence().

© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale