📄 c-periph.html
字号:
( pVOID param, USB_TARG_CHANNEL targChannel, UINT8 requestType, UINT8 descriptorType, UINT8 descriptorIndex, UINT16 languageId, UINT16 length, pUINT8 pBfr, pUINT16 pActLen ); typedef STATUS (*USB_TARG_DESCRIPTOR_SET_FUNC) ( pVOID param, USB_TARG_CHANNEL targChannel, UINT8 requestType, UINT8 descriptorType, UINT8 descriptorIndex, UINT16 languageId, UINT16 length ); </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>( )</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>( )</b>, the target application must use the <b class="routine">usbTargControlPayloadRcv</b><b>( )</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( ) and interfaceSet( ) 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>( )</b>) and <b class="routine">interfaceSet</b><b>( )</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) ( pVOID param, USB_TARG_CHANNEL targChannel, UINT16 interfaceIndex, pUINT8 pAlternateSetting ); typedef STATUS (*USB_TARG_INTERFACE_SET_FUNC) ( pVOID param, USB_TARG_CHANNEL targChannel, UINT16 interfaceIndex, UINT8 alternateSetting ); </pre></font></dl><dl class="margin"><dd><p class="Body"><a name="87440"></a>For the <b class="routine">interfaceGet</b><b>( )</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>( )</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( ) 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>( )</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) ( pVOID param, USB_TARG_CHANNEL targChannel, UINT16 requestType, UINT16 index, UINT16 length, pUINT8 pBfr, pUINT16 pActLen ); </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>( ) </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( ) 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>( )</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) ( pVOID param, USB_TARG_CHANNEL targChannel, UINT16 deviceAddress ); </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( ) 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>( )</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) ( pVOID param, USB_TARG_CHANNEL targChannel, UINT16 endpoint, pUINT16 pFrameNo ); </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>( )</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( ) 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>( )</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) ( pVOID param, USB_TARG_CHANNEL targChannel, UINT8 requestType, UINT8 request, UINT16 value, UINT16 index, UINT16 length ); </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>( )</b> or <b class="routine">usbTargControlResponseSend</b><b>( )</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>( )</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 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>( )</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 { UINT16 endpointId; /* TCD-assigned endpoint ID */ UINT16 flags; /* endpoint characteristics */ UINT16 endpointNumMask; /* mask of allowed endpoint numbers */ UINT32 ctlMaxPacketSize; /* max packet size in control mode */ UINT32 bulkInMaxPacketSize; /* max packet size in bulk IN mode */ UINT32 bulkOutMaxPacketSize; /* max packet size in bulk OUT mode */ UINT32 bulkInOutMaxPacketSize; /* max packet size in bulk I/O mode */ UINT32 intInMaxPacketSize; /* max packet size in intrpt IN mode */ UINT32 intOutMaxPacketSize; /* max packet size in intrpt OUT mode */ UINT32 intInOutMaxPacketSize; /* max packet size in intrpt I/O mode */ UINT32 isochInMaxPacketSize; /* max packet size in isoch IN mode */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -