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

📄 c-periph.html

📁 linux2.4.20下的针对三星公司的s3c2410的usb模块驱动代码
💻 HTML
📖 第 1 页 / 共 5 页
字号:
&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;UINT8 descriptorType, &nbsp;&nbsp;&nbsp;&nbsp;UINT8 descriptorIndex, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 languageId, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 length, &nbsp;&nbsp;&nbsp;&nbsp;pUINT8 pBfr, &nbsp;&nbsp;&nbsp;&nbsp;pUINT16 pActLen &nbsp;&nbsp;&nbsp;&nbsp;); typedef STATUS (*USB_TARG_DESCRIPTOR_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;UINT8 descriptorType, &nbsp;&nbsp;&nbsp;&nbsp;UINT8 descriptorIndex, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 languageId, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 length &nbsp;&nbsp;&nbsp;&nbsp;); </pre></font></dl><dl class="margin"><dd><p class="Body"><a name="87430"></a>The <i class="textVariable">requestType</i>, <i class="textVariable">descriptorType</i>, <i class="textVariable">descriptorIndex</i>, and <i class="textVariable">languageId</i> parameters identify the descriptor requested by the USB host. For the <b class="routine">descriptorGet</b><b>(&nbsp;)</b> callback, the target application should fill the <i class="textVariable">pBfr</i> buffer with the requested descriptor (not to exceed the buffer size specified by <i class="textVariable">length</i>). The target application should also set the <i class="textVariable">pActLen</i> variable to the length of the descriptor placed in <i class="textVariable">pBfr</i>. The target driver transmits the descriptor back to the USB host. </p><dd><p class="Body"><a name="87431"></a>In the case of <b class="routine">descriptorSet</b><b>(&nbsp;)</b>, the target application must use the <b class="routine">usbTargControlPayloadRcv</b><b>(&nbsp;)</b> routine (see <a href="c-periph.html#87512"><i class="title">Control Pipe Data Transfers</i></a>) to receive the descriptor being sent by the USB host, then process it appropriately.</p><dd><p class="Body"><a name="87435"></a>If the target application does not provide these callbacks, <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="87437"></a>interfaceGet(&nbsp;) and interfaceSet(&nbsp;) Callbacks</i></h5></font><dl class="margin"><dd><p class="Body"><a name="87438"></a>The target driver <b class="library">usbTargLib</b> invokes the target application's <b class="routine">interfaceGet</b><b>(&nbsp;)</b>) and <b class="routine">interfaceSet</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="87439"></a>typedef STATUS (*USB_TARG_INTERFACE_GET_FUNC) &nbsp;&nbsp;&nbsp;&nbsp;( &nbsp;&nbsp;&nbsp;&nbsp;pVOID param, &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_CHANNEL targChannel, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 interfaceIndex, &nbsp;&nbsp;&nbsp;&nbsp;pUINT8 pAlternateSetting &nbsp;&nbsp;&nbsp;&nbsp;); typedef STATUS (*USB_TARG_INTERFACE_SET_FUNC) &nbsp;&nbsp;&nbsp;&nbsp;( &nbsp;&nbsp;&nbsp;&nbsp;pVOID param, &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_CHANNEL targChannel, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 interfaceIndex, &nbsp;&nbsp;&nbsp;&nbsp;UINT8 alternateSetting &nbsp;&nbsp;&nbsp;&nbsp;); </pre></font></dl><dl class="margin"><dd><p class="Body"><a name="87440"></a>For the <b class="routine">interfaceGet</b><b>(&nbsp;)</b> callback, the target application should store its current interface setting in the variable <i class="textVariable">pAlternateSetting</i>, for the interface specified by <i class="textVariable">interfaceIndex</i>. For <b class="routine">interfaceSet</b><b>(&nbsp;)</b>, the target application should set its interface according to the <i class="textVariable">interfaceIndex</i> and <i class="textVariable">alternateSetting</i> parameters.</p><dd><p class="Body"><a name="87441"></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="87443"></a>statusGet(&nbsp;) Callback</i></h5></font><dl class="margin"><dd><p class="Body"><a name="87444"></a>The target driver <b class="library">usbTargLib</b> invokes the target application's <b class="routine">statusGet</b><b>(&nbsp;)</b> callback in response to the USB <b class="symbol_UC">GET_STATUS</b> request. This callback takes the following form:</p></dl><dl class="margin"><dd><font color="0000a0"><pre class="Code"><a name="87445"></a>typedef STATUS (*USB_TARG_STATUS_GET_FUNC) &nbsp;&nbsp;&nbsp;&nbsp;( &nbsp;&nbsp;&nbsp;&nbsp;pVOID param, &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_CHANNEL targChannel, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 requestType, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 index, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 length, &nbsp;&nbsp;&nbsp;&nbsp;pUINT8 pBfr, &nbsp;&nbsp;&nbsp;&nbsp;pUINT16 pActLen &nbsp;&nbsp;&nbsp;&nbsp;); </pre></font></dl><dl class="margin"><dd><p class="Body"><a name="87446"></a>If the target application supports this callback, it should store the appropriate status in <i class="textVariable">pBfr</i> (not to exceed the length specified by <i class="textVariable">length</i>). It should also store the length of the status in <i class="textVariable">pActLen</i>. The target driver sends the status back to the USB host.</p><dd><p class="Body"><a name="87447"></a>If the target application does not provide this callback, <b class="library">usbTargLib</b> returns an error in response to <b class="symbol_UC">GET_STATUS</b> requests. Similarly, if the <b class="routine">statusGet</b><b>(&nbsp;) </b>callback returns ERROR, then <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="87449"></a>addressSet(&nbsp;) Callback</i></h5></font><dl class="margin"><dd><p class="Body"><a name="87450"></a>The target driver <b class="library">usbTargLib</b> invokes the target application's <b class="routine">addressSet</b><b>(&nbsp;)</b> callback in response to the USB <b class="symbol_UC">SET_ADDRESS</b> request. This callback takes the following form:</p></dl><dl class="margin"><dd><font color="0000a0"><pre class="Code"><a name="87451"></a>typedef STATUS (*USB_TARG_ADDRESS_SET_FUNC) &nbsp;&nbsp;&nbsp;&nbsp;( &nbsp;&nbsp;&nbsp;&nbsp;pVOID param, &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_CHANNEL targChannel, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 deviceAddress &nbsp;&nbsp;&nbsp;&nbsp;); </pre></font></dl><dl class="margin"><dd><p class="Body"><a name="87452"></a>The target driver handles the <b class="symbol_UC">SET_ADDRESS</b> request automatically whether or not the target application supports this callback. The current implementation of <b class="library">usbTargLib</b> ignores the <b class="symbol_UC">STATUS</b> returned by this callback.</p></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="87454"></a>synchFrameGet(&nbsp;) Callback</i></h5></font><dl class="margin"><dd><p class="Body"><a name="87455"></a>The target driver <b class="library">usbTargLib</b> invokes the target application's <b class="routine">synchFrameGet</b><b>(&nbsp;)</b> callback in response to the USB <b class="symbol_UC">GET_SYNCH_FRAME</b> request. This callback takes the following form:</p></dl><dl class="margin"><dd><font color="0000a0"><pre class="Code"><a name="87456"></a>typedef STATUS (*USB_TARG_SYNCH_FRAME_GET_FUNC) &nbsp;&nbsp;&nbsp;&nbsp;( &nbsp;&nbsp;&nbsp;&nbsp;pVOID param, &nbsp;&nbsp;&nbsp;&nbsp;USB_TARG_CHANNEL targChannel, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 endpoint, &nbsp;&nbsp;&nbsp;&nbsp;pUINT16 pFrameNo &nbsp;&nbsp;&nbsp;&nbsp;); </pre></font></dl><dl class="margin"><dd><p class="Body"><a name="87457"></a>Typically, this function is used to synchronize isochronous data transfers. If the application supports it, then the callback should store the synch frame information in <i class="textVariable">pFrameNo</i> and return OK. The target driver sends the response to the USB host.</p><dd><p class="Body"><a name="87458"></a>If the target application does not provide this callback, <b class="library">usbTargLib</b> returns an error in response to <b class="symbol_UC">GET_SYNCH_FRAME</b> requests. Similarly, if the <b class="routine">synchFrameGet</b><b>(&nbsp;)</b> callback returns 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="87460"></a>vendorSpecific(&nbsp;) Callback</i></h5></font><dl class="margin"><dd><p class="Body"><a name="87461"></a>All requests received on the peripheral's default control pipe and not recognized as standard requests are routed to the target application's <b class="routine">vendorSpecific</b><b>(&nbsp;)</b> callback, if one is provided. This callback takes the following form:</p></dl><dl class="margin"><dd><font color="0000a0"><pre class="Code"><a name="87462"></a>typedef STATUS (*USB_TARG_VENDOR_SPECIFIC_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;UINT8 request, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 value, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 index, &nbsp;&nbsp;&nbsp;&nbsp;UINT16 length &nbsp;&nbsp;&nbsp;&nbsp;); </pre></font></dl><dl class="margin"><dd><p class="Body"><a name="87463"></a>The target application's handling of vendor-specific requests varies widely. Some vendor-specific requests can require additional data transfer, perhaps using <b class="library">usbTargLib</b>'s <b class="routine">usbTargControlPayloadRcv</b><b>(&nbsp;)</b> or <b class="routine">usbTargControlResponseSend</b><b>(&nbsp;)</b> for support. If the target application handles the vendor-specific request successfully, it should return OK.</p><dd><p class="Body"><a name="87464"></a>If the target application does not provide this callback, <b class="library">usbTargLib</b> returns an error in response to a vendor-specific request. Similarly, if the <b class="routine">vendorSpecific</b><b>(&nbsp;)</b> callback returns ERROR, <b class="library">usbTargLib</b> returns an error in response to the corresponding request.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="87467"></a>2.2.5  &nbsp;&nbsp;TCD Endpoints</i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="87468"></a>In response to the <b class="routine">usbTargTcdAttach</b><b>(&nbsp;)</b> routine, <b class="library">usbTargLib</b> returns the number of endpoints supported by the target and a pointer to an array describing each endpoint. Each entry in this array takes the following form:</p></dl><dl class="margin"><dd><font color="0000a0"><pre class="Code"><a name="87469"></a>typedef struct usb_targ_endpoint_info &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;UINT16 endpointId;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* TCD-assigned endpoint ID */ &nbsp;&nbsp;&nbsp;&nbsp;UINT16 flags;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* endpoint characteristics */  &nbsp;&nbsp;&nbsp;&nbsp;UINT16 endpointNumMask;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* mask of allowed endpoint numbers */  &nbsp;&nbsp;&nbsp;&nbsp;UINT32 ctlMaxPacketSize;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* max packet size in control mode */ &nbsp;&nbsp;&nbsp;&nbsp;UINT32 bulkInMaxPacketSize;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* max packet size in bulk IN mode */ &nbsp;&nbsp;&nbsp;&nbsp;UINT32 bulkOutMaxPacketSize;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* max packet size in bulk OUT mode */ &nbsp;&nbsp;&nbsp;&nbsp;UINT32 bulkInOutMaxPacketSize;&nbsp;&nbsp;&nbsp;/* max packet size in bulk I/O mode */  &nbsp;&nbsp;&nbsp;&nbsp;UINT32 intInMaxPacketSize;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* max packet size in intrpt IN mode */ &nbsp;&nbsp;&nbsp;&nbsp;UINT32 intOutMaxPacketSize;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* max packet size in intrpt OUT mode */ &nbsp;&nbsp;&nbsp;&nbsp;UINT32 intInOutMaxPacketSize;&nbsp;&nbsp;&nbsp;&nbsp;/* max packet size in intrpt I/O mode */ &nbsp;&nbsp;&nbsp;&nbsp;UINT32 isochInMaxPacketSize;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* max packet size in isoch IN mode */ 

⌨️ 快捷键说明

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