| 1 | /**************************************************************************//** |
| 2 | * @file adc_core.h |
| 3 | * @brief ADC core header file. |
| 4 | * @author acozma ([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 __ADC_CORE_H__ |
| 45 | #define __ADC_CORE_H__ |
| 46 | |
| 47 | /*****************************************************************************/ |
| 48 | /******************* Include Files *******************************************/ |
| 49 | /*****************************************************************************/ |
| 50 | #include <stdint.h> |
| 51 | |
| 52 | /*****************************************************************************/ |
| 53 | /******************* ADC Core Registers Definitions *******************************/ |
| 54 | /*****************************************************************************/ |
| 55 | |
| 56 | /* ADC COMMON */ |
| 57 | #define ADC_REG_RSTN 0x0040 |
| 58 | #define ADC_RSTN (1 << 0) |
| 59 | #define ADC_MMCM_RSTN (1 << 1) |
| 60 | |
| 61 | /* ADC CHANNEL */ |
| 62 | #define ADC_REG_CHAN_CNTRL(c) (0x0400 + (c) * 0x40) |
| 63 | #define ADC_PN_SEL (1 << 10) |
| 64 | #define ADC_IQCOR_ENB (1 << 9) |
| 65 | #define ADC_DCFILT_ENB (1 << 8) |
| 66 | #define ADC_FORMAT_SIGNEXT (1 << 6) |
| 67 | #define ADC_FORMAT_TYPE (1 << 5) |
| 68 | #define ADC_FORMAT_ENABLE (1 << 4) |
| 69 | #define ADC_PN23_TYPE (1 << 1) |
| 70 | #define ADC_ENABLE (1 << 0) |
| 71 | |
| 72 | #define ADC_REG_CHAN_STATUS(c) (0x0404 + (c) * 0x40) |
| 73 | #define ADC_PN_ERR (1 << 2) |
| 74 | #define ADC_PN_OOS (1 << 1) |
| 75 | #define ADC_OVER_RANGE (1 << 0) |
| 76 | |
| 77 | #define ADC_REG_CHAN_CNTRL_2(c) (0x0414 + (c) * 0x40) |
| 78 | #define ADC_IQCOR_COEFF_1(x) (((x) & 0xFFFF) << 16) |
| 79 | #define ADC_TO_IQCOR_COEFF_1(x) (((x) >> 16) & 0xFFFF) |
| 80 | #define ADC_IQCOR_COEFF_2(x) (((x) & 0xFFFF) << 0) |
| 81 | #define ADC_TO_IQCOR_COEFF_2(x) (((x) >> 0) & 0xFFFF) |
| 82 | |
| 83 | #define ADI_REG_CHAN_CNTRL_3(c) (0x0418 + (c) * 0x40) /* v8.0 */ |
| 84 | #define ADI_ADC_PN_SEL(x) (((x) & 0xF) << 16) |
| 85 | |
| 86 | enum adc_pn_sel { |
| 87 | ADC_PN9 = 0, |
| 88 | ADC_PN23A = 1, |
| 89 | ADC_PN7 = 4, |
| 90 | ADC_PN15 = 5, |
| 91 | ADC_PN23 = 6, |
| 92 | ADC_PN31 = 7, |
| 93 | ADC_PN_CUSTOM = 9, |
| 94 | ADC_PN_END = 10, |
| 95 | }; |
| 96 | |
| 97 | #define PCORE_VERSION_MAJOR(version) (version >> 16) |
| 98 | |
| 99 | /*****************************************************************************/ |
| 100 | /************************ Functions Declarations *****************************/ |
| 101 | /*****************************************************************************/ |
| 102 | |
| 103 | /** Initializes the ADC Core */ |
| 104 | void ADC_Core_Init(uint32_t fmcPort); |
| 105 | /** Reads ADC Core Register. */ |
| 106 | void ADC_Core_Read(uint32_t regAddr, uint32_t *data); |
| 107 | /** Writes ADC Core Register. */ |
| 108 | void ADC_Core_Write(uint32_t regAddr, uint32_t data); |
| 109 | |
| 110 | #endif /* __ADC_CORE_H__ */ |