<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Cannot receive Data through USB HID from PC</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/73092/cannot-receive-data-through-usb-hid-from-pc</link><description>Hi Guys， 
 I want to implement a Vendor-defined USB HID device, But encountered the following problems: 
 1.When the PC sends data via USB HID , the slave(52840) cannot enter the response Event ( APP_USBD_HID_USER_EVT_OUT_REPORT_READY ) in main.c ， i</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 30 Mar 2021 09:03:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/73092/cannot-receive-data-through-usb-hid-from-pc" /><item><title>RE: Cannot receive Data through USB HID from PC</title><link>https://devzone.nordicsemi.com/thread/302521?ContentTypeID=1</link><pubDate>Tue, 30 Mar 2021 09:03:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88bc47cc-f220-4c44-b333-b2e36b4f8810</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please create a new support case for the new issue. This is away from the original scope.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please note that due to the Easter holiday, we&amp;#39;re low on staff, so somewhat lower response times must be expected until April 6th. Sorry about the inconvenience.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-Amanda H.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot receive Data through USB HID from PC</title><link>https://devzone.nordicsemi.com/thread/302239?ContentTypeID=1</link><pubDate>Sat, 27 Mar 2021 09:21:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b546f4bd-3b5f-4153-9452-b4c7a27f28c9</guid><dc:creator>nicholas_cage</dc:creator><description>&lt;p&gt;Thanks for you reply，&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;I ran into another problem。The first packet of data sent by the PC was successfully received, and the second packet of data failed to be received。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;The packet capture tool shows that the second packet of data was unsuccessful, and the device entered the stall pid.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/1643.error.bmp" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;Function returns&amp;nbsp; failed&amp;nbsp; in&amp;nbsp; p_ep_conf-&amp;gt;event_handler() function ( in app_usbd.c)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event)
{
    ASSERT(NULL != m_p_first_cinst);
    /* If no event queue is implemented, it has to be ensured that this function is never called
     * from the context higher than USB interrupt level
     * If queue is implemented it would be called always from Thread level
     * if the library is used correctly.
     * NOTE: Higher interrupt level -&amp;gt; lower priority value.
     */
    ASSERT(USBD_CONFIG_IRQ_PRIORITY &amp;lt;= current_int_priority_get());
    bsp_board_led_invert(2);
    /* Note - there should never be situation that event is generated on disconnected endpoint */
    switch (p_event-&amp;gt;type)
    {
       
        ....
      
        case APP_USBD_EVT_DRV_EPTRANSFER:
        {
            app_usbd_ep_conf_t const * p_ep_conf =
                    app_usbd_ep_conf_access(p_event-&amp;gt;drv_evt.data.eptransfer.ep);
            ASSERT(NULL != p_ep_conf-&amp;gt;p_cinst);
            ASSERT(NULL != p_ep_conf-&amp;gt;event_handler);

    	if (NRF_DRV_USBD_EPOUT4 == p_event-&amp;gt;drv_evt.data.eptransfer.ep) {
    			static uint8_t receive_buffer[64];
    			static nrf_drv_usbd_ep_transfer_t usb_tranfer;
    		if (NRF_USBD_EP_WAITING == p_event-&amp;gt;drv_evt.data.eptransfer.status) {
    				usb_tranfer.p_data.rx = receive_buffer;
    				usb_tranfer.size = 64;
    				int ret = nrf_drv_usbd_ep_transfer(p_event-&amp;gt;drv_evt.data.eptransfer.ep, &amp;amp;usb_tranfer);
    
    		} else if (NRF_USBD_EP_OK == p_event-&amp;gt;drv_evt.data.eptransfer.status) {
    			size_t size = 0;
    			nrf_drv_usbd_ep_status_get(p_event-&amp;gt;drv_evt.data.eptransfer.ep, &amp;amp;size);
    				printf(&amp;quot;Received %d bytes:\n&amp;quot;, size);
    				for (int i = 0; i &amp;lt; size; i++) printf(&amp;quot;0x%02X &amp;quot;, receive_buffer[i]);
    				printf(&amp;quot;\n&amp;quot;);
    		} else {
    			printf(&amp;quot;Transfer failed on EPOUT1: %d\n&amp;quot;, p_event-&amp;gt;drv_evt.data.eptransfer.status);
    		}
    	}       

        
            if (NRF_SUCCESS != p_ep_conf-&amp;gt;event_handler(p_ep_conf-&amp;gt;p_cinst,
                                                       (app_usbd_complex_evt_t const *)p_event))   // not success here
            {
                /* If error returned, every bulk/interrupt endpoint would be stalled */
                if (!(0 == NRF_USBD_EP_NR_GET(p_event-&amp;gt;drv_evt.data.eptransfer.ep) ||
                   NRF_USBD_EPISO_CHECK(p_event-&amp;gt;drv_evt.data.eptransfer.ep)))
                {
                    nrf_drv_usbd_ep_stall(p_event-&amp;gt;drv_evt.data.eptransfer.ep); 
                }
            }
            break;
        }
        .... 

        default:
            ASSERT(0);
            break;
    }
}
&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div class="DNFg3e"&gt;
&lt;div class="oJweqc Qbfsob KKjvXb"&gt;
&lt;div class="PrVWEc"&gt;&lt;/div&gt;
&lt;div class="v3U01d"&gt;
&lt;div class="NqnNQd" lang="en"&gt;Please tell me how to solve this problem.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot receive Data through USB HID from PC</title><link>https://devzone.nordicsemi.com/thread/301470?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2021 14:15:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c64d55a-4a86-4e23-8a4a-09e1ce3cff7f</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Check out&amp;nbsp;this &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/30738/nrf52840-usb-epout-data-buffer/121706#121706"&gt;post&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot receive Data through USB HID from PC</title><link>https://devzone.nordicsemi.com/thread/301439?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2021 13:29:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a147c0b0-a08b-4d09-b347-9149a38ca53b</guid><dc:creator>nicholas_cage</dc:creator><description>&lt;p&gt;I noticed that when the PC sent data, the program gave a warning in nrfx_usbd.c&amp;nbsp; line 1192。&lt;/p&gt;
&lt;p&gt;（NRFX_USBD_EP_WAITING,&amp;nbsp; /**&amp;lt; Data received, no buffer prepared already - waiting for configured transfer. */)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;SDK17.02

/**
 * @brief React on data transfer finished.
 *
 * Auxiliary internal function.
 * @param ep     Endpoint number.
 * @param bitpos Bit position for selected endpoint number.
 */
static void usbd_ep_data_handler(nrfx_usbd_ep_t ep, uint8_t bitpos)
{
     ...
  
    if (NRF_USBD_EPIN_CHECK(ep))
    {
       ....
    }
    else
    {
        /* OUT endpoint (Host -&amp;gt; Device) */
        if (0 == (m_ep_dma_waiting &amp;amp; (1U &amp;lt;&amp;lt; bitpos)))
        {
            NRFX_LOG_DEBUG(&amp;quot;USBD event: EndpointData: Out waiting&amp;quot;);
            /* No buffer prepared - send event to the application */
            NRFX_USBD_EP_TRANSFER_EVENT(evt, ep, NRFX_USBD_EP_WAITING);  // here
            m_event_handler(&amp;amp;evt);
        }
    }
}&lt;/pre&gt;&lt;br /&gt;I want to know how to set the receive buffer of the endpoint ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>