<tr><tdclass="memItemLeft"align="right"valign="top">int </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="xiic_8c.html#ad944f42c3d9972fc2c986a7eed726297">XIic_SetAddress</a> (<aclass="el"href="struct_x_iic.html">XIic</a> *InstancePtr, int AddressType, int Address)</td></tr>
<tr><tdclass="memItemLeft"align="right"valign="top">u16 </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="xiic_8c.html#a3e8f77e5df8d92a4b27627e03b5e1807">XIic_GetAddress</a> (<aclass="el"href="struct_x_iic.html">XIic</a> *InstancePtr, int AddressType)</td></tr>
<p>Contains required functions for the <aclass="el"href="struct_x_iic.html">XIic</a> component. See <aclass="el"href="xiic_8h.html">xiic.h</a> for more information on the driver.</p>
2.07a adk 18/04/13 Updated the code to avoid unused variable warnings
when compiling with the -Wextra -Wall flags.
Changes done if files <aclass="el"href="xiic_8c.html">xiic.c</a> and <aclass="el"href="xiic__i_8h.html">xiic_i.h</a>. CR:705001.</pre><pre></pre><hr/><h2>Function Documentation</h2>
<li>Initialize the driver to allow access to the device registers and initialize other subcomponents necessary for the operation of the device.</li>
<li>Default options to:<ul>
<li>7-bit slave addressing</li>
<li>Send messages as a slave device</li>
<li>Repeated start off</li>
<li>General call recognition disabled</li>
</ul>
</li>
<li>Clear messageing and error statistics</li>
</ul>
<p>The <aclass="el"href="xiic_8c.html#a5f4e497710a9c3719f27d40faa74a10f">XIic_Start()</a> function must be called after this function before the device is ready to send and receive data on the IIC bus.</p>
<p>Before <aclass="el"href="xiic_8c.html#a5f4e497710a9c3719f27d40faa74a10f">XIic_Start()</a> is called, the interrupt control must connect the ISR routine to the interrupt handler. This is done by the user, and not <aclass="el"href="xiic_8c.html#a5f4e497710a9c3719f27d40faa74a10f">XIic_Start()</a> to allow the user to use an interrupt controller of their choice.</p>
<tr><tdvalign="top"></td><tdvalign="top"><em>InstancePtr</em> </td><td>is a pointer to the <aclass="el"href="struct_x_iic.html">XIic</a> instance to be worked on. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>Config</em> </td><td>is a reference to a structure containing information about a specific IIC device. This function can initialize multiple instance objects with the use of multiple calls giving different Config information on each call. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>EffectiveAddr</em> </td><td>is the device base address in the virtual memory address space. The caller is responsible for keeping the address mapping from EffectiveAddr to the device physical base address unchanged once this function is invoked. Unexpected errors may occur if the address mapping changes after this function is called. If address translation is not used, use Config->BaseAddress for this parameters, passing the physical address instead.</td></tr>
<li>XST_DEVICE_IS_STARTED indicates the device is started (i.e. interrupts enabled and messaging is possible). Must stop before re-initialization is allowed.</li>
<p>This function gets the addresses for the IIC device driver. The addresses include the device address that the device responds to as a slave, or the slave address to communicate with on the bus. The address returned has the same format whether 7 or 10 bits.</p>
<tr><tdvalign="top"></td><tdvalign="top"><em>InstancePtr</em> </td><td>is a pointer to the <aclass="el"href="struct_x_iic.html">XIic</a> instance to be worked on. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>AddressType</em> </td><td>indicates which address, the address which this responds to on the IIC bus as a slave, or the slave address to communicate with when this device is a master. One of the following values must be contained in this argument. </p>
<p>This function gets the contents of the General Purpose Output register for the IIC device driver. Note that the number of bits in this register is parameterizable in the hardware such that it may not exist. This function checks to ensure that it does exist to prevent bus errors.</p>
<tr><tdvalign="top"></td><tdvalign="top"><em>InstancePtr</em> </td><td>is a pointer to the <aclass="el"href="struct_x_iic.html">XIic</a> instance to be worked on. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>OutputValuePtr</em> </td><td>contains the value which was read from the register.</td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>InstancePtr</em> </td><td>is a pointer to the <aclass="el"href="struct_x_iic.html">XIic</a> instance to be worked on.</td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>InstancePtr</em> </td><td>is a pointer to the <aclass="el"href="struct_x_iic.html">XIic</a> instance to be worked on.</td></tr>
<dlclass="note"><dt><b>Note:</b></dt><dd>The complete IIC core is Reset on giving a software reset to the IIC core. Some previous versions of the core only reset the Interrupt Logic/Registers, please refer to the HW specification for futher details about this. </dd></dl>
</div>
</div>
<aclass="anchor"id="ad944f42c3d9972fc2c986a7eed726297"></a><!-- doxytag: member="xiic.c::XIic_SetAddress" ref="ad944f42c3d9972fc2c986a7eed726297" args="(XIic *InstancePtr, int AddressType, int Address)" -->
<p>This function sets the bus addresses. The addresses include the device address that the device responds to as a slave, or the slave address to communicate with on the bus. The IIC device hardware is built to allow either 7 or 10 bit slave addressing only at build time rather than at run time. When this device is a master, slave addressing can be selected at run time to match addressing modes for other bus devices.</p>
<p>Addresses are represented as hex values with no adjustment for the data direction bit as the software manages address bit placement. Example: For a 7 address written to the device of 1010 011X where X is the transfer direction (send/recv), the address parameter for this function needs to be 01010011 or 0x53 where the correct bit alllignment will be handled for 7 as well as 10 bit devices. This is especially important as the bit placement is not handled the same depending on which options are used such as repeated start.</p>
<tr><tdvalign="top"></td><tdvalign="top"><em>InstancePtr</em> </td><td>is a pointer to the <aclass="el"href="struct_x_iic.html">XIic</a> instance to be worked on. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>AddressType</em> </td><td>indicates which address is being modified, the address which this device responds to on the IIC bus as a slave, or the slave address to communicate with when this device is a master. One of the following values must be contained in this argument. </p>
XII_ADDR_TO_SEND_TYPE Slave being addressed by a this master
XII_ADDR_TO_RESPOND_TYPE Address to respond to as a slave device
</pre></td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>Address</em> </td><td>contains the address to be set, 7 bit or 10 bit address. A ten bit address must be within the range: 0 - 1023 and a 7 bit address must be within the range 0 - 127.</td></tr>
<p>This function sets the contents of the General Purpose Output register for the IIC device driver. Note that the number of bits in this register is parameterizable in the hardware such that it may not exist. This function checks to ensure that it does exist to prevent bus errors, but does not ensure that the number of bits in the register are sufficient for the value being written (won't cause a bus error).</p>
<tr><tdvalign="top"></td><tdvalign="top"><em>InstancePtr</em> </td><td>is a pointer to the <aclass="el"href="struct_x_iic.html">XIic</a> instance to be worked on. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>OutputValue</em> </td><td>contains the value to be written to the register.</td></tr>
<p>Sets the receive callback function, the receive handler, which the driver calls when it finishes receiving data. The number of bytes used to signal when the receive is complete is the number of bytes set in the XIic_Recv function.</p>
<p>The handler executes in an interrupt context such that it must minimize the amount of processing performed such as transferring data to a thread context.</p>
<p>The number of bytes received is passed to the handler as an argument.</p>
<tr><tdvalign="top"></td><tdvalign="top"><em>InstancePtr</em> </td><td>is a pointer to the <aclass="el"href="struct_x_iic.html">XIic</a> instance to be worked on. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>CallBackRef</em> </td><td>is the upper layer callback reference passed back when the callback function is invoked. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>FuncPtr</em> </td><td>is the pointer to the callback function.</td></tr>
<p>Sets the send callback function, the send handler, which the driver calls when it receives confirmation of sent data. The handler executes in an interrupt context such that it must minimize the amount of processing performed such as transferring data to a thread context.</p>
<tr><tdvalign="top"></td><tdvalign="top"><em>InstancePtr</em> </td><td>the pointer to the <aclass="el"href="struct_x_iic.html">XIic</a> instance to be worked on. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>CallBackRef</em> </td><td>the upper layer callback reference passed back when the callback function is invoked. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>FuncPtr</em> </td><td>the pointer to the callback function.</td></tr>
<p>Sets the status callback function, the status handler, which the driver calls when it encounters conditions which are not data related. The handler executes in an interrupt context such that it must minimize the amount of processing performed such as transferring data to a thread context. The status events that can be returned are described in <aclass="el"href="xiic_8h.html">xiic.h</a>.</p>
<tr><tdvalign="top"></td><tdvalign="top"><em>InstancePtr</em> </td><td>points to the <aclass="el"href="struct_x_iic.html">XIic</a> instance to be worked on. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>CallBackRef</em> </td><td>is the upper layer callback reference passed back when the callback function is invoked. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>FuncPtr</em> </td><td>is the pointer to the callback function.</td></tr>
<p>This function starts the IIC device and driver by enabling the proper interrupts such that data may be sent and received on the IIC bus. This function must be called before the functions to send and receive data.</p>
<p>Before <aclass="el"href="xiic_8c.html#a5f4e497710a9c3719f27d40faa74a10f">XIic_Start()</a> is called, the interrupt control must connect the ISR routine to the interrupt handler. This is done by the user, and not <aclass="el"href="xiic_8c.html#a5f4e497710a9c3719f27d40faa74a10f">XIic_Start()</a> to allow the user to use an interrupt controller of their choice.</p>
<p>Start enables:</p>
<ul>
<li>IIC device</li>
<li>Interrupts:<ul>
<li>Addressed as slave to allow messages from another master</li>
<li>Arbitration Lost to detect Tx arbitration errors</li>
<tr><tdvalign="top"></td><tdvalign="top"><em>InstancePtr</em> </td><td>is a pointer to the <aclass="el"href="struct_x_iic.html">XIic</a> instance to be worked on.</td></tr>
<p>The device interrupt is connected to the interrupt controller, but no "messaging" interrupts are enabled. Addressed as Slave is enabled to reception of messages when this devices address is written to the bus. The correct messaging interrupts are enabled when sending or receiving via the IicSend() and IicRecv() functions. No action is required by the user to control any IIC interrupts as the driver completely manages all 8 interrupts. Start and Stop control the ability to use the device. Stopping the device completely stops all device interrupts from the processor. </p>
<p>This function stops the IIC device and driver such that data is no longer sent or received on the IIC bus. This function stops the device by disabling interrupts. This function only disables interrupts within the device such that the caller is responsible for disconnecting the interrupt handler of the device from the interrupt source and disabling interrupts at other levels.</p>
<p>Due to bus throttling that could hold the bus between messages when using repeated start option, stop will not occur when the device is actively sending or receiving data from the IIC bus or the bus is being throttled by this device, but instead return XST_IIC_BUS_BUSY.</p>
<tr><tdvalign="top"></td><tdvalign="top"><em>InstancePtr</em> </td><td>is a pointer to the <aclass="el"href="struct_x_iic.html">XIic</a> instance to be worked on.</td></tr>
<li>XST_SUCCESS indicates all IIC interrupts are disabled. No messages can be received or transmitted until <aclass="el"href="xiic_8c.html#a5f4e497710a9c3719f27d40faa74a10f">XIic_Start()</a> is called.</li>
<li>XST_IIC_BUS_BUSY indicates this device is currently engaged in message traffic and cannot be stopped.</li>