Library files for AD5592R

Dependents:   EVAL-AD5592R

Committer:
EndaKilgarriff
Date:
Mon Jun 15 13:58:03 2020 +0000
Revision:
1:2ad195e1455b
AD5592R Initial Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
EndaKilgarriff 1:2ad195e1455b 1 /***************************************************************************//**
EndaKilgarriff 1:2ad195e1455b 2 * @file ad5592r.c
EndaKilgarriff 1:2ad195e1455b 3 * @brief Implementation of AD5592R driver.
EndaKilgarriff 1:2ad195e1455b 4 * @author Mircea Caprioru (mircea.caprioru@analog.com)
EndaKilgarriff 1:2ad195e1455b 5 ********************************************************************************
EndaKilgarriff 1:2ad195e1455b 6 * Copyright 2018, 2020(c) Analog Devices, Inc.
EndaKilgarriff 1:2ad195e1455b 7 *
EndaKilgarriff 1:2ad195e1455b 8 * All rights reserved.
EndaKilgarriff 1:2ad195e1455b 9 *
EndaKilgarriff 1:2ad195e1455b 10 * Redistribution and use in source and binary forms, with or without
EndaKilgarriff 1:2ad195e1455b 11 * modification, are permitted provided that the following conditions are met:
EndaKilgarriff 1:2ad195e1455b 12 * - Redistributions of source code must retain the above copyright
EndaKilgarriff 1:2ad195e1455b 13 * notice, this list of conditions and the following disclaimer.
EndaKilgarriff 1:2ad195e1455b 14 * - Redistributions in binary form must reproduce the above copyright
EndaKilgarriff 1:2ad195e1455b 15 * notice, this list of conditions and the following disclaimer in
EndaKilgarriff 1:2ad195e1455b 16 * the documentation and/or other materials provided with the
EndaKilgarriff 1:2ad195e1455b 17 * distribution.
EndaKilgarriff 1:2ad195e1455b 18 * - Neither the name of Analog Devices, Inc. nor the names of its
EndaKilgarriff 1:2ad195e1455b 19 * contributors may be used to endorse or promote products derived
EndaKilgarriff 1:2ad195e1455b 20 * from this software without specific prior written permission.
EndaKilgarriff 1:2ad195e1455b 21 * - The use of this software may or may not infringe the patent rights
EndaKilgarriff 1:2ad195e1455b 22 * of one or more patent holders. This license does not release you
EndaKilgarriff 1:2ad195e1455b 23 * from the requirement that you obtain separate licenses from these
EndaKilgarriff 1:2ad195e1455b 24 * patent holders to use this software.
EndaKilgarriff 1:2ad195e1455b 25 * - Use of the software either in source or binary form, must be run
EndaKilgarriff 1:2ad195e1455b 26 * on or directly connected to an Analog Devices Inc. component.
EndaKilgarriff 1:2ad195e1455b 27 *
EndaKilgarriff 1:2ad195e1455b 28 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
EndaKilgarriff 1:2ad195e1455b 29 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
EndaKilgarriff 1:2ad195e1455b 30 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
EndaKilgarriff 1:2ad195e1455b 31 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
EndaKilgarriff 1:2ad195e1455b 32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
EndaKilgarriff 1:2ad195e1455b 33 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
EndaKilgarriff 1:2ad195e1455b 34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
EndaKilgarriff 1:2ad195e1455b 35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
EndaKilgarriff 1:2ad195e1455b 36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
EndaKilgarriff 1:2ad195e1455b 37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EndaKilgarriff 1:2ad195e1455b 38 *******************************************************************************/
EndaKilgarriff 1:2ad195e1455b 39 #include "error.h"
EndaKilgarriff 1:2ad195e1455b 40 #include "ad5592r-base.h"
EndaKilgarriff 1:2ad195e1455b 41 #include "ad5592r.h"
EndaKilgarriff 1:2ad195e1455b 42
EndaKilgarriff 1:2ad195e1455b 43 const struct ad5592r_rw_ops ad5592r_rw_ops = {
EndaKilgarriff 1:2ad195e1455b 44 .write_dac = ad5592r_write_dac,
EndaKilgarriff 1:2ad195e1455b 45 .read_adc = ad5592r_read_adc,
EndaKilgarriff 1:2ad195e1455b 46 .multi_read_adc = ad5592r_multi_read_adc,
EndaKilgarriff 1:2ad195e1455b 47 .reg_write = ad5592r_reg_write,
EndaKilgarriff 1:2ad195e1455b 48 .reg_read = ad5592r_reg_read,
EndaKilgarriff 1:2ad195e1455b 49 .gpio_read = ad5592r_gpio_read,
EndaKilgarriff 1:2ad195e1455b 50 };
EndaKilgarriff 1:2ad195e1455b 51
EndaKilgarriff 1:2ad195e1455b 52 /**
EndaKilgarriff 1:2ad195e1455b 53 * Write NOP and read value.
EndaKilgarriff 1:2ad195e1455b 54 *
EndaKilgarriff 1:2ad195e1455b 55 * @param dev - The device structure.
EndaKilgarriff 1:2ad195e1455b 56 * @param buf - buffer where to read
EndaKilgarriff 1:2ad195e1455b 57 * @return 0 in case of success, negative error code otherwise
EndaKilgarriff 1:2ad195e1455b 58 */
EndaKilgarriff 1:2ad195e1455b 59 static int32_t ad5592r_spi_wnop_r16(struct ad5592r_dev *dev, uint16_t *buf)
EndaKilgarriff 1:2ad195e1455b 60 {
EndaKilgarriff 1:2ad195e1455b 61 int32_t ret;
EndaKilgarriff 1:2ad195e1455b 62 uint16_t spi_msg_nop = 0; /* NOP */
EndaKilgarriff 1:2ad195e1455b 63
EndaKilgarriff 1:2ad195e1455b 64 ret = spi_write_and_read(dev->spi, (uint8_t *)&spi_msg_nop,
EndaKilgarriff 1:2ad195e1455b 65 sizeof(spi_msg_nop));
EndaKilgarriff 1:2ad195e1455b 66 if (ret < 0)
EndaKilgarriff 1:2ad195e1455b 67 return ret;
EndaKilgarriff 1:2ad195e1455b 68
EndaKilgarriff 1:2ad195e1455b 69 *buf = swab16(spi_msg_nop);
EndaKilgarriff 1:2ad195e1455b 70
EndaKilgarriff 1:2ad195e1455b 71 return ret;
EndaKilgarriff 1:2ad195e1455b 72 }
EndaKilgarriff 1:2ad195e1455b 73
EndaKilgarriff 1:2ad195e1455b 74 /**
EndaKilgarriff 1:2ad195e1455b 75 * Write DAC channel.
EndaKilgarriff 1:2ad195e1455b 76 *
EndaKilgarriff 1:2ad195e1455b 77 * @param dev - The device structure.
EndaKilgarriff 1:2ad195e1455b 78 * @param chan - The channel number.
EndaKilgarriff 1:2ad195e1455b 79 * @param value - DAC value
EndaKilgarriff 1:2ad195e1455b 80 * @return 0 in case of success, negative error code otherwise
EndaKilgarriff 1:2ad195e1455b 81 */
EndaKilgarriff 1:2ad195e1455b 82 int32_t ad5592r_write_dac(struct ad5592r_dev *dev, uint8_t chan,
EndaKilgarriff 1:2ad195e1455b 83 uint16_t value)
EndaKilgarriff 1:2ad195e1455b 84 {
EndaKilgarriff 1:2ad195e1455b 85 if (!dev)
EndaKilgarriff 1:2ad195e1455b 86 return FAILURE;
EndaKilgarriff 1:2ad195e1455b 87
EndaKilgarriff 1:2ad195e1455b 88 dev->spi_msg = swab16( BIT(15) | (uint16_t)(chan << 12) | value);
EndaKilgarriff 1:2ad195e1455b 89
EndaKilgarriff 1:2ad195e1455b 90 return spi_write_and_read(dev->spi, (uint8_t *)&dev->spi_msg,
EndaKilgarriff 1:2ad195e1455b 91 sizeof(dev->spi_msg));
EndaKilgarriff 1:2ad195e1455b 92 }
EndaKilgarriff 1:2ad195e1455b 93
EndaKilgarriff 1:2ad195e1455b 94 /**
EndaKilgarriff 1:2ad195e1455b 95 * Read ADC channel.
EndaKilgarriff 1:2ad195e1455b 96 *
EndaKilgarriff 1:2ad195e1455b 97 * @param dev - The device structure.
EndaKilgarriff 1:2ad195e1455b 98 * @param chan - The channel number.
EndaKilgarriff 1:2ad195e1455b 99 * @param value - ADC value
EndaKilgarriff 1:2ad195e1455b 100 * @return 0 in case of success, negative error code otherwise
EndaKilgarriff 1:2ad195e1455b 101 */
EndaKilgarriff 1:2ad195e1455b 102 int32_t ad5592r_read_adc(struct ad5592r_dev *dev, uint8_t chan,
EndaKilgarriff 1:2ad195e1455b 103 uint16_t *value)
EndaKilgarriff 1:2ad195e1455b 104 {
EndaKilgarriff 1:2ad195e1455b 105 int32_t ret;
EndaKilgarriff 1:2ad195e1455b 106
EndaKilgarriff 1:2ad195e1455b 107 if (!dev)
EndaKilgarriff 1:2ad195e1455b 108 return FAILURE;
EndaKilgarriff 1:2ad195e1455b 109
EndaKilgarriff 1:2ad195e1455b 110 dev->spi_msg = swab16((uint16_t)(AD5592R_REG_ADC_SEQ << 11) |
EndaKilgarriff 1:2ad195e1455b 111 BIT(chan));
EndaKilgarriff 1:2ad195e1455b 112
EndaKilgarriff 1:2ad195e1455b 113 ret = spi_write_and_read(dev->spi, (uint8_t *)&dev->spi_msg,
EndaKilgarriff 1:2ad195e1455b 114 sizeof(dev->spi_msg));
EndaKilgarriff 1:2ad195e1455b 115 if (ret < 0)
EndaKilgarriff 1:2ad195e1455b 116 return ret;
EndaKilgarriff 1:2ad195e1455b 117
EndaKilgarriff 1:2ad195e1455b 118 /*
EndaKilgarriff 1:2ad195e1455b 119 * Invalid data:
EndaKilgarriff 1:2ad195e1455b 120 * See Figure 40. Single-Channel ADC Conversion Sequence
EndaKilgarriff 1:2ad195e1455b 121 */
EndaKilgarriff 1:2ad195e1455b 122 ret = ad5592r_spi_wnop_r16(dev, &dev->spi_msg);
EndaKilgarriff 1:2ad195e1455b 123 if (ret < 0)
EndaKilgarriff 1:2ad195e1455b 124 return ret;
EndaKilgarriff 1:2ad195e1455b 125
EndaKilgarriff 1:2ad195e1455b 126 ret = ad5592r_spi_wnop_r16(dev, &dev->spi_msg);
EndaKilgarriff 1:2ad195e1455b 127 if (ret < 0)
EndaKilgarriff 1:2ad195e1455b 128 return ret;
EndaKilgarriff 1:2ad195e1455b 129
EndaKilgarriff 1:2ad195e1455b 130 *value = dev->spi_msg;
EndaKilgarriff 1:2ad195e1455b 131
EndaKilgarriff 1:2ad195e1455b 132 return 0;
EndaKilgarriff 1:2ad195e1455b 133 }
EndaKilgarriff 1:2ad195e1455b 134
EndaKilgarriff 1:2ad195e1455b 135 /**
EndaKilgarriff 1:2ad195e1455b 136 * Read Multiple ADC Channels.
EndaKilgarriff 1:2ad195e1455b 137 *
EndaKilgarriff 1:2ad195e1455b 138 * @param dev - The device structure.
EndaKilgarriff 1:2ad195e1455b 139 * @param chans - The ADC channels to be readback
EndaKilgarriff 1:2ad195e1455b 140 * @param values - ADC value array
EndaKilgarriff 1:2ad195e1455b 141 * @return 0 in case of success, negative error code otherwise
EndaKilgarriff 1:2ad195e1455b 142 */
EndaKilgarriff 1:2ad195e1455b 143 int32_t ad5592r_multi_read_adc(struct ad5592r_dev *dev, uint16_t chans,
EndaKilgarriff 1:2ad195e1455b 144 uint16_t *values)
EndaKilgarriff 1:2ad195e1455b 145 {
EndaKilgarriff 1:2ad195e1455b 146 int32_t ret;
EndaKilgarriff 1:2ad195e1455b 147 uint8_t samples;
EndaKilgarriff 1:2ad195e1455b 148 uint8_t i;
EndaKilgarriff 1:2ad195e1455b 149
EndaKilgarriff 1:2ad195e1455b 150 if (!dev)
EndaKilgarriff 1:2ad195e1455b 151 return FAILURE;
EndaKilgarriff 1:2ad195e1455b 152
EndaKilgarriff 1:2ad195e1455b 153 samples = hweight8(chans);
EndaKilgarriff 1:2ad195e1455b 154
EndaKilgarriff 1:2ad195e1455b 155 dev->spi_msg = swab16((uint16_t)(AD5592R_REG_ADC_SEQ << 11) | chans);
EndaKilgarriff 1:2ad195e1455b 156
EndaKilgarriff 1:2ad195e1455b 157 ret = spi_write_and_read(dev->spi, (uint8_t *)&dev->spi_msg,
EndaKilgarriff 1:2ad195e1455b 158 sizeof(dev->spi_msg));
EndaKilgarriff 1:2ad195e1455b 159 if (ret < 0)
EndaKilgarriff 1:2ad195e1455b 160 return ret;
EndaKilgarriff 1:2ad195e1455b 161
EndaKilgarriff 1:2ad195e1455b 162 /*
EndaKilgarriff 1:2ad195e1455b 163 * Invalid data:
EndaKilgarriff 1:2ad195e1455b 164 * See Figure 40. Single-Channel ADC Conversion Sequence
EndaKilgarriff 1:2ad195e1455b 165 */
EndaKilgarriff 1:2ad195e1455b 166 ret = ad5592r_spi_wnop_r16(dev, &dev->spi_msg);
EndaKilgarriff 1:2ad195e1455b 167 if (ret < 0)
EndaKilgarriff 1:2ad195e1455b 168 return ret;
EndaKilgarriff 1:2ad195e1455b 169
EndaKilgarriff 1:2ad195e1455b 170 for (i = 0; i < samples; i++) {
EndaKilgarriff 1:2ad195e1455b 171 ret = ad5592r_spi_wnop_r16(dev, &dev->spi_msg);
EndaKilgarriff 1:2ad195e1455b 172 if (ret < 0)
EndaKilgarriff 1:2ad195e1455b 173 return ret;
EndaKilgarriff 1:2ad195e1455b 174 values[i] = dev->spi_msg;
EndaKilgarriff 1:2ad195e1455b 175 }
EndaKilgarriff 1:2ad195e1455b 176
EndaKilgarriff 1:2ad195e1455b 177 return 0;
EndaKilgarriff 1:2ad195e1455b 178 }
EndaKilgarriff 1:2ad195e1455b 179
EndaKilgarriff 1:2ad195e1455b 180 /**
EndaKilgarriff 1:2ad195e1455b 181 * Write register.
EndaKilgarriff 1:2ad195e1455b 182 *
EndaKilgarriff 1:2ad195e1455b 183 * @param dev - The device structure.
EndaKilgarriff 1:2ad195e1455b 184 * @param reg - The register address.
EndaKilgarriff 1:2ad195e1455b 185 * @param value - register value
EndaKilgarriff 1:2ad195e1455b 186 * @return 0 in case of success, negative error code otherwise
EndaKilgarriff 1:2ad195e1455b 187 */
EndaKilgarriff 1:2ad195e1455b 188 int32_t ad5592r_reg_write(struct ad5592r_dev *dev, uint8_t reg, uint16_t value)
EndaKilgarriff 1:2ad195e1455b 189 {
EndaKilgarriff 1:2ad195e1455b 190 if (!dev)
EndaKilgarriff 1:2ad195e1455b 191 return FAILURE;
EndaKilgarriff 1:2ad195e1455b 192
EndaKilgarriff 1:2ad195e1455b 193 dev->spi_msg = swab16((reg << 11) | value);
EndaKilgarriff 1:2ad195e1455b 194
EndaKilgarriff 1:2ad195e1455b 195 return spi_write_and_read(dev->spi, (uint8_t *)&dev->spi_msg,
EndaKilgarriff 1:2ad195e1455b 196 sizeof(dev->spi_msg));
EndaKilgarriff 1:2ad195e1455b 197 }
EndaKilgarriff 1:2ad195e1455b 198
EndaKilgarriff 1:2ad195e1455b 199 /**
EndaKilgarriff 1:2ad195e1455b 200 * Read register.
EndaKilgarriff 1:2ad195e1455b 201 *
EndaKilgarriff 1:2ad195e1455b 202 * @param dev - The device structure.
EndaKilgarriff 1:2ad195e1455b 203 * @param reg - The register address.
EndaKilgarriff 1:2ad195e1455b 204 * @param value - register value
EndaKilgarriff 1:2ad195e1455b 205 * @return 0 in case of success, negative error code otherwise
EndaKilgarriff 1:2ad195e1455b 206 */
EndaKilgarriff 1:2ad195e1455b 207 int32_t ad5592r_reg_read(struct ad5592r_dev *dev, uint8_t reg, uint16_t *value)
EndaKilgarriff 1:2ad195e1455b 208 {
EndaKilgarriff 1:2ad195e1455b 209 int32_t ret;
EndaKilgarriff 1:2ad195e1455b 210
EndaKilgarriff 1:2ad195e1455b 211 if (!dev)
EndaKilgarriff 1:2ad195e1455b 212 return FAILURE;
EndaKilgarriff 1:2ad195e1455b 213
EndaKilgarriff 1:2ad195e1455b 214 dev->spi_msg = swab16((AD5592R_REG_LDAC << 11) |
EndaKilgarriff 1:2ad195e1455b 215 AD5592R_LDAC_READBACK_EN | (reg << 2) | dev->ldac_mode);
EndaKilgarriff 1:2ad195e1455b 216
EndaKilgarriff 1:2ad195e1455b 217 ret = spi_write_and_read(dev->spi, (uint8_t *)&dev->spi_msg,
EndaKilgarriff 1:2ad195e1455b 218 sizeof(dev->spi_msg));
EndaKilgarriff 1:2ad195e1455b 219 if (ret < 0)
EndaKilgarriff 1:2ad195e1455b 220 return ret;
EndaKilgarriff 1:2ad195e1455b 221
EndaKilgarriff 1:2ad195e1455b 222 ret = ad5592r_spi_wnop_r16(dev, &dev->spi_msg);
EndaKilgarriff 1:2ad195e1455b 223 if (ret < 0)
EndaKilgarriff 1:2ad195e1455b 224 return ret;
EndaKilgarriff 1:2ad195e1455b 225
EndaKilgarriff 1:2ad195e1455b 226 *value = dev->spi_msg;
EndaKilgarriff 1:2ad195e1455b 227
EndaKilgarriff 1:2ad195e1455b 228 return 0;
EndaKilgarriff 1:2ad195e1455b 229 }
EndaKilgarriff 1:2ad195e1455b 230
EndaKilgarriff 1:2ad195e1455b 231 /**
EndaKilgarriff 1:2ad195e1455b 232 * Read GPIOs.
EndaKilgarriff 1:2ad195e1455b 233 *
EndaKilgarriff 1:2ad195e1455b 234 * @param dev - The device structure.
EndaKilgarriff 1:2ad195e1455b 235 * @param value - GPIOs value.
EndaKilgarriff 1:2ad195e1455b 236 * @return 0 in case of success, negative error code otherwise
EndaKilgarriff 1:2ad195e1455b 237 */
EndaKilgarriff 1:2ad195e1455b 238 int32_t ad5592r_gpio_read(struct ad5592r_dev *dev, uint8_t *value)
EndaKilgarriff 1:2ad195e1455b 239 {
EndaKilgarriff 1:2ad195e1455b 240 int32_t ret;
EndaKilgarriff 1:2ad195e1455b 241
EndaKilgarriff 1:2ad195e1455b 242 if (!dev)
EndaKilgarriff 1:2ad195e1455b 243 return FAILURE;
EndaKilgarriff 1:2ad195e1455b 244
EndaKilgarriff 1:2ad195e1455b 245 ret = ad5592r_reg_write(dev, AD5592R_REG_GPIO_IN_EN,
EndaKilgarriff 1:2ad195e1455b 246 AD5592R_GPIO_READBACK_EN | dev->gpio_in);
EndaKilgarriff 1:2ad195e1455b 247 if (ret < 0)
EndaKilgarriff 1:2ad195e1455b 248 return ret;
EndaKilgarriff 1:2ad195e1455b 249
EndaKilgarriff 1:2ad195e1455b 250 ret = ad5592r_spi_wnop_r16(dev, &dev->spi_msg);
EndaKilgarriff 1:2ad195e1455b 251 if (ret < 0)
EndaKilgarriff 1:2ad195e1455b 252 return ret;
EndaKilgarriff 1:2ad195e1455b 253
EndaKilgarriff 1:2ad195e1455b 254 *value = (uint8_t)dev->spi_msg;
EndaKilgarriff 1:2ad195e1455b 255
EndaKilgarriff 1:2ad195e1455b 256 return 0;
EndaKilgarriff 1:2ad195e1455b 257 }
EndaKilgarriff 1:2ad195e1455b 258
EndaKilgarriff 1:2ad195e1455b 259 /**
EndaKilgarriff 1:2ad195e1455b 260 * Initialize AD5593r device.
EndaKilgarriff 1:2ad195e1455b 261 *
EndaKilgarriff 1:2ad195e1455b 262 * @param dev - The device structure.
EndaKilgarriff 1:2ad195e1455b 263 * @param init_param - The initial parameters of the device.
EndaKilgarriff 1:2ad195e1455b 264 * @return 0 in case of success, negative error code otherwise
EndaKilgarriff 1:2ad195e1455b 265 */
EndaKilgarriff 1:2ad195e1455b 266 int32_t ad5592r_init(struct ad5592r_dev *dev,
EndaKilgarriff 1:2ad195e1455b 267 struct ad5592r_init_param *init_param)
EndaKilgarriff 1:2ad195e1455b 268 {
EndaKilgarriff 1:2ad195e1455b 269 int32_t ret;
EndaKilgarriff 1:2ad195e1455b 270 uint16_t temp_reg_val;
EndaKilgarriff 1:2ad195e1455b 271
EndaKilgarriff 1:2ad195e1455b 272 if (!dev)
EndaKilgarriff 1:2ad195e1455b 273 return FAILURE;
EndaKilgarriff 1:2ad195e1455b 274
EndaKilgarriff 1:2ad195e1455b 275 dev->ops = &ad5592r_rw_ops;
EndaKilgarriff 1:2ad195e1455b 276
EndaKilgarriff 1:2ad195e1455b 277 ret = ad5592r_software_reset(dev);
EndaKilgarriff 1:2ad195e1455b 278 if (ret < 0)
EndaKilgarriff 1:2ad195e1455b 279 return ret;
EndaKilgarriff 1:2ad195e1455b 280
EndaKilgarriff 1:2ad195e1455b 281 ret = ad5592r_set_channel_modes(dev);
EndaKilgarriff 1:2ad195e1455b 282 if (ret < 0)
EndaKilgarriff 1:2ad195e1455b 283 return ret;
EndaKilgarriff 1:2ad195e1455b 284
EndaKilgarriff 1:2ad195e1455b 285 if(init_param->int_ref) {
EndaKilgarriff 1:2ad195e1455b 286 ret = ad5592r_reg_read(dev, AD5592R_REG_PD, &temp_reg_val);
EndaKilgarriff 1:2ad195e1455b 287 if (ret < 0)
EndaKilgarriff 1:2ad195e1455b 288 return ret;
EndaKilgarriff 1:2ad195e1455b 289 temp_reg_val |= AD5592R_REG_PD_EN_REF;
EndaKilgarriff 1:2ad195e1455b 290
EndaKilgarriff 1:2ad195e1455b 291 return ad5592r_reg_write(dev, AD5592R_REG_PD, temp_reg_val);
EndaKilgarriff 1:2ad195e1455b 292 }
EndaKilgarriff 1:2ad195e1455b 293
EndaKilgarriff 1:2ad195e1455b 294 return ret;
EndaKilgarriff 1:2ad195e1455b 295 }