| 1 | /***************************************************************************//** |
| 2 | * @file ad9434.h |
| 3 | * @brief Header file of AD9434 Driver. |
| 4 | * @author DBogdan ([email protected]) |
| 5 | ******************************************************************************** |
| 6 | * Copyright 2015(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 | #ifndef AD9434_H_ |
| 40 | #define AD9434_H_ |
| 41 | |
| 42 | /******************************************************************************/ |
| 43 | /***************************** Include Files **********************************/ |
| 44 | /******************************************************************************/ |
| 45 | #include <stdint.h> |
| 46 | |
| 47 | /******************************************************************************/ |
| 48 | /********************** Macros and Constants Definitions **********************/ |
| 49 | /******************************************************************************/ |
| 50 | #define AD9434_REG_CHIP_PORT_CONF 0x00 |
| 51 | #define AD9434_REG_CHIP_ID 0x01 |
| 52 | #define AD9434_REG_CHIP_GRADE 0x02 |
| 53 | #define AD9434_REG_CHAN_INDEX 0x05 |
| 54 | #define AD9434_REG_TRANSFER 0xFF |
| 55 | #define AD9434_REG_MODES 0x08 |
| 56 | #define AD9434_REG_TEST_IO 0x0D |
| 57 | #define AD9434_REG_ADC_INPUT 0x0F |
| 58 | #define AD9434_REG_OFFSET 0x10 |
| 59 | #define AD9434_REG_OUTPUT_MODE 0x14 |
| 60 | #define AD9434_REG_OUTPUT_ADJUST 0x15 |
| 61 | #define AD9434_REG_OUTPUT_PHASE 0x16 |
| 62 | #define AD9434_REG_OUTPUT_DELAY 0x17 |
| 63 | #define AD9434_REG_VREF 0x18 |
| 64 | #define AD9434_REG_ANALOG_INPUT 0x2C |
| 65 | |
| 66 | /* ADC_REG_TRANSFER */ |
| 67 | #define TRANSFER_SYNC 0x1 |
| 68 | |
| 69 | /* AD9434_REG_TEST_IO */ |
| 70 | #define TESTMODE_OFF 0x0 |
| 71 | #define TESTMODE_MIDSCALE_SHORT 0x1 |
| 72 | #define TESTMODE_POS_FULLSCALE 0x2 |
| 73 | #define TESTMODE_NEG_FULLSCALE 0x3 |
| 74 | #define TESTMODE_ALT_CHECKERBOARD 0x4 |
| 75 | #define TESTMODE_PN23_SEQ 0x5 |
| 76 | #define TESTMODE_PN9_SEQ 0x6 |
| 77 | #define TESTMODE_ONE_ZERO_TOGGLE 0x7 |
| 78 | #define TESTMODE_RAMP 0xF |
| 79 | |
| 80 | /* ADC_REG_OUTPUT_MODE */ |
| 81 | #define OUTPUT_MODE_OFFSET_BINARY 0x0 |
| 82 | #define OUTPUT_MODE_TWOS_COMPLEMENT 0x1 |
| 83 | #define OUTPUT_MODE_GRAY_CODE 0x2 |
| 84 | |
| 85 | /* ADC_REG_OUTPUT_PHASE */ |
| 86 | #define OUTPUT_EVEN_ODD_MODE_EN 0x20 |
| 87 | #define INVERT_DCO_CLK 0x80 |
| 88 | |
| 89 | #define AD9434_CHIP_ID 0x6A |
| 90 | #define AD9434_DEF_OUTPUT_MODE 0x00 |
| 91 | |
| 92 | /******************************************************************************/ |
| 93 | /*************************** Types Declarations *******************************/ |
| 94 | /******************************************************************************/ |
| 95 | typedef struct { |
| 96 | spi_device spi_dev; |
| 97 | uint8_t output_mode; |
| 98 | } ad9434_dev; |
| 99 | |
| 100 | typedef struct { |
| 101 | uint8_t spi_chip_select; |
| 102 | spi_mode spi_mode; |
| 103 | spi_type spi_type; |
| 104 | uint32_t spi_device_id; |
| 105 | } ad9434_init_param; |
| 106 | |
| 107 | /******************************************************************************/ |
| 108 | /************************ Functions Declarations ******************************/ |
| 109 | /******************************************************************************/ |
| 110 | int32_t ad9434_testmode_set(ad9434_dev *dev, |
| 111 | uint8_t chan, |
| 112 | uint8_t mode); |
| 113 | int32_t ad9434_setup(ad9434_dev **device, |
| 114 | ad9434_init_param init_param, |
| 115 | adc_core core); |
| 116 | #endif |