| 1 | /**************************************************************************//** |
| 2 | * @file i2c_ps7.h |
| 3 | * @brief ZYNQ Hardware I2C header file. |
| 4 | * @author ATofan ([email protected]) |
| 5 | * |
| 6 | ******************************************************************************* |
| 7 | * Copyright 2011(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 | * SVN Revision: $WCREV$ |
| 42 | ******************************************************************************/ |
| 43 | |
| 44 | #ifndef __I2C_PS7_H__ |
| 45 | #define __I2C_PS7_H__ |
| 46 | |
| 47 | /*****************************************************************************/ |
| 48 | /******************* Include Files *******************************************/ |
| 49 | /*****************************************************************************/ |
| 50 | #include <stdint.h> |
| 51 | #include "xparameters.h" |
| 52 | #include "system_config.h" |
| 53 | |
| 54 | #if(USE_PS7 == 0) |
| 55 | |
| 56 | #define I2C_BASEADDR XPS_I2C1_BASEADDR |
| 57 | |
| 58 | /* ZYNQ Hardware I2C Registers */ |
| 59 | #define HW_I2C_CONTROL_REG 0x00 |
| 60 | #define HW_I2C_STATUS_REG 0x04 |
| 61 | #define HW_I2C_ADDRESS_REG 0x08 |
| 62 | #define HW_I2C_DATA_REG 0x0C |
| 63 | #define HW_I2C_INTR_STATUS_REG 0x10 |
| 64 | #define HW_I2C_TX_SIZE_REG 0x14 |
| 65 | #define HW_I2C_SLAVE_MON_PAUSE_REG 0x18 |
| 66 | #define HW_I2C_TIMEOUT_REG 0x1C |
| 67 | #define HW_I2C_INTR_MSK_REG 0x20 |
| 68 | #define HW_I2C_INTR_EN_REG 0x24 |
| 69 | #define HW_I2C_INTR_DIS_REG 0x28 |
| 70 | |
| 71 | /* ZYNQ Hardware I2C Register Specific Bits */ |
| 72 | // CONTROL REG 0x00 |
| 73 | #define DIV_A 14 |
| 74 | #define DIV_B 8 |
| 75 | #define CLR_FIFO 6 |
| 76 | #define SLVMON 5 |
| 77 | #define HOLD 4 |
| 78 | #define ACK_EN 3 |
| 79 | #define NEA 2 |
| 80 | #define MS 1 |
| 81 | #define RW 0 |
| 82 | // STATUS REG 0x04 |
| 83 | #define BA 8 |
| 84 | #define RXOVF 7 |
| 85 | #define TXDV 6 |
| 86 | #define RXDV 5 |
| 87 | #define RXRW 3 |
| 88 | // ADDRESS REG 0x08 |
| 89 | #define ADD_MSK 0 |
| 90 | // DATA REG 0x0C |
| 91 | #define DATA_MSK 0 |
| 92 | // INTERRUPT STATUS REG 0x10 |
| 93 | #define ARB_LOST 9 |
| 94 | #define RX_UNF 7 |
| 95 | #define TX_OVF 6 |
| 96 | #define RX_OVF 5 |
| 97 | #define SLV_RDY 4 |
| 98 | #define IXR_TO 3 |
| 99 | #define IXR_NACK 2 |
| 100 | #define IXR_DATA 1 |
| 101 | #define IXR_COMP 0 |
| 102 | // TRANSFER SIZE REG 0x14 |
| 103 | #define Transfer_Size 0 |
| 104 | // SLAVE MON PAUSE REG 0x18 |
| 105 | #define Pause_MASK 0 |
| 106 | // TIMEOUT REG 0x1C |
| 107 | #define TO_MASK 0 |
| 108 | // INTERRUPT MASK REG 0x20 - same bits as INTERRUPT STATUS REG |
| 109 | // INTERRUPT ENABLE REG 0x24 - same bits as INTERRUPT STATUS REG |
| 110 | // INTERRUPT DISABLE REG 0x28 - same bits as INTERRUPT STATUS REG |
| 111 | |
| 112 | /*****************************************************************************/ |
| 113 | /************************ Functions Declarations *****************************/ |
| 114 | /*****************************************************************************/ |
| 115 | |
| 116 | uint32_t I2C_Init_ps7(); |
| 117 | uint32_t I2C_Read_ps7(int i2cBaseAddr, uint32_t i2cAddr, uint32_t regAddr, uint32_t rxSize, uint8_t* rxBuf); |
| 118 | uint32_t I2C_Write_ps7(int i2cBaseAddr, uint32_t i2cAddr, uint32_t regAddr, uint32_t txSize, uint8_t* txBuf); |
| 119 | |
| 120 | #endif |
| 121 | |
| 122 | #endif /* __I2C_PS7_H__ */ |