1 /*-----------------------------------------------------------------------------
2 * $Date: 2005/04/11 02:50:21 $
3 * $RCSfile: xiic_options.c,v $
4 *----------------------------------------------------------------------------*/
6 /******************************************************************************
8 * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
9 * SOLELY FOR USE IN DEVELOPING PROGRAMS AND SOLUTIONS FOR
10 * XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION
11 * AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION
12 * OR STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS
13 * IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
14 * AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
15 * FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
16 * WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
17 * IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
18 * REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
19 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE.
22 * (c) Copyright 2002 Xilinx, Inc.
23 * All rights reserved.
25 ******************************************************************************/
26 /*****************************************************************************/
29 * @file xiic_options.c
31 * Contains options functions for the XIic component. This file is not required
32 * unless the functions in this file are called.
35 * MODIFICATION HISTORY:
37 * Ver Who Date Changes
38 * ----- --- ------- -----------------------------------------------
39 * 1.01b jhl 3/26/02 repartioned the driver
42 ****************************************************************************/
44 /***************************** Include Files *******************************/
50 /************************** Constant Definitions ***************************/
52 /**************************** Type Definitions *****************************/
54 /***************** Macros (Inline Functions) Definitions *******************/
56 /************************** Function Prototypes ****************************/
58 /************************** Variable Definitions **************************/
60 /*****************************************************************************/
63 * This function sets the options for the IIC device driver. The options control
64 * how the device behaves relative to the IIC bus. If an option applies to
65 * how messages are sent or received on the IIC bus, it must be set prior to
66 * calling functions which send or receive data.
68 * To set multiple options, the values must be ORed together. To not change
69 * existing options, read/modify/write with the current options using
72 * <b>USAGE EXAMPLE:</b>
74 * Read/modify/write to enable repeated start:
77 * Options = XIic_GetOptions(&Iic);
78 * XIic_SetOptions(&Iic, Options | XII_REPEATED_START_OPTION);
81 * Disabling General Call:
83 * Options = XIic_GetOptions(&Iic);
84 * XIic_SetOptions(&Iic, Options &= ~XII_GENERAL_CALL_OPTION);
87 * @param InstancePtr is a pointer to the XIic instance to be worked on.
89 * @param NewOptions are the options to be set. See xiic.h for a list of
90 * the available options.
98 * Sending or receiving messages with repeated start enabled, and then
99 * disabling repeated start, will not take effect until another master
100 * transaction is completed. i.e. After using repeated start, the bus will
101 * continue to be throttled after repeated start is disabled until a master
102 * transaction occurs allowing the IIC to release the bus.
104 * Options enabled will have a 1 in its appropriate bit position.
106 ****************************************************************************/
108 XIic_SetOptions(XIic * InstancePtr, u32 NewOptions)
112 XASSERT_VOID(InstancePtr != NULL);
114 XIic_mEnterCriticalRegion(InstancePtr->BaseAddress);
116 /* Update the options in the instance and get the contents of the control
117 * register such that the general call option can be modified
119 InstancePtr->Options = NewOptions;
120 CntlReg = XIo_In8(InstancePtr->BaseAddress + XIIC_CR_REG_OFFSET);
122 /* The general call option is the only option that maps directly to
123 * a hardware register feature
125 if (NewOptions & XII_GENERAL_CALL_OPTION) {
126 CntlReg |= XIIC_CR_GENERAL_CALL_MASK;
128 CntlReg &= ~XIIC_CR_GENERAL_CALL_MASK;
131 /* Write the new control register value to the register */
133 XIo_Out8(InstancePtr->BaseAddress + XIIC_CR_REG_OFFSET, CntlReg);
135 XIic_mExitCriticalRegion(InstancePtr->BaseAddress);
138 /*****************************************************************************/
141 * This function gets the current options for the IIC device. Options control
142 * the how the device behaves on the IIC bus. See SetOptions for more information
145 * @param InstancePtr is a pointer to the XIic instance to be worked on.
149 * The options of the IIC device. See xiic.h for a list of available options.
153 * Options enabled will have a 1 in its appropriate bit position.
155 ****************************************************************************/
157 XIic_GetOptions(XIic * InstancePtr)
159 XASSERT_NONVOID(InstancePtr != NULL);
161 return InstancePtr->Options;