![]() |
![]() |
|
SAIL API Guide
|
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:
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.
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"
"MSP_EXP432P401R.c"
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.
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... | |
Typedefs | |
| typedef struct ADS7142_Config * | ADS7142_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... | |
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 struct ADS7142_Config* ADS7142_Handle |
A handle that is returned from a ADS7142_open() call.
| typedef enum ADS7142_channelConfig 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:
| typedef enum ADS7142_slaveAddress ADS7142_slaveAddress |
ADS7142 I2C slave addresses.
| typedef enum ADS7142_opMode ADS7142_opMode |
ADS7142 operation mode selection.
This enumeration defines the operation modes available for ADS7142. configurations are:
| typedef enum ADS7142_channelSelect ADS7142_channelSelect |
ADS7142 autosequencing channel selection.
This enumeration defines the channel options available for autosequencing operation. configurations are:
| typedef enum ADS7142_oscSelect ADS7142_oscSelect |
ADS7142 oscillator selection.
This enumeration defines the options available for selection of internal oscillator during sequencing. configurations are:
| typedef enum ADS7142_autonomousSubModes ADS7142_autonomousSubModes |
ADS7142 Autonomous-submodes selection.
This enumeration defines the options of autonomous mode operations supported by ADS7142 sensor monitor. The supported modes are:
| typedef struct ADS7142_Config 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.
| typedef struct ADS7142_HWAttrs 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.
| typedef struct ADS7142_Object ADS7142_Object |
Members should not be accessed by the application.
| typedef struct ADS7142_thresholds ADS7142_thresholds |
ADS7142 channel thresholds.
ADS7142 channel thresholds are used to give the value of thresholds while using Alert Diagnostic modes
| typedef struct ADS7142_Params 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.
ADS7142 channel configuration.
This enumeration defines the number of channel configurations available for manual mode operations of ADS7142 sensor monitor.The supported configurations are:
| Enumerator | |
|---|---|
| ADS7142_channelConfig_DCSE | Double channel, single ended. |
| ADS7142_channelConfig_SCSE | Single Channel, single ended |
| ADS7142_channelConfig_SCPD | Single Channel, pseudo differential. |
| enum ADS7142_slaveAddress |
| enum ADS7142_opMode |
ADS7142 operation mode selection.
This enumeration defines the operation modes available for ADS7142. configurations are:
| Enumerator | |
|---|---|
| ADS7142_opMode_manual | Manual Mode. |
| ADS7142_opMode_autonomous | Autonomous Mode. |
| ADS7142_opMode_highPrecision | High-Precision Mode. |
ADS7142 autosequencing channel selection.
This enumeration defines the channel options available for autosequencing operation. configurations are:
| Enumerator | |
|---|---|
| ADS7142_channelSelect_CH0 | CH0 Only. |
| ADS7142_channelSelect_CH1 | CH1 Only |
| ADS7142_channelSelect_CH0_CH1 | CH0 and CH1 both. |
| enum ADS7142_oscSelect |
ADS7142 Autonomous-submodes selection.
This enumeration defines the options of autonomous mode operations supported by ADS7142 sensor monitor. The supported modes are:
| void ADS7142_init | ( | ) |
Function to initialize ADS7142 driver.
This function will initialize the ADS7142 driver.
| void ADS7142_initParams | ( | ADS7142_Params * | params | ) |
Function to initialize a ADS7142_Params struct to its defaults.
| params | A pointer to ADS7142_Params structure for initialization. |
Default values are: dataReadyCallbackFxn = NULL alertCallbackFxn = NULL
References ADS7142_defaultParams.
| 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.
| ADS7142Index | Logical sensor number for the ADS7142 indexed into the ADS7142_config table |
| i2cHandle | An I2C_Handle opened in BLOCKING mode |
References ADS7142_count, ADS7142_Object::alertCallbackFxn, ADS7142_Params::alertCallbackFxn, ADS7142_Object::dataReadyCallbackFxn, ADS7142_Params::dataReadyCallbackFxn, ADS7142_Object::i2cHandle, and ADS7142_Config::object.
| 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.
| handle | A ADS7142_Handle returned from ADS7142_open() |
| 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.
| handle | A ADS7142_Handle returned from ADS7142_open() |
References ADS7142_abortSequence(), ADS7142_clearAlertFlags(), ADS7142_REG_OFFSET_CAL, ADS7142_VAL_TRIG_OFFCAL, and ADS7142_writeRegisterSingle().
| 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
| handle | A ADS7142_Handle returned from ADS7142_open() |
| mode | A mode selected from the enumeration ADS7142_autonomousSubModes |
References ADS7142_readRegisterSingle(), ADS7142_REG_DATA_BUFFER_OPMODE, ADS7142_writeRegisterSingle(), ADS7142_HWAttrs::dataReadyGPIOIndex, ADS7142_Config::hwAttrs, ADS7142_Config::object, and ADS7142_Object::subMode.
| 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
| handle | A ADS7142_Handle returned from ADS7142_open() |
| thresholdValues | A structure that contains threshold values in above order |
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.
| 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
| handle | A ADS7142_Handle returned from ADS7142_open() |
| lowFlagStatus | Variable to store the status of low alert flag |
| highFlagStatus | Variable to store the status of high alert flag |
References ADS7142_readRegisterSingle(), ADS7142_REG_ALERT_HIGH_FLAGS, ADS7142_REG_ALERT_LOW_FLAGS, ADS7142_HWAttrs::dataReadyGPIOIndex, and ADS7142_Config::hwAttrs.
| 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.
| handle | A ADS7142_Handle returned from ADS7142_open() |
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_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.
| handle | A ADS7142_Handle returned from ADS7142_open() |
References ADS7142_Config::object, and ADS7142_Object::opMode.
| 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.
| handle | A ADS7142_Handle returned from ADS7142_open() |
References ADS7142_Config::object, and ADS7142_Object::subMode.
| bool ADS7142_selectChannelConfig | ( | ADS7142_Handle | handle, |
| ADS7142_channelConfig | channelConfig | ||
| ) |
function to select Channel configuration
Function used to select one of the three Channel Configuration
| handle | A ADS7142_Handle |
| channelConfig | A ADS7142_channelConfig enumeration to select between channel configuration options. |
References ADS7142_readRegisterSingle(), ADS7142_REG_CHANNEL_INPUT_CFG, ADS7142_writeRegisterSingle(), ADS7142_Object::configMode, ADS7142_HWAttrs::dataReadyGPIOIndex, ADS7142_Config::hwAttrs, and ADS7142_Config::object.
| 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.
| handle | A ADS7142_Handle |
| mode | A ADS7142_opMode enumeration to select opModes. |
#param channel A ADS7142_channelSelect to select channels for autosequencing.
| mode | A ADS7142_oscSelect enumeration to select oscillator. |
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.
| 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.
| handle | A ADS7142_Handle |
| numConversion | A variable to determine the number of conversions. The numConversion variable is two times the number of conversions required by user. |
| data | A pointer to variable that stores the result of conversions. |
References ADS7142_abortSequence(), ADS7142_Config::hwAttrs, and ADS7142_Config::object.
| 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.
| handle | A ADS7142_Handle |
References ADS7142_readRegisterSingle(), ADS7142_REG_ABORT_SEQUENCE, ADS7142_VAL_ABORT_SEQUENCE, and ADS7142_writeRegisterSingle().
Referenced by ADS7142_calibrate(), and ADS7142_readDataInManualMode().
| 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.
| handle | A ADS7142_Handle |
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.
| 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.
| handle | A ADS7142_Handle |
| accCH0 | A variable to store the 16 bit accumulation of CH0. |
| accCH1 | A variable to store the 16 bit accumulation of CH1. |
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.
| bool ADS7142_disableDWCAlert | ( | ADS7142_Handle | handle | ) |
function to disable DWC in ADS7142
Function used to disable the digital window comparator of ADS7142.
| handle | A ADS7142_Handle |
References ADS7142_readRegisterSingle(), ADS7142_REG_ALERT_DWC_EN, ADS7142_writeRegisterSingle(), ADS7142_HWAttrs::alertGPIOIndex, ADS7142_HWAttrs::dataReadyGPIOIndex, and ADS7142_Config::hwAttrs.
| bool ADS7142_enableDWCAlert | ( | ADS7142_Handle | handle | ) |
function to enable DWC in ADS7142
Function used to enable the digital window comparator of ADS7142.
| handle | A ADS7142_Handle |
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.
| 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.
| handle | A ADS7142_Handle |
| data | A pointer to variable to store the results of conversion from data buffer |
References ADS7142_Config::hwAttrs, and ADS7142_Config::object.
| 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.
| handle | A ADS7142_Handle |
| data | A uint16_t containing the 1 byte to be written to the ADS7142 sensor. |
| registerAddress | Register address. |
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().
| bool ADS7142_readRegisterSingle | ( | ADS7142_Handle | handle, |
| uint8_t * | data, | ||
| uint8_t | registerAddress | ||
| ) |
Read function for advanced users.
| handle | A ADS7142_Handle |
| registerAddress | Register address |
| data | A pointer to a data variable in which received data will be written to. Must be 8 bits. |
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().