Go to the documentation of this file.
51 #define AD5754R_MAX_RESOLUTION 16
54 #define AD5754R_NUM_CHANNELS 4
57 #define AD5754R_REG_DAC 0
58 #define AD5754R_REG_OUTPUT_RANGE_SEL 1
59 #define AD5754R_REG_PWR_CTRL 2
60 #define AD5754R_REG_CONTROL 3
63 #define AD5754R_DAC_CH_A_ADDR 0
64 #define AD5754R_DAC_CH_B_ADDR 1
65 #define AD5754R_DAC_CH_C_ADDR 2
66 #define AD5754R_DAC_CH_D_ADDR 3
67 #define AD5754R_DAC_CH_ALL_ADDR 4
70 #define AD5754R_ADDR_REG_MASK NO_OS_GENMASK(5, 3)
71 #define AD5754R_ADDR_REG(x) no_os_field_prep(AD5754R_ADDR_REG_MASK, x)
72 #define AD5754R_ADDR_DAC_CH_MASK NO_OS_GENMASK(2, 0)
73 #define AD5754R_ADDR_DAC_CH(x) no_os_field_prep(AD5754R_ADDR_DAC_CH_MASK, x)
74 #define AD5754R_PREP_INSTR_ADDR(reg, dac_ch) (AD5754R_ADDR_REG(reg) | \
75 AD5754R_ADDR_DAC_CH(dac_ch))
78 #define AD5754R_OUTPUT_RANGE_SEL_MASK NO_OS_GENMASK(2,0)
81 #define AD5754R_CTRL_NOP 0
82 #define AD5754R_CTRL_TSD_EN(x) no_os_field_prep(NO_OS_BIT(3), x)
83 #define AD5754R_CTRL_TSD_EN_MASK NO_OS_BIT(3)
84 #define AD5754R_CTRL_CLAMP_EN(X) no_os_field_prep(NO_OS_BIT(2), x)
85 #define AD5754R_CTRL_CLAMP_EN_MASK NO_OS_BIT(2)
86 #define AD5754R_CTRL_CLR_SEL(x) no_os_field_prep(NO_OS_BIT(1), x)
87 #define AD5754R_CTRL_CLR_SEL_MASK NO_OS_BIT(1)
88 #define AD5754R_CTRL_SDO_DISABLE(x) (x)
89 #define AD5754R_CTRL_SDO_DISABLE_MASK NO_OS_BIT(0)
90 #define AD5754R_CTRL_CLEAR 0
91 #define AD5754R_CTRL_LOAD 0
94 #define AD5754R_PWR_UP_DAC_CH_MASK(x) NO_OS_BIT(x)
95 #define AD5754R_PWR_UP_INT_REF_MASK NO_OS_BIT(4)
96 #define AD5754R_PWR_OC_ALERT_MASK NO_OS_GENMASK(10,7)
97 #define AD5754R_PWR_OC_ALERT_CH_MASK(x) no_os_field_prep(AD5754R_PWR_OC_ALERT_MASK, \
99 #define AD5754R_PWR_TSD_ALERT_MASK NO_OS_BIT(5)
101 #define AD5754R_BYTE_H NO_OS_GENMASK(15, 8)
102 #define AD5754R_BYTE_L NO_OS_GENMASK(7, 0)
104 #define AD5754R_READ NO_OS_BIT(7)
105 #define AD5754R_WRITE 0
107 #define AD5754R_INSTR_NOP 0x18
108 #define AD5754R_INSTR_CLEAR 0x1C
109 #define AD5754R_INSTR_LOAD 0x1D
111 #define AD5754R_GAIN_SCALE 1000
346 uint16_t mvolts, uint16_t *code);
#define AD5754R_CTRL_CLR_SEL_MASK
Definition: ad5754r.h:87
int ad5754r_set_ch_range(struct ad5754r_dev *dev, uint8_t chn, enum ad5754r_dac_ch_range ch_range)
Set output range for specific channel.
Definition: ad5754r.c:369
int ad5754r_set_current_clamp_en(struct ad5754r_dev *dev, enum ad5754r_ctrl_current_clamp_en clamp_en)
Apply current clamp setting for device.
Definition: ad5754r.c:425
@ AD5754R_PWR_OC_CH_NOT_DETECTED
Definition: ad5754r.h:220
int ad5754r_set_clear_mode(struct ad5754r_dev *dev, enum ad5754r_ctrl_clear_sel clear_sel)
Set clear mode setting for device.
Definition: ad5754r.c:479
ad5754r_ctrl_tsd_en
TSD EN/DIS Modes.
Definition: ad5754r.h:165
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
int ad5754r_reg_init(struct ad5754r_dev *dev, struct ad5754r_init_param *init_param)
Initialize registers based on init parameters.
Definition: ad5754r.c:698
int ad5754r_remove(struct ad5754r_dev *dev)
Remove the device and release resources.
Definition: ad5754r.c:837
ad5754r_ctrl_sdo_dis
SDO EN/DIS Modes.
Definition: ad5754r.h:183
enum ad5754r_dac_ch_range dac_ch_range[AD5754R_NUM_CHANNELS]
Definition: ad5754r.h:245
#define AD5754R_READ
Definition: ad5754r.h:104
int ad5754r_read_dac_ch_register(struct ad5754r_dev *dev, uint8_t chn, uint16_t *value)
Read DAC register value for specific channel.
Definition: ad5754r.c:272
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:159
#define AD5754R_BYTE_L
Definition: ad5754r.h:102
@ AD5754R_DAC_CH_A
Definition: ad5754r.h:122
int ad5754r_set_int_ref_pwrup(struct ad5754r_dev *dev, enum ad5754r_pwr_int_ref_pwrup int_ref_pwrup)
Set Internal Reference Enable/Disable state for device.
Definition: ad5754r.c:533
enum ad5754r_ctrl_clear_sel clear_sel
Definition: ad5754r.h:282
int ad5754r_read_dac_ch_register(struct ad5754r_dev *dev, uint8_t chn, uint16_t *value)
Read DAC register value for specific channel.
Definition: ad5754r.c:272
Header file of SPI Interface.
int ad5754r_update_dac_ch_register(struct ad5754r_dev *dev, uint8_t chn, uint16_t value)
Update DAC register value for specific channel.
Definition: ad5754r.c:165
enum ad5754r_pwr_int_ref_pwrup int_ref_pwrup
Definition: ad5754r.h:288
Header file of AD5754R Driver.
enum ad5754r_ctrl_current_clamp_en clamp_en
Definition: ad5754r.h:278
ad5754r_pwr_oc_ch_alert
DAC Channel Overcurrent Alert State.
Definition: ad5754r.h:219
#define AD5754R_REG_OUTPUT_RANGE_SEL
Definition: ad5754r.h:58
int ad5754r_set_current_clamp_en(struct ad5754r_dev *dev, enum ad5754r_ctrl_current_clamp_en clamp_en)
Apply current clamp setting for device.
Definition: ad5754r.c:425
ad5754r_dac_ch_range
DAC Channel Output Ranges.
Definition: ad5754r.h:132
#define AD5754R_CTRL_CLAMP_EN(X)
Definition: ad5754r.h:84
int ad5754r_gpio_init(struct ad5754r_dev *dev, struct ad5754r_init_param *init_param)
Do GPIO initialization and config for AD5754R.
Definition: ad5754r.c:658
struct no_os_gpio_init_param * gpio_ldac_init
Definition: ad5754r.h:243
#define AD5754R_PWR_OC_ALERT_CH_MASK(x)
Definition: ad5754r.h:97
@ AD5754R_PWR_TSD_DETECTED
Definition: ad5754r.h:212
int ad5754r_set_int_ref_pwrup(struct ad5754r_dev *dev, enum ad5754r_pwr_int_ref_pwrup int_ref_pwrup)
Set Internal Reference Enable/Disable state for device.
Definition: ad5754r.c:533
enum ad5754r_ctrl_sdo_dis sdo_dis
Definition: ad5754r.h:253
enum ad5754r_ctrl_tsd_en tsd_en
Definition: ad5754r.h:249
#define AD5754R_WRITE
Definition: ad5754r.h:105
Header file of Delay functions.
struct no_os_gpio_desc * gpio_clear
Definition: ad5754r.h:272
int ad5754r_set_ch_pwrup(struct ad5754r_dev *dev, uint8_t chn, enum ad5754r_pwr_dac_ch_pwrup ch_pwrup)
Set power-up state for specific channel.
Definition: ad5754r.c:395
Definition: ad9361_util.h:69
@ AD5754R_CTRL_SDO_DIS
Definition: ad5754r.h:185
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
ad5754r_encoding_scheme
DAC encoding scheme: Binary/2sComplement.
Definition: ad5754r.h:228
int ad5754r_dac_mvolts_to_code(struct ad5754r_dev *dev, uint8_t chn, uint16_t mvolts, uint16_t *code)
Convert DAC millivolts to code for specific channel.
Definition: ad5754r.c:333
@ AD5754R_PWR_TSD_NOT_DETECTED
Definition: ad5754r.h:211
#define AD5754R_CTRL_CLAMP_EN_MASK
Definition: ad5754r.h:85
ad5754r Device structure.
Definition: ad5754r.h:268
int ad5754r_set_sdo_disable(struct ad5754r_dev *dev, enum ad5754r_ctrl_sdo_dis sdo_dis)
Set SDO Enable/Disable state for device.
Definition: ad5754r.c:506
ad5754r_ctrl_current_clamp_en
Current Clamp EN/DIS Modes.
Definition: ad5754r.h:156
int ad5754r_gpio_init(struct ad5754r_dev *dev, struct ad5754r_init_param *init_param)
Do GPIO initialization and config for AD5754R.
Definition: ad5754r.c:658
int ad5754r_update_dac_all_ch_registers(struct ad5754r_dev *dev, uint16_t value)
Update DAC register value for all channels.
Definition: ad5754r.c:192
@ AD5754R_DAC_CH_D
Definition: ad5754r.h:125
@ AD5754R_DAC_CH_C
Definition: ad5754r.h:124
#define AD5754R_GAIN_SCALE
Definition: ad5754r.h:111
enum ad5754r_ctrl_tsd_en tsd_en
Definition: ad5754r.h:280
#define AD5754R_REG_DAC
Definition: ad5754r.h:57
int ad5754r_set_sdo_disable(struct ad5754r_dev *dev, enum ad5754r_ctrl_sdo_dis sdo_dis)
Set SDO Enable/Disable state for device.
Definition: ad5754r.c:506
enum ad5754r_pwr_dac_ch_pwrup dac_ch_pwr_states[AD5754R_NUM_CHANNELS]
Definition: ad5754r.h:255
#define AD5754R_INSTR_CLEAR
Definition: ad5754r.h:108
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
@ AD5754R_PWR_DAC_CH_POWERDOWN
Definition: ad5754r.h:193
ad5754r Device initialization parameters.
Definition: ad5754r.h:237
@ AD5754R_DAC_CH_B
Definition: ad5754r.h:123
int ad5754r_write(struct ad5754r_dev *dev, uint8_t instr_addr, uint16_t reg_val)
Write device register.
Definition: ad5754r.c:71
struct no_os_spi_desc * spi_desc
Definition: ad5754r.h:270
@ AD5754R_SPAN_M5V_TO_5V
Definition: ad5754r.h:136
@ AD5754R_LOAD_DAC_ADDR
Definition: ad5754r.h:149
@ AD5754R_SPAN_0V_TO_5V
Definition: ad5754r.h:133
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
struct no_os_gpio_desc * gpio_ldac
Definition: ad5754r.h:274
int ad5754r_clear_async(struct ad5754r_dev *dev)
Clear DAC output for all channels.
Definition: ad5754r.c:246
@ AD5754R_SPAN_0V_TO_10V8
Definition: ad5754r.h:135
int ad5754r_spi_verify(struct ad5754r_dev *dev)
Write to and read back a register to verify SPI.
Definition: ad5754r.c:619
enum ad5754r_encoding_scheme encoding
Definition: ad5754r.h:290
@ AD5754R_SPAN_M10V8_TO_10V8
Definition: ad5754r.h:138
@ AD5754R_PWR_OC_CH_DETECTED
Definition: ad5754r.h:221
ad5754r_ctrl_clear_sel
Clear Mode Options.
Definition: ad5754r.h:174
#define AD5754R_CTRL_TSD_EN(x)
Definition: ad5754r.h:82
int ad5754r_dac_code_to_mvolts(struct ad5754r_dev *dev, uint8_t chn, uint16_t code, uint16_t *value)
Convert DAC code to millivolts for specific channel.
Definition: ad5754r.c:292
struct no_os_spi_init_param * spi_init
Definition: ad5754r.h:239
int ad5754r_remove_gpios(struct ad5754r_dev *dev)
Remove GPIOs and free resources.
Definition: ad5754r.c:810
#define AD5754R_PWR_TSD_ALERT_MASK
Definition: ad5754r.h:99
#define AD5754R_MAX_RESOLUTION
Definition: ad5754r.h:51
@ AD5754R_TSD_CLAMP_CLR_SDO_DAC_ADDR
Definition: ad5754r.h:147
enum ad5754r_ctrl_clear_sel clear_sel
Definition: ad5754r.h:251
int ad5754r_init(struct ad5754r_dev **device, struct ad5754r_init_param *init_param)
Initialize the device.
Definition: ad5754r.c:751
int ad5754r_set_ch_range(struct ad5754r_dev *dev, uint8_t chn, enum ad5754r_dac_ch_range ch_range)
Set output range for specific channel.
Definition: ad5754r.c:369
int ad5754r_read(struct ad5754r_dev *dev, uint8_t instr_addr, uint16_t *reg_val)
Read device register.
Definition: ad5754r.c:98
#define AD5754R_INSTR_NOP
Definition: ad5754r.h:107
@ AD5754R_ENCODING_BINARY
Definition: ad5754r.h:230
const unsigned int ad5754r_gain_values_scaled[AD5754R_SPAN_M10V8_TO_10V8+1]
Definition: ad5754r.c:48
int ad5754r_set_clear_mode(struct ad5754r_dev *dev, enum ad5754r_ctrl_clear_sel clear_sel)
Set clear mode setting for device.
Definition: ad5754r.c:479
int ad5754r_get_tsd_alert(struct ad5754r_dev *dev, enum ad5754r_pwr_tsd_alert *tsd_alert)
Get Thermal Shutdown status bit.
Definition: ad5754r.c:591
#define AD5754R_PREP_INSTR_ADDR(reg, dac_ch)
Definition: ad5754r.h:74
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:104
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
@ AD5754R_PWR_INT_REF_POWERDOWN
Definition: ad5754r.h:202
#define AD5754R_INSTR_LOAD
Definition: ad5754r.h:109
ad5754r_pwr_tsd_alert
Thermal Shutdown Alert State.
Definition: ad5754r.h:210
@ AD5754R_CTRL_TSD_DIS
Definition: ad5754r.h:166
const unsigned int ad5754r_gain_values_scaled[AD5754R_SPAN_M10V8_TO_10V8+1]
Definition: ad5754r.c:48
ad5754r_pwr_int_ref_pwrup
Internal Reference Powerup Modes.
Definition: ad5754r.h:201
@ AD5754R_NOP_DAC_ADDR
Definition: ad5754r.h:146
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
#define AD5754R_DAC_CH_A_ADDR
Definition: ad5754r.h:63
int ad5754r_ldac_trigger(struct ad5754r_dev *dev)
Trigger LDAC.
Definition: ad5754r.c:219
int ad5754r_update_dac_all_ch_registers(struct ad5754r_dev *dev, uint16_t value)
Update DAC register value for all channels.
Definition: ad5754r.c:192
@ AD5754R_CTRL_SDO_EN
Definition: ad5754r.h:184
enum ad5754r_pwr_dac_ch_pwrup dac_ch_pwr_states[AD5754R_NUM_CHANNELS]
Definition: ad5754r.h:286
enum ad5754r_ctrl_sdo_dis sdo_dis
Definition: ad5754r.h:284
int ad5754r_get_oc_ch_alert(struct ad5754r_dev *dev, uint8_t chn, enum ad5754r_pwr_oc_ch_alert *oc_ch_alert)
Get Over-current status bit for specific channel.
Definition: ad5754r.c:563
uint16_t vref_mv
Definition: ad5754r.h:292
@ AD5754R_CTRL_CLEAR_0V
Definition: ad5754r.h:175
#define AD5754R_DAC_CH_ALL_ADDR
Definition: ad5754r.h:67
@ AD5754R_SPAN_0V_TO_10V
Definition: ad5754r.h:134
int ad5754r_read(struct ad5754r_dev *dev, uint8_t instr_addr, uint16_t *reg_val)
Read device register.
Definition: ad5754r.c:98
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:43
int ad5754r_write(struct ad5754r_dev *dev, uint8_t instr_addr, uint16_t reg_val)
Write device register.
Definition: ad5754r.c:71
@ AD5754R_ENCODING_TWOSCOMPLEMENT
Definition: ad5754r.h:229
int ad5754r_get_tsd_alert(struct ad5754r_dev *dev, enum ad5754r_pwr_tsd_alert *tsd_alert)
Get Thermal Shutdown status bit.
Definition: ad5754r.c:591
@ AD5754R_PWR_DAC_CH_POWERUP
Definition: ad5754r.h:194
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
@ AD5754R_CTRL_CLAMP_EN
Definition: ad5754r.h:158
#define AD5754R_REG_CONTROL
Definition: ad5754r.h:60
enum ad5754r_encoding_scheme encoding
Definition: ad5754r.h:259
int ad5754r_set_tsd_en(struct ad5754r_dev *dev, enum ad5754r_ctrl_tsd_en tsd_en)
Apply TSD setting for device.
Definition: ad5754r.c:452
int ad5754r_clear_async(struct ad5754r_dev *dev)
Clear DAC output for all channels.
Definition: ad5754r.c:246
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
int ad5754r_set_ch_pwrup(struct ad5754r_dev *dev, uint8_t chn, enum ad5754r_pwr_dac_ch_pwrup ch_pwrup)
Set power-up state for specific channel.
Definition: ad5754r.c:395
@ AD5754R_SPAN_M10V_TO_10V
Definition: ad5754r.h:137
ad5754r_pwr_dac_ch_pwrup
DAC Channel Powerup Modes.
Definition: ad5754r.h:192
@ AD5754R_PWR_INT_REF_POWERUP
Definition: ad5754r.h:203
#define AD5754R_PWR_UP_INT_REF_MASK
Definition: ad5754r.h:95
int ad5754r_remove(struct ad5754r_dev *dev)
Remove the device and release resources.
Definition: ad5754r.c:837
enum ad5754r_dac_ch_range dac_ch_range[AD5754R_NUM_CHANNELS]
Definition: ad5754r.h:276
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
int ad5754r_ldac_trigger(struct ad5754r_dev *dev)
Trigger LDAC.
Definition: ad5754r.c:219
#define AD5754R_PWR_UP_DAC_CH_MASK(x)
Definition: ad5754r.h:94
int ad5754r_dac_mvolts_to_code(struct ad5754r_dev *dev, uint8_t chn, uint16_t mvolts, uint16_t *code)
Convert DAC millivolts to code for specific channel.
Definition: ad5754r.c:333
int ad5754r_update_bits(struct ad5754r_dev *dev, uint8_t instr_addr, uint16_t mask, uint16_t reg_val)
Update specific register bits.
Definition: ad5754r.c:140
#define AD5754R_BYTE_H
Definition: ad5754r.h:101
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: no_os_gpio.c:197
struct no_os_gpio_init_param * gpio_clear_init
Definition: ad5754r.h:241
int ad5754r_get_oc_ch_alert(struct ad5754r_dev *dev, uint8_t chn, enum ad5754r_pwr_oc_ch_alert *oc_ch_alert)
Get Over-current status bit for specific channel.
Definition: ad5754r.c:563
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
@ AD5754R_CTRL_CLAMP_DIS
Definition: ad5754r.h:157
@ AD5754R_CTRL_TSD_EN
Definition: ad5754r.h:167
int ad5754r_update_dac_ch_register(struct ad5754r_dev *dev, uint8_t chn, uint16_t value)
Update DAC register value for specific channel.
Definition: ad5754r.c:165
ad5754r_dac_addr_for_ctrl_settings
DAC Addresses for Control Register Settings.
Definition: ad5754r.h:145
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:116
int ad5754r_init(struct ad5754r_dev **device, struct ad5754r_init_param *init_param)
Initialize the device.
Definition: ad5754r.c:751
int ad5754r_set_tsd_en(struct ad5754r_dev *dev, enum ad5754r_ctrl_tsd_en tsd_en)
Apply TSD setting for device.
Definition: ad5754r.c:452
Header file of GPIO Interface.
@ AD5754R_CTRL_CLEAR_MIDSCALE_CODE
Definition: ad5754r.h:176
@ AD5754R_CLEAR_DAC_ADDR
Definition: ad5754r.h:148
#define AD5754R_REG_PWR_CTRL
Definition: ad5754r.h:59
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:52
uint16_t no_os_get_unaligned_be16(uint8_t *buf)
int ad5754r_spi_verify(struct ad5754r_dev *dev)
Write to and read back a register to verify SPI.
Definition: ad5754r.c:619
int ad5754r_update_bits(struct ad5754r_dev *dev, uint8_t instr_addr, uint16_t mask, uint16_t reg_val)
Update specific register bits.
Definition: ad5754r.c:140
Header file of utility functions.
#define AD5754R_CTRL_TSD_EN_MASK
Definition: ad5754r.h:83
enum ad5754r_pwr_int_ref_pwrup int_ref_pwrup
Definition: ad5754r.h:257
uint16_t vref_mv
Definition: ad5754r.h:261
#define AD5754R_CTRL_SDO_DISABLE_MASK
Definition: ad5754r.h:89
int ad5754r_dac_code_to_mvolts(struct ad5754r_dev *dev, uint8_t chn, uint16_t code, uint16_t *value)
Convert DAC code to millivolts for specific channel.
Definition: ad5754r.c:292
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: no_os_gpio.c:147
#define AD5754R_OUTPUT_RANGE_SEL_MASK
Definition: ad5754r.h:78
enum ad5754r_ctrl_current_clamp_en clamp_en
Definition: ad5754r.h:247
int ad5754r_remove_gpios(struct ad5754r_dev *dev)
Remove GPIOs and free resources.
Definition: ad5754r.c:810
ad5754r_dac_channels
DAC Channels.
Definition: ad5754r.h:121
#define AD5754R_NUM_CHANNELS
Definition: ad5754r.h:54
int ad5754r_reg_init(struct ad5754r_dev *dev, struct ad5754r_init_param *init_param)
Initialize registers based on init parameters.
Definition: ad5754r.c:698
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
int32_t no_os_gpio_get_optional(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Get the value of an optional GPIO.
Definition: no_os_gpio.c:75