Analog Devices AD7124-8 - 8-Channel, Low Noise, Low Power, 24-Bit, Sigma-Delta ADC with PGA and Reference

Dependents:   CN0398 CN0391 CN0398_arduino

Embed: (wiki syntax)

« Back to documentation index

AD7124 Class Reference

Analog Devices AD7790 SPI 16-bit Buffered Sigma-Delta ADC. More...

#include <AD7124.h>

Data Structures

struct  _ad7124_st_reg

Public Types

typedef struct
AD7124::_ad7124_st_reg 
ad7124_st_reg

Public Member Functions

 AD7124 (PinName CS=SPI_CS, PinName MOSI=SPI_MOSI, PinName MISO=SPI_MISO, PinName SCK=SPI_SCK)
 SPI configuration & constructor.
void frequency (int hz)
 Set AD7790 SPI frequency.
void reset (void)
 Low level SPI bus comm methods.
void write_reg (uint8_t regAddress, uint8_t regValue)
 Writes a register of the AD7790.
uint16_t write_spi (uint16_t data)
 Writes 16bit data to the AD7790 SPI interface.
uint16_t read_reg (uint8_t regAddress)
 Resets the AD7790.
int32_t Reset ()
 Resets the device.
uint32_t ReadDeviceRegister (enum ad7124_registers reg)
 Reads and returns the value of a device register.
int32_t WriteDeviceRegister (enum ad7124_registers reg, uint32_t value)
 Writes the specified value to a device register.
int32_t ReadRegister (ad7124_st_reg *pReg)
 Reads the value of the specified register only when the device is ready to accept user requests.
int32_t WriteRegister (ad7124_st_reg reg)
 Writes the value of the specified register only when the device is ready to accept user requests.
int32_t NoCheckReadRegister (ad7124_st_reg *pReg)
 Reads the value of the specified register without checking if the device is ready to accept user requests.
int32_t NoCheckWriteRegister (ad7124_st_reg reg)
 Writes the value of the specified register without checking if the device is ready to accept user requests.
int32_t WaitForSpiReady (uint32_t timeout)
int32_t WaitForConvReady (uint32_t timeout)
int32_t ReadData (int32_t *pData)
uint8_t ComputeCRC8 (uint8_t *pBuf, uint8_t bufSize)
void UpdateDevSpiSettings ()
int32_t Setup ()

Data Fields

ad7124_st_reg ad7124_regs [57]
DigitalIn miso
 DigitalIn must be initialized before SPI to prevent pin MUX overwrite.
SPI ad7124
 SPI instance of the AD7790.
DigitalOut cs
 DigitalOut instance for the chipselect of the AD7790.

Detailed Description

Analog Devices AD7790 SPI 16-bit Buffered Sigma-Delta ADC.

Definition at line 65 of file AD7124.h.


Member Typedef Documentation

Device register info


Constructor & Destructor Documentation

AD7124 ( PinName  CS = SPI_CS,
PinName  MOSI = SPI_MOSI,
PinName  MISO = SPI_MISO,
PinName  SCK = SPI_SCK 
)

SPI configuration & constructor.

Definition at line 121 of file AD7124.cpp.


Member Function Documentation

uint8_t ComputeCRC8 ( uint8_t *  pBuf,
uint8_t  bufSize 
)

Computes the CRC checksum for a data buffer.

Parameters:
pBuf- Data buffer
bufSize- Data buffer size in bytes
Returns:
Returns the computed CRC checksum.

Definition at line 553 of file AD7124.cpp.

void frequency ( int  hz )

Set AD7790 SPI frequency.

Parameters:
hz- SPI bus frequency in hz
Returns:
none

Definition at line 141 of file AD7124.cpp.

int32_t NoCheckReadRegister ( ad7124_st_reg pReg )

Reads the value of the specified register without checking if the device is ready to accept user requests.

Reads the value of the specified register without a device state check.

Parameters:
device- The handler of the instance of the driver.
pReg- Pointer to the register structure holding info about the register to be read. The read value is stored inside the register structure.
Returns:
Returns 0 for success or negative error code.

Definition at line 225 of file AD7124.cpp.

int32_t NoCheckWriteRegister ( ad7124_st_reg  reg )

Writes the value of the specified register without checking if the device is ready to accept user requests.

Writes the value of the specified register without a device state check.

Parameters:
device- The handler of the instance of the driver.
reg- Register structure holding info about the register to be written
Returns:
Returns 0 for success or negative error code.

Definition at line 281 of file AD7124.cpp.

uint16_t read_reg ( uint8_t  address )

Resets the AD7790.

