no-OS
Loading...
Searching...
No Matches
ad5141.h
Go to the documentation of this file.
1/*******************************************************************************
2 * @file ad5141.h
3 * @brief Header file for the AD5141 digital potentiometer drivers
4********************************************************************************
5 Copyright 2025(c) Analog Devices, Inc.
6
7Redistribution and use in source and binary forms, with or without
8modification, are permitted provided that the following conditions are met:
9
101. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12
132. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
173. Neither the name of Analog Devices, Inc. nor the names of its
18 contributors may be used to endorse or promote products derived from this
19 software without specific prior written permission.
20
21THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR
22IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
24EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
25INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
27OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*******************************************************************************/
32#ifndef AD5141_H_
33#define AD5141_H_
34
35#include "../common/dpot.h"
36#include "no_os_spi.h"
37#include "no_os_i2c.h"
38#include "no_os_gpio.h"
39#include "no_os_util.h"
40#include "ad51xx_cmd.h"
41/* Number of channels in Potentiometer mode of operation*/
42#define NUM_POTENTIOMETER_CH 1
43/* Number of channels in Linear gain mode of operation*/
44#define NUM_LINEAR_GAIN_CH 2
45
46
52 /* Interface type */
54 /* SPI init parameters */
56 /* I2C init parameters */
58 /* Reset GPIO init parameters */
60 /* Digital interface select GPIO init parameters */
62 /* LRDAC GPIO init parameters */
64 /* EEPROM Write Protect GPIO init parameters */
66 /* INDEP GPIO init parameters */
68 /* Shutdown enable flag */
71 /* Operating mode */
73};
74
80 /* Interface type */
82 /* SPI descriptor */
84 /* I2C descriptor */
86 /* Reset GPIO desc */
88 /* Digital interface select GPIO descriptor */
90 /* LRDAC GPIO descriptor */
92 /* EEPROM Write Protect descriptor */
94 /* INDEP GPIO init parameters */
96 /* Shutdown enable flag */
98 /* Operating mode */
100};
101
102/* AD5141 digital potentiometer ops */
103extern const struct dpot_ops ad5141_dpot_ops;
104
105int ad5141_dpot_init(struct dpot_init_param *init_params,
106 struct dpot_dev **desc);
107int ad5141_dpot_remove(struct dpot_dev *desc);
108int ad5141_dpot_reset(struct dpot_dev *desc);
109int ad5141_dpot_shutdown(struct dpot_dev *desc,
110 enum dpot_chn_type chn, bool shutdown_enable);
112 enum dpot_operating_mode operating_mode);
113int ad5141_dpot_input_reg_read(struct dpot_dev *desc,
114 enum dpot_chn_type chn, uint8_t *data);
116 enum dpot_chn_type chn, uint8_t data);
117int ad5141_dpot_sw_lrdac_update(struct dpot_dev *desc, enum dpot_chn_type chn);
118int ad5141_dpot_chn_read(struct dpot_dev *desc,
119 enum dpot_chn_type chn, uint8_t *data);
120int ad5141_dpot_chn_write(struct dpot_dev *desc,
121 enum dpot_chn_type chn, uint8_t data);
122int ad5141_dpot_nvm_read(struct dpot_dev *desc,
123 enum dpot_chn_type chn, uint8_t *data);
124int ad5141_dpot_nvm_write(struct dpot_dev *desc,
125 enum dpot_chn_type chn, uint8_t data);
126int ad5141_dpot_copy_rdac_to_nvm(struct dpot_dev *desc, enum dpot_chn_type chn);
127int ad5141_dpot_copy_nvm_to_rdac(struct dpot_dev *desc, enum dpot_chn_type chn);
129 enum dpot_chn_type chn,
130 enum dpot_rdac_linear_status status);
131int ad5141_dpot_rdac_6db_update(struct dpot_dev *desc, enum dpot_chn_type chn,
132 enum dpot_rdac_6db_status status);
133int ad5141_dpot_send_cmd(struct dpot_dev *desc,
134 struct dpot_command *cmd);
135
136#endif // AD5141_H_
const struct dpot_ops ad5141_dpot_ops
Definition ad5141.c:910
int ad5141_dpot_set_operating_mode(struct dpot_dev *desc, enum dpot_operating_mode operating_mode)
Set the AD5141 digital potentiometer operating mode.
Definition ad5141.c:432
int ad5141_dpot_rdac_linear_update(struct dpot_dev *desc, enum dpot_chn_type chn, enum dpot_rdac_linear_status status)
Perform RDAC linear increment/decrement.
Definition ad5141.c:785
int ad5141_dpot_rdac_6db_update(struct dpot_dev *desc, enum dpot_chn_type chn, enum dpot_rdac_6db_status status)
Perform RDAC 6dB increment/decrement.
Definition ad5141.c:821
int ad5141_dpot_copy_nvm_to_rdac(struct dpot_dev *desc, enum dpot_chn_type chn)
Copy NVM/EEPROM data to RDAC.
Definition ad5141.c:753
#define NUM_LINEAR_GAIN_CH
Definition ad5141.h:44
int ad5141_dpot_nvm_write(struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t data)
Write data to NVM (non-volatile) memory.
Definition ad5141.c:684
int ad5141_dpot_input_reg_read(struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t *data)
Read the AD5141 digital potentiometer input register.
Definition ad5141.c:481
int ad5141_dpot_chn_write(struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t data)
Write to the digital potentiometer channel.
Definition ad5141.c:616
int ad5141_dpot_reset(struct dpot_dev *desc)
Reset the AD5141 digital potentiometer.
Definition ad5141.c:346
#define NUM_POTENTIOMETER_CH
Definition ad5141.h:42
int ad5141_dpot_shutdown(struct dpot_dev *desc, enum dpot_chn_type chn, bool shutdown_enable)
Shutdown the AD5141 digital potentiometer channel.
Definition ad5141.c:396
int ad5141_dpot_input_reg_write(struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t data)
Write to the digital potentiometer input register.
Definition ad5141.c:516
int ad5141_dpot_chn_read(struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t *data)
Read the AD5141 digital potentiometer channel.
Definition ad5141.c:581
int ad5141_dpot_remove(struct dpot_dev *desc)
Free the memory allocated by ad5141_dpot_init().
Definition ad5141.c:308
int ad5141_dpot_sw_lrdac_update(struct dpot_dev *desc, enum dpot_chn_type chn)
Copy input register to RDAC (software LRDAC).
Definition ad5141.c:549
int ad5141_dpot_copy_rdac_to_nvm(struct dpot_dev *desc, enum dpot_chn_type chn)
Copy RDAC register to NVM/EEPROM.
Definition ad5141.c:719
int ad5141_dpot_init(struct dpot_init_param *init_params, struct dpot_dev **desc)
Initialize the AD5141 digital potentiometer.
Definition ad5141.c:205
int ad5141_dpot_send_cmd(struct dpot_dev *desc, struct dpot_command *cmd)
Send command word to the AD5141 digital potentiometer.
Definition ad5141.c:855
int ad5141_dpot_nvm_read(struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t *data)
Read the NVM (non-volatile) memory data.
Definition ad5141.c:649
dpot_operating_mode
Digital potentiometer operating mode.
Definition dpot.h:106
dpot_rdac_linear_status
Digital potentiometer RDAC linear update status.
Definition dpot.h:118
dpot_rdac_6db_status
Digital potentiometer RDAC 6dB update status.
Definition dpot.h:130
dpot_chn_type
Digital potentiometer channel type.
Definition dpot.h:81
dpot_intf_type
digital potentiometer interface type.
Definition dpot.h:72
Header file of GPIO Interface.
Header file of I2C Interface.
Header file of SPI Interface.
Header file of utility functions.
AD5141 digital potentiometer device descriptor parameters.
Definition ad5141.h:79
struct no_os_gpio_desc * reset_gpio_desc
Definition ad5141.h:87
struct no_os_gpio_desc * dis_gpio_desc
Definition ad5141.h:89
enum dpot_intf_type intf_type
Definition ad5141.h:81
enum dpot_operating_mode operating_mode
Definition ad5141.h:99
struct no_os_gpio_desc * indep_gpio_desc
Definition ad5141.h:95
struct no_os_gpio_desc * wp_gpio_desc
Definition ad5141.h:93
struct no_os_spi_desc * spi_desc
Definition ad5141.h:83
bool shutdown_enable[2]
Definition ad5141.h:97
struct no_os_gpio_desc * lrdac_gpio_desc
Definition ad5141.h:91
struct no_os_i2c_desc * i2c_desc
Definition ad5141.h:85
AD5141 digital potentiometer init parameters.
Definition ad5141.h:51
bool shutdown_enable_lg[NUM_LINEAR_GAIN_CH]
Definition ad5141.h:70
bool shutdown_enable_pt[NUM_POTENTIOMETER_CH]
Definition ad5141.h:69
struct no_os_gpio_init_param * wp_gpio_init
Definition ad5141.h:65
struct no_os_gpio_init_param * dis_gpio_init
Definition ad5141.h:61
enum dpot_operating_mode eoperating_mode
Definition ad5141.h:72
struct no_os_i2c_init_param * i2c_init
Definition ad5141.h:57
enum dpot_intf_type eintf_type
Definition ad5141.h:53
struct no_os_gpio_init_param * lrdac_gpio_init
Definition ad5141.h:63
struct no_os_gpio_init_param * reset_gpio_init
Definition ad5141.h:59
struct no_os_gpio_init_param * indep_gpio_init
Definition ad5141.h:67
struct no_os_spi_init_param * spi_init
Definition ad5141.h:55
Digital potentiometer command structure.
Definition dpot.h:141
Digital potentiometer device descriptor parameters.
Definition dpot.h:175
Digital potentiometer init parameters.
Definition dpot.h:157
Digital potentiometer common APIs.
Definition dpot.h:188
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding I2C address descriptor.
Definition no_os_i2c.h:89
Structure holding the parameters for I2C initialization.
Definition no_os_i2c.h:52
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128