A collection of Analog Devices drivers for the mbed platform
AD7124 Class Reference
Analog Devices AD7790 SPI 16-bit Buffered Sigma-Delta ADC. More...
#include <AD7124.h>
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 | |
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 63 of file AD7124.h.
Constructor & Destructor Documentation
AD7124 | ( | PinName | CS = SPI_CS , |
PinName | MOSI = SPI_MOSI , |
||
PinName | MISO = SPI_MISO , |
||
PinName | SCK = SPI_SCK |
||
) |
SPI configuration & constructor.
AD7790 constructor, sets CS pin and SPI format.
- Parameters:
-
CS - (optional)chip select of the AD7790 MOSI - (optional)pin of the SPI interface MISO - (optional)pin of the SPI interface SCK - (optional)pin of the SPI interface
Definition at line 59 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 488 of file AD7124.cpp.
void frequency | ( | int | hz ) |
Set AD7790 SPI frequency.
- Parameters:
-
hz - SPI bus frequency in hz
- Returns:
- none
Definition at line 76 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 160 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 216 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 107 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 428 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 312 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 262 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 341 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 539 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 516 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 392 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 361 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 122 of file AD7124.cpp.
uint16_t write_spi | ( | uint16_t | reg_val ) |
Writes 16bit data to the AD7790 SPI interface.
- Parameters:
-
reg_val to be written
- Returns:
- data returned by the AD7790
Definition at line 134 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 328 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 286 of file AD7124.cpp.
Field Documentation
DigitalOut cs |
Generated on Tue Jul 12 2022 17:59:52 by 1.7.2