| 1 | /**************************************************************************//** |
| 2 | * @file ad5110.h |
| 3 | * @brief Header file of ad5110 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 | #ifndef _ad5110_H_ |
| 42 | #define _ad5110_H_ |
| 43 | |
| 44 | /******************************************************************************/ |
| 45 | /***************************** Include Files **********************************/ |
| 46 | /******************************************************************************/ |
| 47 | #include "xil_types.h" |
| 48 | #include "xparameters.h" |
| 49 | |
| 50 | /******************************************************************************/ |
| 51 | /******************* Macros and Constants Definitions *************************/ |
| 52 | /******************************************************************************/ |
| 53 | /*!< ad5110 Device Address */ |
| 54 | #define ad5110_I2C_ADDR 0x2F |
| 55 | #define ad5110_1_I2C_ADDR 0x2C |
| 56 | |
| 57 | /******************************************************************************/ |
| 58 | /************************* Input shift register *******************************/ |
| 59 | /******************************************************************************/ |
| 60 | |
| 61 | /*!< Command position in transmitted bytes */ |
| 62 | #define COMMAND 8 |
| 63 | /*!< Available Commands */ |
| 64 | #define CMD_NOP 0 |
| 65 | #define CMD_WR_RDAC_EEPROM 1 |
| 66 | #define CMD_WR_RDAC 2 |
| 67 | #define CMD_SHUT_DOWN 3 |
| 68 | #define CMD_RESET 4 |
| 69 | #define CMD_RD_RDAC 5 |
| 70 | #define CMD_RD_EEPROM 6 |
| 71 | /*!< Shutdown modes */ |
| 72 | #define SHUT_DOWN_OFF 0 |
| 73 | #define SHUT_DOWN_ON 1 |
| 74 | /*!< Read modes */ |
| 75 | #define WIPER_POSITION 0 |
| 76 | #define RESISTOR_TOLERANCE 1 |
| 77 | |
| 78 | /******************************************************************************/ |
| 79 | /************************ Functions Declarations ******************************/ |
| 80 | /******************************************************************************/ |
| 81 | |
| 82 | /*!< Initializes the communication with the device. */ |
| 83 | char ad5110_Init(unsigned char devAddr); |
| 84 | |
| 85 | /*!< Write the content of serial register data to RDAC. */ |
| 86 | void ad5110_WriteRdac(unsigned char rdacValue); |
| 87 | |
| 88 | /*!< Read the content of RDAC register. */ |
| 89 | unsigned char ad5110_ReadRdac(void); |
| 90 | |
| 91 | /*!< Write the content of RDAC register to EEPROM. */ |
| 92 | void ad5110_WriteRdacEeprom(void); |
| 93 | |
| 94 | /*!< Read wiper position from EEPROM. */ |
| 95 | unsigned char ad5110_ReadWiper(void); |
| 96 | |
| 97 | /*!< Read resistor tolerance from EEPROM. */ |
| 98 | unsigned char ad5110_ReadResTolerance(void); |
| 99 | |
| 100 | /*!< Software reset; makes a refresh of RDAC register with EEPROM. */ |
| 101 | void ad5110_Reset(void); |
| 102 | |
| 103 | /*!< Software shutdown. */ |
| 104 | void ad5110_ShutDown(unsigned char value); |
| 105 | |
| 106 | #endif // _ad5110_H_ |