<?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>nRF52840 USB EPOUT data buffer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/30738/nrf52840-usb-epout-data-buffer</link><description>Hi All! 
 I use &amp;quot;examples\peripheral\usbd\&amp;quot; example Project as reference to implement my own HID protocol. 
 I use only EP1 in/out 64 bytes both. 
 faced with a question, there is a DATA BUFFER for NRF_DRV_USBD_EPOUT1 when I receive NRF_DRV_USBD_EVT_EPTRANSFER</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 22 Feb 2018 15:41:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/30738/nrf52840-usb-epout-data-buffer" /><item><title>RE: nRF52840 USB EPOUT data buffer</title><link>https://devzone.nordicsemi.com/thread/121706?ContentTypeID=1</link><pubDate>Thu, 22 Feb 2018 15:41:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c289b6cb-c260-4465-8cd2-ec3995944597</guid><dc:creator>Aylik</dc:creator><description>&lt;p&gt;I find solution, the problem is NRF_USBD_EP_WAITING event processing.&lt;/p&gt;
&lt;p&gt;this code works SUCCESS, now I can SEND / RECEIVE EPxIN/EPxOUT of 64 bytes to/from HOST (FS USB)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    
    case NRF_DRV_USBD_EVT_EPTRANSFER:
        if (NRF_DRV_USBD_EPIN1 == p_event-&amp;gt;data.eptransfer.ep)
        {
        	NRF_LOG_INFO(&amp;quot;EPTRANSFER EPIN1 status: %x&amp;quot;,p_event-&amp;gt;data.eptransfer.status);
        	muENV.cnt_ep1_in++;
            m_send_pending = false;
        }
        else
        if (NRF_DRV_USBD_EPOUT1 == p_event-&amp;gt;data.eptransfer.ep)
        {// EPxOUT DATA READ Algorithm
        	NRF_LOG_INFO(&amp;quot;EPTRANSFER EPOUT1 status: %x&amp;quot;,p_event-&amp;gt;data.eptransfer.status);
            muENV.cnt_ep1_out++;
        	if(p_event-&amp;gt;data.eptransfer.status == NRF_USBD_EP_WAITING)
        	{// STAGE_0: WAITING for EPxOUT DATA READ, do Prepare the BUFFER to READ !
        		m_urx_bf.p_data.rx = (void*)urx_bf_w; //&amp;lt; raw buffer to rx data
        		m_urx_bf.size = nrf_drv_usbd_epout_size_get(NRF_DRV_USBD_EPOUT1); //&amp;lt; EPxOUT data sz to be rx
        		// REQUEST: READ EPxOUT DATA
        		nrf_drv_usbd_ep_transfer(NRF_DRV_USBD_EPOUT1,(void*)&amp;amp;m_urx_bf);
        	}
        	else
        	if(p_event-&amp;gt;data.eptransfer.status == NRF_USBD_EP_OK)
        	{// STAGE_1: DATA READ OK , set FLAG !
            	muENV.ep1out_rcvd++;
        	}
        	else
        	if(p_event-&amp;gt;data.eptransfer.status == NRF_USBD_EP_OVERLOAD || p_event-&amp;gt;data.eptransfer.status == NRF_USBD_EP_ABORTED)
        	{// ERROR CASE processing... resolve this issue later in CORE.
        		muENV.ep1out_err++;
                nrf_drv_usbd_ep_stall(NRF_DRV_USBD_EPOUT1);
        	}
        }
        else
        {
        // EP0 processing
        ...
        }&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>