| 1 | /***************************************************************************//** |
| 2 | * @file AD9467.h |
| 3 | * @brief Header file of AD9467 Driver. |
| 4 | * @author DNechita ([email protected]) |
| 5 | ******************************************************************************** |
| 6 | * Copyright 2012(c) Analog Devices, Inc. |
| 7 | * |
| 8 | * All rights reserved. |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions are met: |
| 12 | * - Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * - Redistributions in binary form must reproduce the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer in |
| 16 | * the documentation and/or other materials provided with the |
| 17 | * distribution. |
| 18 | * - Neither the name of Analog Devices, Inc. nor the names of its |
| 19 | * contributors may be used to endorse or promote products derived |
| 20 | * from this software without specific prior written permission. |
| 21 | * - The use of this software may or may not infringe the patent rights |
| 22 | * of one or more patent holders. This license does not release you |
| 23 | * from the requirement that you obtain separate licenses from these |
| 24 | * patent holders to use this software. |
| 25 | * - Use of the software either in source or binary form, must be run |
| 26 | * on or directly connected to an Analog Devices Inc. component. |
| 27 | * |
| 28 | * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR |
| 29 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, |
| 30 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 31 | * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 33 | * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 34 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 36 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 38 | * |
| 39 | ******************************************************************************** |
| 40 | * SVN Revision: $WCREV$ |
| 41 | *******************************************************************************/ |
| 42 | #ifndef __AD9467_H__ |
| 43 | #define __AD9467_H__ |
| 44 | |
| 45 | /*****************************************************************************/ |
| 46 | /***************************** Include Files *********************************/ |
| 47 | /*****************************************************************************/ |
| 48 | #include <stdint.h> |
| 49 | |
| 50 | /******************************************************************************/ |
| 51 | /*********************************** AD9467 ***********************************/ |
| 52 | /******************************************************************************/ |
| 53 | #define AD9467_READ (1 << 15) |
| 54 | #define AD9467_WRITE (0 << 15) |
| 55 | #define AD9467_CNT(x) (((x) - 1) << 13) |
| 56 | #define AD9467_ADDR(x) ((x) & 0X1FFF) |
| 57 | |
| 58 | /* Chip configuration registers */ |
| 59 | #define AD9467_REG_CHIP_PORT_CFG 0x00 |
| 60 | #define AD9467_REG_CHIP_ID 0x01 |
| 61 | #define AD9467_REG_CHIP_GRADE 0x02 |
| 62 | |
| 63 | /* Channel index and transfer registers */ |
| 64 | #define AD9467_REG_DEVICE_UPDATE 0xFF |
| 65 | |
| 66 | /* ADC functions registers */ |
| 67 | #define AD9467_REG_MODES 0x08 |
| 68 | #define AD9467_REG_TEST_IO 0x0D |
| 69 | #define AD9467_REG_ADC_INPUT 0x0F |
| 70 | #define AD9467_REG_OFFSET 0x10 |
| 71 | #define AD9467_REG_OUT_MODE 0x14 |
| 72 | #define AD9467_REG_OUT_ADJ 0x15 |
| 73 | #define AD9467_REG_OUT_PHASE 0x16 |
| 74 | #define AD9467_REG_OUT_DELAY 0x17 |
| 75 | #define AD9467_REG_V_REF 0x18 |
| 76 | #define AD9467_REG_ANALOG_INPUT 0x2C |
| 77 | #define AD9467_REG_BUFF_CURRENT_1 0x36 |
| 78 | #define AD9467_REG_BUFF_CURRENT_2 0x107 |
| 79 | |
| 80 | /* AD9467_REG_CHIP_PORT_CFG */ |
| 81 | #define AD9467_CHIP_PORT_CGF_LSB_FIRST (1 << 6) |
| 82 | #define AD9467_CHIP_PORT_CGF_SOFT_RST (1 << 5) |
| 83 | |
| 84 | /* AD9467_REG_CHIP_GRADE */ |
| 85 | #define AD9467_CHIP_GRADE_BITS(x) (((x) & 0x3) << 4) |
| 86 | |
| 87 | /* AD9467_REG_DEVICE_UPDATE */ |
| 88 | #define AD9467_DEVICE_UPDATE_SW (1 << 0) |
| 89 | |
| 90 | /* AD9467_REG_MODES */ |
| 91 | #define AD9467_MODES_INT_PD_MODE(x) (((x) & 0x3) << 0) |
| 92 | |
| 93 | /* AD9467_REG_TEST_IO */ |
| 94 | #define AD9467_TEST_IO_RST_PN_LONG (1 << 5) |
| 95 | #define AD9467_TEST_IO_RST_PN_SHORT (1 << 4) |
| 96 | #define AD9467_TEST_IO_OUT_TEST(x) (((x) & 0xF) << 0) |
| 97 | |
| 98 | /* AD9467_REG_ADC_INPUT */ |
| 99 | #define AD9467_ADC_INPUT_XVREF (1 << 7) |
| 100 | #define AD9467_ADC_INPUT_ANALOG_DSCN (1 << 2) |
| 101 | |
| 102 | /* AD9467_REG_OUT_MODE */ |
| 103 | #define AD9467_OUT_MODE_DOUT_DISBL (1 << 4) |
| 104 | #define AD9467_OUT_MODE_OUT_INV (1 << 2) |
| 105 | #define AD9467_OUT_MODE_DATA_FORMAT(x) (((x) & 0x3) << 0) |
| 106 | |
| 107 | /* AD9467_REG_OUT_ADJ */ |
| 108 | #define AD9467_OUT_ADJ_LVDS (1 << 3) |
| 109 | #define AD9467_OUT_ADJ_OUT_CURRENT(x) (((x) & 0x7) << 0) |
| 110 | |
| 111 | /* AD9467_REG_OUT_PHASE */ |
| 112 | #define AD9467_OUT_PHASE_DCO_INV (1 << 7) |
| 113 | |
| 114 | /* AD9467_REG_OUT_DELAY */ |
| 115 | #define AD9467_OUT_DELAY_DCO_DLY_EN (1 << 7) |
| 116 | #define AD9467_OUT_DELAY_OUT_DLY(x) (((x) & 0x1F) << 0) |
| 117 | |
| 118 | /* AD9467_REG_V_REF */ |
| 119 | #define AD9467_V_REF_IN_FS_RANGE(x) (((x) & 0xF) << 0) |
| 120 | |
| 121 | /* AD9467_REG_ANALOG_INPUT */ |
| 122 | #define AD9467_ANALOG_INPUT_COUPLING (1 << 2) |
| 123 | |
| 124 | /* AD9467_REG_BUFF_CURRENT_1 */ |
| 125 | #define AD9467_BUFF_CURRENT_1(x) (((x) & 0x3F) << 2) |
| 126 | |
| 127 | /* AD9467_REG_BUFF_CURRENT_2 */ |
| 128 | #define AD9467_BUFF_CURRENT_2(x) (((x) & 0x3F) << 2) |
| 129 | |
| 130 | /******************************************************************************/ |
| 131 | /************************ Types Definitions ***********************************/ |
| 132 | /******************************************************************************/ |
| 133 | |
| 134 | /******************************************************************************/ |
| 135 | /************************ Functions Declarations ******************************/ |
| 136 | /******************************************************************************/ |
| 137 | /*! Configures the test mode and the output mode to a default state. */ |
| 138 | #ifdef OLD_VERSION |
| 139 | int32_t ad9467_setup(int32_t spiBaseAddr, int32_t ssNo); |
| 140 | #else |
| 141 | int32_t ad9467_setup(uint32_t spi_device_id, uint8_t slave_select); |
| 142 | #endif |
| 143 | /*! Writes data into a register. */ |
| 144 | int32_t ad9467_write(uint16_t regAddr, uint8_t regVal); |
| 145 | /*! Reads data from a register. */ |
| 146 | int32_t ad9467_read(uint16_t regAddr); |
| 147 | /*! Configures the power mode. */ |
| 148 | int32_t ad9467_pwr_mode(int32_t mode); |
| 149 | /*! Sets the ADC's test mode. */ |
| 150 | int32_t ad9467_test_mode(int32_t mode); |
| 151 | /*! Sets (1) or clears (0) the reset short PN sequence bit(PN9). */ |
| 152 | int32_t ad9467_reset_PN9(int32_t rst); |
| 153 | /*! Sets (1) or clears (0) the reset long PN sequence bit(PN23). */ |
| 154 | int32_t ad9467_reset_PN23(int32_t rst); |
| 155 | /*! Enables (1) or disables (0) the external voltage reference. */ |
| 156 | int32_t ad9467_external_ref(int32_t en); |
| 157 | /*! Disconnects (1) or connects (0) the analog input from or to the ADC |
| 158 | channel. */ |
| 159 | int32_t ad9467_analog_input_disconnect(int32_t en); |
| 160 | /*! Sets the offset adjustment. */ |
| 161 | int32_t ad9467_offset_adj(int32_t adj); |
| 162 | /*! Disables (1) or enables (0) the data output. */ |
| 163 | int32_t ad9467_output_disable(int32_t en); |
| 164 | /*! Activates the inverted (1) or normal (0) output mode. */ |
| 165 | int32_t ad9467_output_invert(int32_t invert); |
| 166 | /*! Specifies the output format. */ |
| 167 | int32_t ad9467_output_format(int32_t format); |
| 168 | /*! Determines LVDS output properties. */ |
| 169 | int32_t ad9467_coarse_LVDS_adj(int32_t lvds_adj); |
| 170 | /*! Sets the output current adjustment. */ |
| 171 | int32_t ad9467_output_current_adj(int32_t adj); |
| 172 | /*! Activates the normal (0) or inverted (1) DCO clock. */ |
| 173 | int32_t ad9467_dco_clock_invert(int32_t invert); |
| 174 | /*! Configures the clock delay setting. */ |
| 175 | int32_t ad9467_dco_output_clock_delay(int32_t delay); |
| 176 | /*! Configures the full-scale input voltage selection. */ |
| 177 | float ad9467_full_scale_range(float v_fs); |
| 178 | /*! Sets the AC coupling(0) or DC coupling(1) mode. */ |
| 179 | int32_t ad9467_analog_input_coupling(int32_t coupling_mode); |
| 180 | /*! Changes the input buffer current(1). */ |
| 181 | int32_t ad9467_buffer_current_1(int32_t percentage); |
| 182 | /*! Changes the input buffer current(2). */ |
| 183 | int32_t ad9467_buffer_current_2(int32_t percentage); |
| 184 | /*! Initiates a transfer and waits for the operation to end. */ |
| 185 | int32_t ad9467_transfer(void); |
| 186 | |
| 187 | #endif /* __AD9467_H__ */ |