| 1 | /**************************************************************************//** |
| 2 | * @file ad527x.h |
| 3 | * @brief Header file of AD527x Driver for Microblaze processor. |
| 4 | * @author Lucian Sin ([email protected]) |
| 5 | * |
| 6 | ******************************************************************************* |
| 7 | * Copyright 2013(c) Analog Devices, Inc. |
| 8 | * |
| 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without modification, |
| 12 | * are permitted provided that the following conditions are met: |
| 13 | * - Redistributions of source code must retain the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer. |
| 15 | * - Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in |
| 17 | * the documentation and/or other materials provided with the |
| 18 | * distribution. |
| 19 | * - Neither the name of Analog Devices, Inc. nor the names of its |
| 20 | * contributors may be used to endorse or promote products derived |
| 21 | * from this software without specific prior written permission. |
| 22 | * - The use of this software may or may not infringe the patent rights |
| 23 | * of one or more patent holders. This license does not release you |
| 24 | * from the requirement that you obtain separate licenses from these |
| 25 | * patent holders to use this software. |
| 26 | * - Use of the software either in source or binary form, must be run |
| 27 | * on or directly connected to an Analog Devices Inc. component. |
| 28 | * |
| 29 | * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED |
| 30 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY |
| 31 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 32 | * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 33 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 34 | * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 35 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 36 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 37 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 38 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 39 | * |
| 40 | ******************************************************************************/ |
| 41 | |
| 42 | #ifndef _AD527x_H_ |
| 43 | #define _AD527x_H_ |
| 44 | |
| 45 | /******************************************************************************/ |
| 46 | /***************************** Include Files **********************************/ |
| 47 | /******************************************************************************/ |
| 48 | #include "Communication.h" |
| 49 | |
| 50 | /******************************************************************************/ |
| 51 | /******************* Macros and Constants Definitions *************************/ |
| 52 | /******************************************************************************/ |
| 53 | /* Supported devices */ |
| 54 | typedef enum { |
| 55 | ID_AD5270, |
| 56 | ID_AD5271, |
| 57 | ID_AD5272, |
| 58 | ID_AD5274, |
| 59 | } AD527x_type; |
| 60 | |
| 61 | /* AD527x Device I2C Address */ |
| 62 | #define AD527x_I2C_ADDR_0 0x2F // A1=1 and A0=1 (ADDR_Pin=GND) |
| 63 | #define AD527x_I2C_ADDR_1 0x2C // A1=0 and A0=0 (ADDR_Pin=VDD) |
| 64 | #define AD527x_I2C_ADDR_2 0x2E // A1=1 and A0=0 (ADDR_Pin=NC) |
| 65 | |
| 66 | #define MAX_BITS_NUMBER 10 |
| 67 | |
| 68 | /* Commands */ |
| 69 | /* AD527x Commands */ |
| 70 | #define AD527x_NOP 0x00 |
| 71 | #define AD527x_WRITE_RDAC 0x01 |
| 72 | #define AD527x_READ_RDAC 0x02 |
| 73 | #define AD527x_STORE_RDAC_50TP 0x03 |
| 74 | #define AD527x_RESET 0x04 |
| 75 | #define AD527x_READ_CONTENT_50TP 0x05 |
| 76 | #define AD527x_READ_ADDRESS_50TP 0x06 |
| 77 | #define AD527x_WRITE_CONTROL 0x07 |
| 78 | #define AD527x_READ_CONTROL 0x08 |
| 79 | #define AD527x_SHUTDOWN 0x09 |
| 80 | |
| 81 | /* AD527x Control Register Bits */ |
| 82 | #define AD527x_C3 (1 << 3) |
| 83 | #define AD527x_C2 (1 << 2) |
| 84 | #define AD527x_C1 (1 << 1) |
| 85 | #define AD527x_C0 (1 << 0) |
| 86 | |
| 87 | /* AD527x GPIO */ |
| 88 | /* RESET - GPIO1 */ |
| 89 | #define AD527x_RESET_OUT GPIO1_PIN_OUT |
| 90 | #define AD527x_RESET_LOW GPIO1_LOW |
| 91 | #define AD527x_RESET_HIGH GPIO1_HIGH |
| 92 | |
| 93 | #define AD527x_SLAVE_ID 1 |
| 94 | |
| 95 | /******************************************************************************/ |
| 96 | /************************ Functions Declarations ******************************/ |
| 97 | /******************************************************************************/ |
| 98 | |
| 99 | /* Initializes the communication with the device. */ |
| 100 | char AD527x_Init(unsigned char devAddr, AD527x_type device); |
| 101 | |
| 102 | /* Writes data to AD527x. */ |
| 103 | void AD527x_SetRegister(unsigned char command, unsigned short data); |
| 104 | |
| 105 | /* Reads data from AD527x. */ |
| 106 | unsigned short AD527x_GetRegister(unsigned char command, unsigned char memReg50TP); |
| 107 | |
| 108 | #endif /* AD527x_H_ */ |