Returns:
none Reads a register of the AD7790
Parameters:
address- address of the register
Returns:
value of the register

Definition at line 172 of file AD7124.cpp.

int32_t ReadData ( int32_t *  pData )

Reads the conversion result from the device.

Parameters:
device- The handler of the instance of the driver.
pData- Pointer to store the read data.
Returns:
Returns 0 for success or negative error code.

Definition at line 493 of file AD7124.cpp.

uint32_t ReadDeviceRegister ( enum ad7124_registers  reg )

Reads and returns the value of a device register.

The read value is also stored in software register list of the device.

Parameters:
device- The handler of the instance of the driver.
reg- Which register to read from.
pError- Pointer to the location where to store the error code if an error occurs. Stores 0 for success or negative error code. Does not store anything if pErorr = NULL;
Returns:
Returns the value read from the specified register.

Definition at line 377 of file AD7124.cpp.

int32_t ReadRegister ( ad7124_st_reg pReg )

Reads the value of the specified register only when the device is ready to accept user requests.

Reads the value of the specified register.

If the device ready flag is deactivated the read operation will be executed without checking the device state.

Parameters:
device- The handler of the instance of the driver.
pReg- Pointer to the register structure holding info about the register to be read. The read value is stored inside the register structure.
Returns:
Returns 0 for success or negative error code.

Definition at line 327 of file AD7124.cpp.

void reset ( void   )

Low level SPI bus comm methods.

int32_t Reset (  )

Resets the device.

Parameters:
device- The handler of the instance of the driver.
Returns:
Returns 0 for success or negative error code.

Definition at line 406 of file AD7124.cpp.

int32_t Setup (  )

Initializes the AD7124.

Parameters:
device- The handler of the instance of the driver.
slave_select- The Slave Chip Select Id to be passed to the SPI calls.
regs- The list of registers of the device (initialized or not) to be added to the instance of the driver.
Returns:
Returns 0 for success or negative error code.

Definition at line 604 of file AD7124.cpp.

void UpdateDevSpiSettings (  )

Updates the device SPI interface settings.

Parameters:
device- The handler of the instance of the driver.
Returns:
None.

Definition at line 581 of file AD7124.cpp.

int32_t WaitForConvReady ( uint32_t  timeout )

Waits until a new conversion result is available.

Parameters:
device- The handler of the instance of the driver.
timeout- Count representing the number of polls to be done until the function returns if no new data is available.
Returns:
Returns 0 for success or negative error code.

Definition at line 457 of file AD7124.cpp.

int32_t WaitForSpiReady ( uint32_t  timeout )

Waits until the device can accept read and write user actions.

Parameters:
device- The handler of the instance of the driver.
timeout- Count representing the number of polls to be done until the function returns.
Returns:
Returns 0 for success or negative error code.

Definition at line 426 of file AD7124.cpp.

void write_reg ( uint8_t  address,
uint8_t  reg_val 
)

Writes a register of the AD7790.

Parameters:
address- address of the register
reg_val- value to be written
Returns:
none

Definition at line 187 of file AD7124.cpp.

uint16_t write_spi ( uint16_t  reg_val )

Writes 16bit data to the AD7790 SPI interface.

Parameters:
reg_valto be written
Returns:
data returned by the AD7790

Definition at line 199 of file AD7124.cpp.

int32_t WriteDeviceRegister ( enum ad7124_registers  reg,
uint32_t  value 
)

Writes the specified value to a device register.

The value to be written is also stored in the software register list of the device.

Parameters:
device- The handler of the instance of the driver.
reg- Which register to write to.
value- The value to be written to the reigster of the device.
Returns:
Returns 0 for success or negative error code.

Definition at line 393 of file AD7124.cpp.

int32_t WriteRegister ( ad7124_st_reg  pReg )

Writes the value of the specified register only when the device is ready to accept user requests.

Writes the value of the specified register.

If the device ready flag is deactivated the write operation will be executed without checking the device state.

Parameters:
device- The handler of the instance of the driver.
reg- Register structure holding info about the register to be written
Returns:
Returns 0 for success or negative error code.

Definition at line 351 of file AD7124.cpp.


Field Documentation

SPI ad7124

SPI instance of the AD7790.

Definition at line 409 of file AD7124.h.

Array holding the info for the ad7124 registers - address, initial value, size and access type.

Definition at line 140 of file AD7124.h.

DigitalOut cs

DigitalOut instance for the chipselect of the AD7790.

Definition at line 410 of file AD7124.h.

DigitalIn miso

DigitalIn must be initialized before SPI to prevent pin MUX overwrite.

Definition at line 408 of file AD7124.h.