Petaluma (MAXREFDES30#) Code Documentation  V01.00
16-Bit, 8-Ch, +/-10V input, Simultaneous-Sampling Analog Front End
 All Data Structures Files Functions Variables Macros Pages
axi_max11046.c
Go to the documentation of this file.
1 
28 /*
29  * Copyright (C) 2012 Maxim Integrated Products, Inc., All Rights Reserved.
30  *
31  * Permission is hereby granted, free of charge, to any person obtaining a
32  * copy of this software and associated documentation files (the "Software"),
33  * to deal in the Software without restriction, including without limitation
34  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
35  * and/or sell copies of the Software, and to permit persons to whom the
36  * Software is furnished to do so, subject to the following conditions:
37  *
38  * The above copyright notice and this permission notice shall be included
39  * in all copies or substantial portions of the Software.
40  *
41  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
42  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
43  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
44  * IN NO EVENT SHALL MAXIM INTEGRATED PRODUCTS BE LIABLE FOR ANY CLAIM, DAMAGES
45  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
46  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
47  * OTHER DEALINGS IN THE SOFTWARE.
48  *
49  * Except as contained in this notice, the name of Maxim Integrated Products
50  * shall not be used except as stated in the Maxim Integrated Products
51  * Branding Policy.
52  *
53  * The mere transfer of this software does not imply any licenses
54  * of trade secrets, proprietary technology, copyrights, patents,
55  * trademarks, maskwork rights, or any other form of intellectual
56  * property whatsoever. Maxim Integrated Products retains all ownership rights.
57  *
58  ***************************************************************************/
59 
60 /***************************** Include Files *******************************/
61 
62 #include "axi_max11046.h"
63 
64 /************************** Function Definitions ***************************/
65 
66 void AXI_MAX11046_Config_ADC(u32 BaseAddress, u32 Value)
76 {
77  Xil_Out32((BaseAddress) + (AXI_MAX11046_CR_REG_OFFSET), Value);
78  Xil_Out32((BaseAddress) + (AXI_MAX11046_WRITE_CR_REG_OFFSET), (u32)(1));
79 }
80 
81 void AXI_MAX11046_Start_Conversion(u32 BaseAddress)
92 {
93  Xil_Out32((BaseAddress) + (AXI_MAX11046_ADC_START_REG_OFFSET), (u32)(1));
94 }
95 
96 void AXI_MAX11046_Stop_Conversion(u32 BaseAddress)
107 {
108  Xil_Out32((BaseAddress) + (AXI_MAX11046_ADC_START_REG_OFFSET), (u32)(0));
109 }
110 
111 void AXI_MAX11046_Write_Delay_Reg(u32 BaseAddress, u32 Value)
125 {
126  Xil_Out32((BaseAddress) + (AXI_MAX11046_DELAY_REG_OFFSET), (u32)(Value));
127 }
128 
129 void AXI_MAX11046_Interrupt_Enable(u32 BaseAddress)
142 {
143  Xil_Out32((BaseAddress) + (AXI_MAX11046_IP_INTR_ENABLE_REG_OFFSET), (u32)(1));
144 }
145 
146 void AXI_MAX11046_Interrupt_Disable(u32 BaseAddress)
157 {
158  Xil_Out32((BaseAddress) + (AXI_MAX11046_IP_INTR_ENABLE_REG_OFFSET), (u32)(0));
159 }
160 
161 u32 AXI_MAX11046_Read_Data(u32 BaseAddress, u8 Channel)
173 {
174  return Xil_In32((BaseAddress) + 0x00000004*Channel);
175 }
176 
190 {
191  return Xil_In32((BaseAddress) + (AXI_MAX11046_IP_INTR_STATUS_REG_OFFSET));
192 }
193 
194 void AXI_MAX11046_Single_Convert(u32 BaseAddress, u8 Channel, u16 * uSample)
204 {
205  AXI_MAX11046_Stop_Conversion(BaseAddress);
206  AXI_MAX11046_Interrupt_Disable(BaseAddress);
208  AXI_MAX11046_Start_Conversion(BaseAddress);
209 
210  while(AXI_MAX11046_Read_Interrupt_Status(BaseAddress)==0);
211  AXI_MAX11046_Stop_Conversion(BaseAddress);
213 
214  if(Channel<8)
215  uSample[0]=AXI_MAX11046_Read_Data(BaseAddress, Channel);
216  else
217  {
218  uSample[0]=AXI_MAX11046_Read_Data(BaseAddress, 0);
219  uSample[1]=AXI_MAX11046_Read_Data(BaseAddress, 1);
220  uSample[2]=AXI_MAX11046_Read_Data(BaseAddress, 2);
221  uSample[3]=AXI_MAX11046_Read_Data(BaseAddress, 3);
222  uSample[4]=AXI_MAX11046_Read_Data(BaseAddress, 4);
223  uSample[5]=AXI_MAX11046_Read_Data(BaseAddress, 5);
224  uSample[6]=AXI_MAX11046_Read_Data(BaseAddress, 6);
225  uSample[7]=AXI_MAX11046_Read_Data(BaseAddress, 7);
226  }
227 }