⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c-periph.html

📁 linux2.4.20下的针对三星公司的s3c2410的usb模块驱动代码
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<dd><font color="0000a0"><pre class="Code"><a name="87392"></a>typedef struct usb_targ_callback_table &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;/* device management callbacks */  &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_MANAGEMENT_FUNC mngmtFunc;  &nbsp;&nbsp;&nbsp;&nbsp;/* Control pipe callbacks */  &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_FEATURE_CLEAR_FUNC featureClear; &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_FEATURE_SET_FUNC featureSet; &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_CONFIGURATION_GET_FUNC configurationGet; &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_CONFIGURATION_SET_FUNC configurationSet; &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_DESCRIPTOR_GET_FUNC descriptorGet; &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_DESCRIPTOR_SET_FUNC descriptorSet; &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_INTERFACE_GET_FUNC interfaceGet; &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_INTERFACE_SET_FUNC interfaceSet; &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_STATUS_GET_FUNC statusGet; &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_ADDRESS_SET_FUNC addressSet; &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_SYNCH_FRAME_GET_FUNC synchFrameGet; &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_VENDOR_SPECIFIC_FUNC vendorSpecific;  &nbsp;&nbsp;&nbsp;&nbsp;} USB_TARG_CALLBACK_TABLE, *pUSB_TARG_CALLBACK_TABLE; </pre></font></dl><dl class="margin"><dd><p class="Body"><a name="87393"></a>Before calling the <b class="routine">usbTargTcdAttach</b><b>(&nbsp;)</b> routine, the function pointers in this table should be set to point to corresponding entry points in the target application. As soon as <b class="routine">usbTargTcdAttach</b><b>(&nbsp;)</b> is called, <b class="library">usbTargLib</b> begins making asynchronous calls to the entry points in the callback table. (Some callbacks are immediate and occur during the attach process itself; others happen in response to activity on the USB.) The target application should provide pointers for each function whose requests need software processing. The <b class="library">usbTargLib</b> driver provides default handling for any functions whose corresponding entry in the callback table is NULL.</p><dd><p class="Body"><a name="87394"></a>The prototypes for each of these callbacks are defined in <b class="file">usbTargLib.h</b>. Two parameters are common to each of the callback functions:</p></dl><dl class="margin"><dd><font color="0000a0"><pre class="Code"><a name="87395"></a>&nbsp;&nbsp;&nbsp;&nbsp;pVOID param &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_CHANNEL targChannel </pre></font></dl><dl class="margin"><dd><div class="Item"><a name="87396"></a><i class="textVariable">param</i> </div><dl class="margin"><dd><div class="Follow"><a name="87397"></a>The application-defined parameter originally passed to <b class="library">usbTargLib</b> as part of the <b class="routine">usbTargTcdAttach</b><b>(&nbsp;)</b> function. Its value is not interpreted by <b class="library">usbTargLib</b>, and it can take on any meaning defined by the target application.</div><br></dl><dd><div class="Item"><a name="87398"></a><i class="textVariable">targChannel</i></div><dl class="margin"><dd><div class="Follow"><a name="87399"></a>The handle assigned to the TCD by <b class="library">usbTargLib</b> during attach processing. </div><br></dl></dl><dl class="margin"><dd><p class="Body"><a name="87400"></a>The following sections describe each callback in the callback table in more detail. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="87403"></a>mngmtFunc(&nbsp;) Callback</i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="87404"></a>The target driver <b class="library">usbTargLib</b> invokes the target application's <b class="routine">mngmtFunc</b><b>(&nbsp;)</b> callback to inform the application of changes that broadly affect the USB's operation. This callback takes the following form:</p></dl><dl class="margin"><dd><font color="0000a0"><pre class="Code"><a name="87405"></a>typedef STATUS (*USB_TARG_MANAGEMENT_FUNC) &nbsp;&nbsp;&nbsp;&nbsp;( &nbsp;&nbsp;&nbsp;&nbsp;pVOID param, &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_CHANNEL targChannel, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 mngmtCode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* management code */ &nbsp;&nbsp;&nbsp;&nbsp;); </pre></font></dl><dl class="margin"><dd><p class="Body"><a name="87406"></a>The <i class="textVariable">mngmtCode</i> parameter tells the target application what management event has happened. It takes the following values, as defined in <b class="file">usbTcd.h</b>:</p></dl><dl class="margin"><dd><font color="0000a0"><pre class="Code"><a name="87407"></a>&nbsp;&nbsp;&nbsp;&nbsp;TCD_MNGMT_ATTACH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;initial TCD attachment &nbsp;&nbsp;&nbsp;&nbsp;TCD_MNGMT_DETACH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TCD detach &nbsp;&nbsp;&nbsp;&nbsp;TCD_MNGMT_VBUS_DETECT&nbsp;&nbsp;&nbsp;&nbsp;bus detected &nbsp;&nbsp;&nbsp;&nbsp;TCD_MNGMT_VBUS_LOST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vbus lost &nbsp;&nbsp;&nbsp;&nbsp;TCD_MNGMT_BUS_RESET&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bus reset &nbsp;&nbsp;&nbsp;&nbsp;TCD_MNGMT_SUSPEND&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suspend signaling detected &nbsp;&nbsp;&nbsp;&nbsp;TCD_MNGMT_RESUME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resume signaling detected </pre></font></dl><dl class="margin"><dd><p class="Body"><a name="87408"></a>The target application can process or ignore these management codes as it sees fit. In most cases, <b class="library">usbTargLib</b> ignores the status returned by the <b class="routine">mngmtFunc</b><b>(&nbsp;)</b> callback. However, <b class="library">usbTargLib</b> does examine the <b class="routine">mngmtFunc</b><b>(&nbsp;)</b> return code in response to the <b class="symbol_UC">TCD_MNGMT_ATTACH</b> code. In this case, if the <b class="routine">mngmtFunc</b><b>(&nbsp;)</b> returns ERROR, TCD attachment is aborted.</p><dd><p class="Body"><a name="87409"></a>The target driver provides default handling for the <b class="routine">mngmtFunc</b><b>(&nbsp;)</b> callback. The default handler always returns OK.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="87411"></a>Control Pipe Request Callbacks</i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="87412"></a>The target driver <b class="library">usbTargLib</b> provides default processing for all standard requests received on the peripheral's default control pipe (endpoint #0). For each of the standard USB control requests, <b class="library">usbTargLib</b> provides some form of default processing. The following callbacks can be provided by the target application to modify default processing.</p></dl></dl><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="87414"></a>featureClear(&nbsp;) and featureSet(&nbsp;) Callbacks</i></h5></font><dl class="margin"><dd><p class="Body"><a name="87415"></a>The target driver <b class="library">usbTargLib</b> invokes the target application's <b class="routine">featureClear</b><b>(&nbsp;)</b> and <b class="routine">featureSet</b><b>(&nbsp;)</b> callbacks in response to the USB <b class="symbol_UC">CLEAR_FEATURE</b> and <b class="symbol_UC">SET_FEATURE</b> requests, respectively. These callbacks take the following form:</p></dl><dl class="margin"><dd><font color="0000a0"><pre class="Code"><a name="87416"></a>typedef STATUS (*USB_TARG_FEATURE_CLEAR_FUNC) &nbsp;&nbsp;&nbsp;&nbsp;( &nbsp;&nbsp;&nbsp;&nbsp;pVOID param, &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_CHANNEL targChannel, &nbsp;&nbsp;&nbsp;&nbsp;UINT8 requestType, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 feature, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 index &nbsp;&nbsp;&nbsp;&nbsp;);</pre></font><dd><font color="0000a0"><pre class="Code"><a name="87417"></a>typedef STATUS (*USB_TARG_FEATURE_SET_FUNC) &nbsp;&nbsp;&nbsp;&nbsp;( &nbsp;&nbsp;&nbsp;&nbsp;pVOID param, &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_CHANNEL targChannel, &nbsp;&nbsp;&nbsp;&nbsp;UINT8 requestType, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 feature, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 index &nbsp;&nbsp;&nbsp;&nbsp;);</pre></font></dl><dl class="margin"><dd><p class="Body"><a name="87418"></a>If the target application supports these functions, it should clear or set the feature identified by the <i class="textVariable">requestType</i>, <i class="textVariable">feature</i>, and <i class="textVariable">index</i> parameters.</p><dd><p class="Body"><a name="87419"></a>If the target application does not provide these callbacks, then <b class="library">usbTargLib</b> returns an error in response to the corresponding requests. Similarly, if the callbacks return ERROR, <b class="library">usbTargLib</b> returns an error in response to the corresponding request.</p></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="87421"></a>configurationGet(&nbsp;) and configurationSet(&nbsp;) Callbacks</i></h5></font><dl class="margin"><dd><p class="Body"><a name="87422"></a>The target driver <b class="library">usbTargLib</b> invokes the target application's <b class="routine">configurationGet</b><b>(&nbsp;)</b> and <b class="routine">configurationSet</b><b>(&nbsp;)</b> callbacks in response to the USB <b class="symbol_UC">GET_CONFIGURATION</b> and <b class="symbol_UC">SET_CONFIGURATION</b> requests. These callbacks take the following form:</p></dl><dl class="margin"><dd><font color="0000a0"><pre class="Code"><a name="87423"></a>typedef STATUS (*USB_TARG_CONFIGURATION_GET_FUNC) &nbsp;&nbsp;&nbsp;&nbsp;( &nbsp;&nbsp;&nbsp;&nbsp;pVOID param, &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_CHANNEL targChannel, &nbsp;&nbsp;&nbsp;&nbsp;pUINT8 pConfiguration &nbsp;&nbsp;&nbsp;&nbsp;); typedef STATUS (*USB_TARG_CONFIGURATION_SET_FUNC) &nbsp;&nbsp;&nbsp;&nbsp;( &nbsp;&nbsp;&nbsp;&nbsp;pVOID param, &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_CHANNEL targChannel, &nbsp;&nbsp;&nbsp;&nbsp;UINT8 configuration &nbsp;&nbsp;&nbsp;&nbsp;); </pre></font></dl><dl class="margin"><dd><p class="Body"><a name="87424"></a>For the <b class="routine">configurationGet</b><b>(&nbsp;)</b> callback, the target application should fill the <i class="textVariable">pConfiguration</i> buffer with the UINT8 value identifying the current configuration; <b class="library">usbTargLib</b> transmits the response back to the USB host. For <b class="routine">configurationSet</b><b>(&nbsp;)</b>, the target application should set the current configuration to the value indicated by <i class="textVariable">configuration</i>.</p><dd><p class="Body"><a name="87425"></a>If the target application does not provide these callbacks, then <b class="library">usbTargLib</b> returns an error in response to the corresponding requests. Similarly, if the callbacks return ERROR, <b class="library">usbTargLib</b> returns an error in response to the corresponding request.</p></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="87427"></a>descriptorGet(&nbsp;) and descriptorSet(&nbsp;) Callbacks</i></h5></font><dl class="margin"><dd><p class="Body"><a name="87428"></a>The target driver <b class="library">usbTargLib</b> invokes the target application's <b class="routine">descriptorGet</b><b>(&nbsp;)</b> and <b class="routine">descriptorSet</b><b>(&nbsp;)</b> callbacks in response to the USB <b class="symbol_UC">GET_DESCRIPTOR</b> and <b class="symbol_UC">SET_DESCRIPTOR</b> requests. These callbacks take the following form:</p></dl><dl class="margin"><dd><font color="0000a0"><pre class="Code"><a name="87429"></a>typedef STATUS (*USB_TARG_DESCRIPTOR_GET_FUNC) 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -