| 1 | /**************************************************************************//** |
| 2 | * @file eeprom.h |
| 3 | * @brief EEPROM header file. |
| 4 | * @author mhennerich |
| 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 __XCOMM_EEPROM_H___ |
| 45 | #define __XCOMM_EEPROM_H___ |
| 46 | |
| 47 | #include <stdint.h> |
| 48 | |
| 49 | #define IICSEL_FRU_LPC 0x51 |
| 50 | #define IICSEL_CAL_LPC 0x55 |
| 51 | |
| 52 | #define IICSEL_FRU_HPC 0x50 |
| 53 | #define IICSEL_CAL_HPC 0x54 |
| 54 | |
| 55 | #define CURRENT_VERSION 1 |
| 56 | #define MAX_SIZE_CAL_EEPROM 254 |
| 57 | #define FAB_SIZE_CAL_EEPROM 256 |
| 58 | #define NEXT_TERMINATION 0 |
| 59 | |
| 60 | #define ADI_MAGIC_0 'A' |
| 61 | #define ADI_MAGIC_1 'D' |
| 62 | #define ADI_VERSION(v) ('0' + (v)) |
| 63 | |
| 64 | /* Version 0 */ |
| 65 | |
| 66 | #pragma pack(push, 1) // exact fit - no padding |
| 67 | struct fmcomms1_calib_data |
| 68 | { |
| 69 | int8_t adi_magic0; |
| 70 | int8_t adi_magic1; |
| 71 | int8_t version; |
| 72 | uint8_t next; |
| 73 | uint16_t cal_frequency_MHz; |
| 74 | |
| 75 | /* DAC Calibration Data */ |
| 76 | int16_t i_phase_adj; /* 10-bit */ |
| 77 | int16_t q_phase_adj; /* 10-bit */ |
| 78 | uint16_t i_dac_offset; /* 16-bit */ |
| 79 | uint16_t q_dac_offset; /* 16-bit */ |
| 80 | uint16_t i_dac_fs_adj; /* 10-bit */ |
| 81 | uint16_t q_dac_fs_adj; /* 10-bit */ |
| 82 | |
| 83 | /* ADC Calibration Data */ |
| 84 | int16_t i_adc_offset_adj; /* 16-bit signed */ |
| 85 | uint16_t i_adc_gain_adj; /* 16-bit fract 1.15 */ |
| 86 | int16_t q_adc_offset_adj; /* 16-bit signed */ |
| 87 | uint16_t q_adc_gain_adj; /* 16-bit fract 1.15 */ |
| 88 | }; |
| 89 | #pragma pack(pop) //back to whatever the previous packing mode was |
| 90 | |
| 91 | /* Version 1 */ |
| 92 | |
| 93 | #pragma pack(push, 1) // exact fit - no padding |
| 94 | struct fmcomms1_calib_data_v1 { |
| 95 | int8_t adi_magic0; |
| 96 | int8_t adi_magic1; |
| 97 | int8_t version; |
| 98 | uint8_t num_entries; |
| 99 | uint16_t temp_calibbias; |
| 100 | uint16_t cal_frequency_MHz; |
| 101 | |
| 102 | /* DAC Calibration Data */ |
| 103 | int16_t i_phase_adj; /* 10-bit */ |
| 104 | int16_t q_phase_adj; /* 10-bit */ |
| 105 | int16_t i_dac_offset; /* 16-bit */ |
| 106 | int16_t q_dac_offset; /* 16-bit */ |
| 107 | uint16_t i_dac_fs_adj; /* 10-bit */ |
| 108 | uint16_t q_dac_fs_adj; /* 10-bit */ |
| 109 | |
| 110 | /* ADC Calibration Data */ |
| 111 | int16_t i_adc_offset_adj; /* 16-bit signed */ |
| 112 | uint16_t i_adc_gain_adj; /* 16-bit fract 1.1.14 */ |
| 113 | uint16_t i_adc_phase_adj; /* 16-bit fract 1.1.14 */ |
| 114 | int16_t q_adc_offset_adj; /* 16-bit signed */ |
| 115 | uint16_t q_adc_gain_adj; /* 16-bit fract 1.1.14 */ |
| 116 | }; |
| 117 | #pragma pack(pop) //back to whatever the previous packing mode was |
| 118 | |
| 119 | /*****************************************************************************/ |
| 120 | /************************ Functions Declarations *****************************/ |
| 121 | /*****************************************************************************/ |
| 122 | /** Reads data from the selected EEPROM device */ |
| 123 | int32_t EEPROM_Read(uint8_t i2cAddr, uint8_t eepromAddr, |
| 124 | uint8_t* pData, uint16_t size); |
| 125 | /** Write data to the selected EEPROM device */ |
| 126 | int32_t EEPROM_Write(uint8_t i2cAddr, uint8_t eepromAddr, |
| 127 | uint8_t* pData, uint16_t size); |
| 128 | /** Reads the calibration data from the calibration EEPROM */ |
| 129 | int32_t EEPROM_GetCalData(uint8_t* pData, uint8_t* pSize, uint32_t fmcPort); |
| 130 | |
| 131 | #endif /* __XCOMM_EEPROM_H__ */ |