embeddedsw/XilinxProcessorIPLib/drivers/gpio/doc/html/api/xgpio_8c.html

278 lines
15 KiB
HTML
Raw Normal View History

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>
Xilinx Driver gpio v4_0: xgpio.c File Reference
</title>
<link href="doxygen_kalyanidocs/doc/css/driver_api_doxygen.css" rel="stylesheet" type="text/css">
</head>
<h3 class="PageHeader">Xilinx Processor IP Library</h3>
<hl>Software Drivers</hl>
<hr class="whs1">
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>xgpio.c File Reference</h1><code>#include &quot;<a class="el" href="xgpio_8h.html">xgpio.h</a>&quot;</code><br/>
<code>#include &quot;xstatus.h&quot;</code><br/>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xgpio_8c.html#a0e136b38b58ea4e7f299484b0d0beddc">XGpio_CfgInitialize</a> (<a class="el" href="struct_x_gpio.html">XGpio</a> *InstancePtr, <a class="el" href="struct_x_gpio___config.html">XGpio_Config</a> *Config, u32 EffectiveAddr)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xgpio_8c.html#abee6bcad28382ef5ecd336887647c238">XGpio_SetDataDirection</a> (<a class="el" href="struct_x_gpio.html">XGpio</a> *InstancePtr, unsigned Channel, u32 DirectionMask)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">u32&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xgpio_8c.html#a77090853c15dc3d72e2bfbc66e635ada">XGpio_GetDataDirection</a> (<a class="el" href="struct_x_gpio.html">XGpio</a> *InstancePtr, unsigned Channel)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">u32&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xgpio_8c.html#aed95c58f21d567fca624f9f51cb25e20">XGpio_DiscreteRead</a> (<a class="el" href="struct_x_gpio.html">XGpio</a> *InstancePtr, unsigned Channel)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xgpio_8c.html#ab6965e5986a770e5e9d62d0ea4e56636">XGpio_DiscreteWrite</a> (<a class="el" href="struct_x_gpio.html">XGpio</a> *InstancePtr, unsigned Channel, u32 Data)</td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>The implementation of the <a class="el" href="struct_x_gpio.html">XGpio</a> driver's basic functionality. See <a class="el" href="xgpio_8h.html">xgpio.h</a> for more information about the driver.</p>
<dl class="note"><dt><b>Note:</b></dt><dd></dd></dl>
<p>None</p>
<pre>
MODIFICATION HISTORY:</pre><pre> Ver Who Date Changes
----- ---- -------- -----------------------------------------------
1.00a rmm 02/04/02 First release
2.00a jhl 12/16/02 Update for dual channel and interrupt support
2.01a jvb 12/13/05 Changed Initialize() into CfgInitialize(), and made
CfgInitialize() take a pointer to a config structure
instead of a device id. Moved Initialize() into
<a class="el" href="xgpio__sinit_8c.html">xgpio_sinit.c</a>, and had Initialize() call CfgInitialize()
after it retrieved the config structure using the device
id. Removed include of xparameters.h along with any
dependencies on xparameters.h and the _g.c config table.
2.11a mta 03/21/07 Updated to new coding style, added GetDataDirection
2.12a sv 11/21/07 Updated driver to support access through DCR bus
3.00a sv 11/21/09 Updated to use HAL Processor APIs. Renamed the
macros to remove _m from the name.
</pre> <hr/><h2>Function Documentation</h2>
<a class="anchor" id="a0e136b38b58ea4e7f299484b0d0beddc"></a><!-- doxytag: member="xgpio.c::XGpio_CfgInitialize" ref="a0e136b38b58ea4e7f299484b0d0beddc" args="(XGpio *InstancePtr, XGpio_Config *Config, u32 EffectiveAddr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int XGpio_CfgInitialize </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_x_gpio.html">XGpio</a> *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="struct_x_gpio___config.html">XGpio_Config</a> *&nbsp;</td>
<td class="paramname"> <em>Config</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">u32&nbsp;</td>
<td class="paramname"> <em>EffectiveAddr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Initialize the <a class="el" href="struct_x_gpio.html">XGpio</a> instance provided by the caller based on the given configuration data.</p>
<p>Nothing is done except to initialize the InstancePtr.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to an <a class="el" href="struct_x_gpio.html">XGpio</a> instance. The memory the pointer references must be pre-allocated by the caller. Further calls to manipulate the driver through the <a class="el" href="struct_x_gpio.html">XGpio</a> API must be made with this pointer. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>Config</em>&nbsp;</td><td>is a reference to a structure containing information about a specific GPIO device. This function initializes an InstancePtr object for a specific device specified by the contents of Config. This function can initialize multiple instance objects with the use of multiple calls giving different Config information on each call. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>EffectiveAddr</em>&nbsp;</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-&gt;BaseAddress for this parameters, passing the physical address instead.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd><ul>
<li>XST_SUCCESS Initialization was successfull.</li>
</ul>
</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd>None. </dd></dl>
</div>
</div>
<a class="anchor" id="aed95c58f21d567fca624f9f51cb25e20"></a><!-- doxytag: member="xgpio.c::XGpio_DiscreteRead" ref="aed95c58f21d567fca624f9f51cb25e20" args="(XGpio *InstancePtr, unsigned Channel)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">u32 XGpio_DiscreteRead </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_x_gpio.html">XGpio</a> *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned&nbsp;</td>
<td class="paramname"> <em>Channel</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Read state of discretes for the specified GPIO channnel.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to an <a class="el" href="struct_x_gpio.html">XGpio</a> instance to be worked on. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>Channel</em>&nbsp;</td><td>contains the channel of the GPIO (1 or 2) to operate on.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Current copy of the discretes register.</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd>The hardware must be built for dual channels if this function is used with any channel other than 1. If it is not, this function will assert. </dd></dl>
</div>
</div>
<a class="anchor" id="ab6965e5986a770e5e9d62d0ea4e56636"></a><!-- doxytag: member="xgpio.c::XGpio_DiscreteWrite" ref="ab6965e5986a770e5e9d62d0ea4e56636" args="(XGpio *InstancePtr, unsigned Channel, u32 Data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void XGpio_DiscreteWrite </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_x_gpio.html">XGpio</a> *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned&nbsp;</td>
<td class="paramname"> <em>Channel</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">u32&nbsp;</td>
<td class="paramname"> <em>Data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Write to discretes register for the specified GPIO channel.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to an <a class="el" href="struct_x_gpio.html">XGpio</a> instance to be worked on. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>Channel</em>&nbsp;</td><td>contains the channel of the GPIO (1 or 2) to operate on. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>Data</em>&nbsp;</td><td>is the value to be written to the discretes register.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>None.</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd>The hardware must be built for dual channels if this function is used with any channel other than 1. If it is not, this function will assert. See also <a class="el" href="xgpio_8h.html#a8f2cea7ef78412c03c7ebdba87b7cdd4">XGpio_DiscreteSet()</a> and <a class="el" href="xgpio_8h.html#ae430718af9f347c91be42aad580b216c">XGpio_DiscreteClear()</a>. </dd></dl>
</div>
</div>
<a class="anchor" id="a77090853c15dc3d72e2bfbc66e635ada"></a><!-- doxytag: member="xgpio.c::XGpio_GetDataDirection" ref="a77090853c15dc3d72e2bfbc66e635ada" args="(XGpio *InstancePtr, unsigned Channel)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">u32 XGpio_GetDataDirection </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_x_gpio.html">XGpio</a> *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned&nbsp;</td>
<td class="paramname"> <em>Channel</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Get the input/output direction of all discrete signals for the specified GPIO channel.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to an <a class="el" href="struct_x_gpio.html">XGpio</a> instance to be worked on. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>Channel</em>&nbsp;</td><td>contains the channel of the GPIO (1 or 2) to operate on.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Bitmask specifying which discretes are input and which are output. Bits set to 0 are output and bits set to 1 are input.</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd></dd></dl>
<p>The hardware must be built for dual channels if this function is used with any channel other than 1. If it is not, this function will assert. </p>
</div>
</div>
<a class="anchor" id="abee6bcad28382ef5ecd336887647c238"></a><!-- doxytag: member="xgpio.c::XGpio_SetDataDirection" ref="abee6bcad28382ef5ecd336887647c238" args="(XGpio *InstancePtr, unsigned Channel, u32 DirectionMask)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void XGpio_SetDataDirection </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_x_gpio.html">XGpio</a> *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned&nbsp;</td>
<td class="paramname"> <em>Channel</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">u32&nbsp;</td>
<td class="paramname"> <em>DirectionMask</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Set the input/output direction of all discrete signals for the specified GPIO channel.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to an <a class="el" href="struct_x_gpio.html">XGpio</a> instance to be worked on. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>Channel</em>&nbsp;</td><td>contains the channel of the GPIO (1 or 2) to operate on. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>DirectionMask</em>&nbsp;</td><td>is a bitmask specifying which discretes are input and which are output. Bits set to 0 are output and bits set to 1 are input.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>None.</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd>The hardware must be built for dual channels if this function is used with any channel other than 1. If it is not, this function will assert. </dd></dl>
</div>
</div>
</div>
<p class="Copyright">
Copyright &copy; 1995-2014 Xilinx, Inc. All rights reserved.
</p>
</body>
</html>