pflib v2.7.0-1-gd371ab6a
Polarfire Interaction Library
|
Class representing communication with the Digital-Analog Converter on the HGC ROC. More...
#include <Bias.h>
Public Member Functions | |
MAX5825 (I2C &i2c, uint8_t max_addr, int bus=4) | |
Wrap an I2C class for communicating with the MAX5825. More... | |
std::vector< uint8_t > | get (uint8_t cmd, int n_return_bytes=2) |
Get the settings for the DACs on this MAX. More... | |
void | set (uint8_t cmd, uint16_t data_bytes) |
Write a setting for the DACs on this MAX. More... | |
std::vector< uint16_t > | getByDAC (uint8_t i_dac, uint8_t cmd) |
get by DAC index More... | |
void | setByDAC (uint8_t i_dac, uint8_t cmd, uint16_t twelve_bit_setting) |
set by DAC index More... | |
void | setRefVoltage (int level) |
Set reference voltage 0 - external 1 - 2.5V 2 - 2.048V 3 - 4.096V. | |
Private Attributes | |
I2C & | i2c_ |
our connection | |
uint8_t | our_addr_ |
our addr on the chip | |
int | bus_ |
our bus | |
Class representing communication with the Digital-Analog Converter on the HGC ROC.
https://datasheets.maximintegrated.com/en/ds/MAX5823-MAX5825.pdf
CODE - future setting for the DAC output LOAD - load CODE into DAC outputs CODE_LOAD - CODE and then LOAD
The lower-level set and get functions are for chip-wide configuration (e.g. the watch dog WDOG configuration).
Use the {set,get}byDAC functions when setting or getting DAC parameters.
pflib::MAX5825::MAX5825 | ( | I2C & | i2c, |
uint8_t | max_addr, | ||
int | bus = 4 |
||
) |
std::vector< uint8_t > pflib::MAX5825::get | ( | uint8_t | cmd, |
int | n_return_bytes = 2 |
||
) |
Get the settings for the DACs on this MAX.
We return the bytes requested i.e. further parsing will be necessary especially in the per-DAC case where the settings are the twelve MSBs from two concatenated returned bytes.
std::vector< uint16_t > pflib::MAX5825::getByDAC | ( | uint8_t | i_dac, |
uint8_t | cmd | ||
) |
get by DAC index
The per-DAC commands return the 12-bit settings as the 12 MSBs of two adjacent concatenated bits. We do this concatenation in this file as well as determine how many bytes to request depending on if we are requesting a single DAC (i_dac <= 7) or if we are requesting all DACs (i_dac > 7).
The per-DAC commands use the 4 MSBs as a command the 4 LSBs to make the DAC selection. Using the commands defined as static constants in this class, the combination of i_dac and command is simply adding them together, which is done here.
void pflib::MAX5825::set | ( | uint8_t | cmd, |
uint16_t | data_bytes | ||
) |
Write a setting for the DACs on this MAX.
The input two data bytes is a single 16-bit word where the 8 MSBs are the first data byte and the 8 LSBs are the second. Some pre-parsing may be necessary e.g. 12-bit settings for a specific DAC would need to be passed as data_bytes = actual_12_bit_setting << 4; Since the chip expects the 12-bit settings to be the 12 MSBs from these two concatenated data words.
void pflib::MAX5825::setByDAC | ( | uint8_t | i_dac, |
uint8_t | cmd, | ||
uint16_t | twelve_bit_setting | ||
) |
set by DAC index
The per-DAC commands expect the 12-bit settings as the 12 MSBs of the two adjacent concatenated data bytes. We do the shifting inside of this function, so the twelve_bit_setting should be the value you want the DAC to be set at.
The per-DAC commands use the 4 MSBs as a command the 4 LSBs to make the DAC selection. Using the commands defined as static constants in this class, the combination of i_dac and command is simply adding them together, which is done here.