"Host Present" Detection via LPCOpen USB Library (LPC11U68)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

"Host Present" Detection via LPCOpen USB Library (LPC11U68)

1,489件の閲覧回数
mattferrari
Contributor III

I am coding a USB MSC application and am connecting with the Host via the USB Library function call:

USBD_API->hw->Connect(g_hUsb, 1);

I would like to know if there is a facility for confirming that  Host is actually present.

Is there a flag I can check, or a function I can call which can tell me if (or when) the presence (or absence) of a Host can be confirmed?

Thanks,

Matt

ラベル(3)
0 件の賞賛
返信
2 返答(返信)

1,234件の閲覧回数
jeremyzhou
NXP Employee
NXP Employee

Hi Matt Ferrari,

You can check the return value of the EP0 handler when USB device fail to complete the enumeration, and you can find the code above

          g_Ep0BaseHdlr = pCtrl->ep_event_hdlr[0];/* retrieve the default EP0_OUT handler */
          pCtrl->ep_event_hdlr[0] = EP0_patch;/* set our patch routine as EP0_OUT handler */

/* EP0_patch part of WORKAROUND for artf45032. */
ErrorCode_t EP0_patch(USBD_HANDLE_T hUsb, void *data, uint32_t event)
{
     switch (event) {
     case USB_EVT_OUT_NAK:
          if (g_ep0RxBusy) {
               /* we already queued the buffer so ignore this NAK event. */
               return LPC_OK;
          }
          else {
               /* Mark EP0_RX buffer as busy and allow base handler to queue the buffer. */
               g_ep0RxBusy = 1;
          }
          break;

     case USB_EVT_SETUP:     /* reset the flag when new setup sequence starts */
     case USB_EVT_OUT:
          /* we received the packet so clear the flag. */
          g_ep0RxBusy = 0;
          break;
     }
     return g_Ep0BaseHdlr(hUsb, data, event);
}

Have a great day,
Ping

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信

1,234件の閲覧回数
mattferrari
Contributor III

Dear NXP tech support, can you please provide an answer to this question?  Thanks, Matt

0 件の賞賛
返信