Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
AD7790 Class Reference
Analog Devices AD7790 SPI 16-bit Buffered Sigma-Delta ADC. More...
#include <AD7790.h>
Public Types | |
| enum | AD7790Register_t { COMMUNICATION_REG = 0, STATUS_REG = 0, MODE_REG, FILTER_REG, DATA_REG } |
AD7790 registers. More... | |
| enum | AD7790Channel_t { DIFFERENTIAL = 0, RESERVED, SHORT, VDDMONITOR } |
AD7790 channel configuration. More... | |
| enum | ModeRegisterBits_t { MD1 = 0x80, MD0 = 0x40, G1 = 0x20, G0 = 0x10, BO = 0x08, BUF = 0x02 } |
| enum | FilterRegisterBits_t { CLKDIV1 = 0x40, CLKDIV0 = 0x20, FS2 = 0x04, FS1 = 0x02, FS0 = 0x01 } |
Public Member Functions | |
| AD7790 (float reference_voltage, 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 | set_channel (AD7790Channel_t channel) |
| Register access methods. | |
| void | set_conversion_mode (AD7790Mode_t mode) |
| Enables/disables continous_conversion mode In Single Conversion mode, read_u16 method will read the MODE register of the ADC, then write the Start single conversion bit and wait for the DOUT/RDY pin to go low, When the pin is driven low, data register is read back from the ADC. | |
| uint16_t | read_data_reg () |
| Reads the data register and returns its value. | |
| uint8_t | read_status_reg (void) |
| Reads the status register of the ADC and returns its value. | |
| void | write_filter_reg (uint8_t regVal) |
| Writes the filter register. | |
| uint8_t | read_filter_reg (void) |
| Reads the filter register and returns its value. | |
| void | write_mode_reg (uint8_t regVal) |
| Sets the mode register. | |
| uint8_t | read_mode_reg (void) |
| Reads the mode register and returns its value. | |
| void | set_range (AnalogInputRange_t range) |
| Sets the AnalogInputRange to be used by the AD7790. | |
| void | set_reference_voltage (float ref) |
| Reference voltage methods. | |
| float | get_reference_voltage (void) |
| Gets the reference voltage of the AD7790. | |
| float | read_voltage (void) |
| Voltage read methods. | |
| float | data_to_voltage (uint16_t data) |
| Converts an uint16_t to voltage. | |
| uint16_t | voltage_to_data (float voltage) |
| Converts voltage to an uint16_t. | |
| float | read (void) |
| AnalogIn API. | |
| uint16_t | read_u16 (void) |
| |
| operator float () | |
| |
Detailed Description
Analog Devices AD7790 SPI 16-bit Buffered Sigma-Delta ADC.
Definition at line 63 of file AD7790.h.
Member Enumeration Documentation
| enum AD7790Channel_t |
| enum AD7790Register_t |
| enum FilterRegisterBits_t |
| enum ModeRegisterBits_t |
Constructor & Destructor Documentation
| AD7790 | ( | float | reference_voltage, |
| 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 AD7790.cpp.
Member Function Documentation
| float data_to_voltage | ( | uint16_t | data ) |
Converts an uint16_t to voltage.
Gain needs to be correctly set using set_gain in order to get accurate results
- Parameters:
-
data in uint16_t format
- Returns:
- float value of voltage (in V)
Definition at line 344 of file AD7790.cpp.
| void frequency | ( | int | hz ) |
Set AD7790 SPI frequency.
- Parameters:
-
hz - SPI bus frequency in hz
- Returns:
- none
Definition at line 77 of file AD7790.cpp.
| float get_reference_voltage | ( | void | ) |
Gets the reference voltage of the AD7790.
- Returns:
- reference voltage
Definition at line 323 of file AD7790.cpp.
| operator float | ( | ) |
- From mbed AnalogIn API - An operator shorthand for read() The float() operator can be used as a shorthand for read() to simplify common code sequences
Definition at line 391 of file AD7790.cpp.
| float read | ( | void | ) |
AnalogIn API.
- From mbed AnalogIn API - Read the input voltage, represented as a float in the range [0.0, 1.0] - uses the read_u16 method
- Returns:
- A floating-point value representing the current input voltage, measured as a percentage returns 1.0 along with a debug message if the conversion failed
Definition at line 375 of file AD7790.cpp.
| uint16_t read_data_reg | ( | ) |
Reads the data register and returns its value.
- Returns:
- value of the data register
Definition at line 149 of file AD7790.cpp.
| uint8_t read_filter_reg | ( | void | ) |
Reads the filter register and returns its value.
- Returns:
- the value of the filter register
Definition at line 140 of file AD7790.cpp.
| uint8_t read_mode_reg | ( | void | ) |
Reads the mode register and returns its value.
- Returns:
- value of the mode register
Definition at line 122 of file AD7790.cpp.
| uint8_t read_status_reg | ( | void | ) |
Reads the status register of the ADC and returns its value.
- Returns:
- value of the status reg
Definition at line 165 of file AD7790.cpp.
| uint16_t read_u16 | ( | void | ) |
- From mbed AnalogIn API -
Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF] Depending on the conversion mode, this method will have different behavior. Conversion mode is set using set_continous_conversion_mode(bool).
In Single Conversion mode, read_u16 method will read the MODE register of the ADC, then write the Start single conversion bit and wait for the DOUT/RDY pin to go low, When the pin is driven low, data register is read back from the ADC.
In Continous conversion mode, read_u16 method will poll the DOUT/RDY pin, if it is low, the data register is read back from the ADC.
- Returns:
- 16-bit unsigned short representing the current input voltage, normalised to a 16-bit value returns -1 (0xFFFF) along with a debug message if conversion failed.
Definition at line 208 of file AD7790.cpp.
| float read_voltage | ( | void | ) |
Voltage read methods.
Reads the data register of the ADC and converts the result to volts Gain needs to be correctly set using set_gain in order to get accurate results.
- Returns:
- voltage of the ADC input
Definition at line 333 of file AD7790.cpp.
| void reset | ( | void | ) |
Low level SPI bus comm methods.
Resets the AD7790.
- Returns:
- none
Definition at line 86 of file AD7790.cpp.
| void set_channel | ( | AD7790Channel_t | channel ) |
Register access methods.
Sets the conversion channel.
- Parameters:
-
channel
Definition at line 364 of file AD7790.cpp.
| void set_conversion_mode | ( | AD7790Mode_t | mode ) |
Enables/disables continous_conversion mode In Single Conversion mode, read_u16 method will read the MODE register of the ADC, then write the Start single conversion bit and wait for the DOUT/RDY pin to go low, When the pin is driven low, data register is read back from the ADC.
In Continous conversion mode, read_u16 method will poll the DOUT/RDY pin, if it is low, the data register is read back from the ADC.
- Parameters:
-
mode true - continous conversion mode enabled false - single conversion mode enabled
Definition at line 184 of file AD7790.cpp.
| void set_range | ( | AnalogInputRange_t | range ) |
Sets the AnalogInputRange to be used by the AD7790.
- Parameters:
-
range AnalogInputRange_t to be used in voltage computations
Definition at line 301 of file AD7790.cpp.
| void set_reference_voltage | ( | float | ref ) |
Reference voltage methods.
Sets the reference voltage of the AD7790.
- Parameters:
-
ref reference voltage to be set
Definition at line 314 of file AD7790.cpp.
| uint16_t voltage_to_data | ( | float | voltage ) |
Converts voltage to an uint16_t.
Gain needs to be correctly set using set_gain in order to get accurate results
- Parameters:
-
voltage to be converted
- Returns:
- data in uint16_t format
Definition at line 355 of file AD7790.cpp.
| void write_filter_reg | ( | uint8_t | reg_val ) |
Writes the filter register.
- Parameters:
-
regValue value to be written.
Definition at line 131 of file AD7790.cpp.
| void write_mode_reg | ( | uint8_t | reg_val ) |
Sets the mode register.
Also sets continous mode and range based on the value written in reg_val
- Parameters:
-
reg_val
Definition at line 105 of file AD7790.cpp.
Generated on Tue Jul 12 2022 17:59:52 by
1.7.2
CN0357 - Toxic gas measurement
CN0216 - Weight Scale