| 1 | /**************************************************************************//** |
| 2 | * @file dac_core.c |
| 3 | * @brief DAC core functions implementation. |
| 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 | /*****************************************************************************/ |
| 45 | /***************************** Include Files *********************************/ |
| 46 | /*****************************************************************************/ |
| 47 | #include "dac_core.h" |
| 48 | #include "xparameters.h" |
| 49 | #include "xil_io.h" |
| 50 | #include "test.h" |
| 51 | |
| 52 | /*****************************************************************************/ |
| 53 | /************************ Variables Definitions ******************************/ |
| 54 | /*****************************************************************************/ |
| 55 | static uint32_t dacCoreAxiAddr; |
| 56 | |
| 57 | /**************************************************************************//** |
| 58 | * @brief Initializes the DAC Core. |
| 59 | * |
| 60 | * @param fmcPort - Set to 0 for LPC, set to 1 for HPC |
| 61 | ******************************************************************************/ |
| 62 | void DAC_Core_Init(uint32_t fmcPort) |
| 63 | { |
| 64 | #ifdef XPAR_AXI_DAC_4D_2C_1_BASEADDR |
| 65 | dacCoreAxiAddr = fmcPort == 0 ? CFAD9122_0_BASEADDR : CFAD9122_1_BASEADDR; |
| 66 | #else |
| 67 | dacCoreAxiAddr = CFAD9122_0_BASEADDR; |
| 68 | #endif |
| 69 | } |
| 70 | |
| 71 | /**************************************************************************//** |
| 72 | * @brief Reads data from the DAC Core. |
| 73 | * |
| 74 | * @param regAddr - Address of the DAC Core register to be read. |
| 75 | * @param data - Buffer to store the register content. |
| 76 | ******************************************************************************/ |
| 77 | void DAC_Core_Read(uint32_t regAddr, uint32_t *data) |
| 78 | { |
| 79 | *data = Xil_In32(dacCoreAxiAddr + 0x4000 + regAddr); |
| 80 | } |
| 81 | |
| 82 | /**************************************************************************//** |
| 83 | * @brief Writes data to the DAC Core. |
| 84 | * |
| 85 | * @param regAddr - Address of the DAC Core register to be written. |
| 86 | * @param data - Buffer to store the register content to be transmitted. |
| 87 | ******************************************************************************/ |
| 88 | void DAC_Core_Write(uint32_t regAddr, uint32_t data) |
| 89 | { |
| 90 | Xil_Out32(dacCoreAxiAddr + 0x4000 + regAddr, data); |
| 91 | } |