<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>i.MX RT Crossover MCUsのトピックError in USB VCOM CDC example ?</title>
    <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Error-in-USB-VCOM-CDC-example/m-p/1160821#M10325</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I have a question concerning the USB virtual com example. In the following &lt;FONT color="#333333"&gt;code&lt;/FONT&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;usb_status_t USB_DeviceCdcVcomCallback(class_handle_t handle, uint32_t event, void *param)
{
    usb_status_t error = kStatus_USB_Error;
    uint32_t len;
    uint8_t *uartBitmap;
    usb_cdc_acm_info_t *acmInfo = &amp;amp;s_usbCdcAcmInfo;
    usb_device_cdc_acm_request_param_struct_t *acmReqParam;
    usb_device_endpoint_callback_message_struct_t *epCbParam;
    acmReqParam = (usb_device_cdc_acm_request_param_struct_t *)param;
    epCbParam   = (usb_device_endpoint_callback_message_struct_t *)param;
    switch (event)
    {
        case kUSB_DeviceCdcEventSendResponse:
        {
            if ((epCbParam-&amp;gt;length != 0) &amp;amp;&amp;amp; (!(epCbParam-&amp;gt;length % g_UsbDeviceCdcVcomDicEndpoints[0].maxPacketSize)))
            {
                /* If the last packet is the size of endpoint, then send also zero-ended packet,
                 ** meaning that we want to inform the host that we do not have any additional
                 ** data, so it can flush the output.
                 */
                error = USB_DeviceCdcAcmSend(handle, USB_CDC_VCOM_BULK_IN_ENDPOINT, NULL, 0);
            }
            else if ((1 == s_cdcVcom.attach) &amp;amp;&amp;amp; (1 == s_cdcVcom.startTransactions))
            {
                if ((epCbParam-&amp;gt;buffer != NULL) || ((epCbParam-&amp;gt;buffer == NULL) &amp;amp;&amp;amp; (epCbParam-&amp;gt;length == 0)))
                {
                    /* User: add your own code for send complete event */
                    /* Schedule buffer for next receive event */
                    error = USB_DeviceCdcAcmRecv(handle, USB_CDC_VCOM_BULK_OUT_ENDPOINT, s_currRecvBuf,
                                                 g_UsbDeviceCdcVcomDicEndpoints[0].maxPacketSize);
#if defined(FSL_FEATURE_USB_KHCI_KEEP_ALIVE_ENABLED) &amp;amp;&amp;amp; (FSL_FEATURE_USB_KHCI_KEEP_ALIVE_ENABLED &amp;gt; 0U) &amp;amp;&amp;amp; \
    defined(USB_DEVICE_CONFIG_KEEP_ALIVE_MODE) &amp;amp;&amp;amp; (USB_DEVICE_CONFIG_KEEP_ALIVE_MODE &amp;gt; 0U) &amp;amp;&amp;amp;             \
    defined(FSL_FEATURE_USB_KHCI_USB_RAM) &amp;amp;&amp;amp; (FSL_FEATURE_USB_KHCI_USB_RAM &amp;gt; 0U)
                    s_waitForDataReceive = 1;
                    USB0-&amp;gt;INTEN &amp;amp;= ~USB_INTEN_SOFTOKEN_MASK;
#endif
                }
            }
        }
        break;
        case kUSB_DeviceCdcEventRecvResponse:
        {
            if ((1 == s_cdcVcom.attach) &amp;amp;&amp;amp; (1 == s_cdcVcom.startTransactions))
            {
                s_recvSize = epCbParam-&amp;gt;length;

#if defined(FSL_FEATURE_USB_KHCI_KEEP_ALIVE_ENABLED) &amp;amp;&amp;amp; (FSL_FEATURE_USB_KHCI_KEEP_ALIVE_ENABLED &amp;gt; 0U) &amp;amp;&amp;amp; \
    defined(USB_DEVICE_CONFIG_KEEP_ALIVE_MODE) &amp;amp;&amp;amp; (USB_DEVICE_CONFIG_KEEP_ALIVE_MODE &amp;gt; 0U) &amp;amp;&amp;amp;             \
    defined(FSL_FEATURE_USB_KHCI_USB_RAM) &amp;amp;&amp;amp; (FSL_FEATURE_USB_KHCI_USB_RAM &amp;gt; 0U)
                s_waitForDataReceive = 0;
                USB0-&amp;gt;INTEN |= USB_INTEN_SOFTOKEN_MASK;
#endif
                if (!s_recvSize)
                {
                    /* Schedule buffer for next receive event */
                    error = USB_DeviceCdcAcmRecv(handle, USB_CDC_VCOM_BULK_OUT_ENDPOINT, s_currRecvBuf,
                                                 g_UsbDeviceCdcVcomDicEndpoints[0].maxPacketSize);
#if defined(FSL_FEATURE_USB_KHCI_KEEP_ALIVE_ENABLED) &amp;amp;&amp;amp; (FSL_FEATURE_USB_KHCI_KEEP_ALIVE_ENABLED &amp;gt; 0U) &amp;amp;&amp;amp; \
    defined(USB_DEVICE_CONFIG_KEEP_ALIVE_MODE) &amp;amp;&amp;amp; (USB_DEVICE_CONFIG_KEEP_ALIVE_MODE &amp;gt; 0U) &amp;amp;&amp;amp;             \
    defined(FSL_FEATURE_USB_KHCI_USB_RAM) &amp;amp;&amp;amp; (FSL_FEATURE_USB_KHCI_USB_RAM &amp;gt; 0U)
                    s_waitForDataReceive = 1;
                    USB0-&amp;gt;INTEN &amp;amp;= ~USB_INTEN_SOFTOKEN_MASK;
#endif
                }
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333"&gt;For cases &lt;EM&gt;kUSB_DeviceCdcEventSendResponse &lt;/EM&gt;and &lt;EM&gt;kUSB_DeviceCdcEventRecvResponse&lt;/EM&gt;, in the &lt;EM&gt;USB_DeviceCdcAcmRecv&lt;/EM&gt; function call, endpoint index 0 is used to get max packet size&amp;nbsp; (&lt;EM&gt;g_UsbDeviceCdcVcomDicEndpoints[&lt;STRONG&gt;0&lt;/STRONG&gt;].maxPacketSize&lt;/EM&gt;). However, this call reference BULK_OUT endpoint which is define at index 1 of g_UsbDeviceCdcVcomDicEndpoints variable:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/* Define endpoint for data class */
usb_device_endpoint_struct_t g_UsbDeviceCdcVcomDicEndpoints[USB_CDC_VCOM_ENDPOINT_DIC_COUNT] = {
    {
        USB_CDC_VCOM_BULK_IN_ENDPOINT | (USB_IN &amp;lt;&amp;lt; 7U), USB_ENDPOINT_BULK, FS_CDC_VCOM_BULK_IN_PACKET_SIZE, 0U,
    },
    {
        USB_CDC_VCOM_BULK_OUT_ENDPOINT | (USB_OUT &amp;lt;&amp;lt; 7U), USB_ENDPOINT_BULK, FS_CDC_VCOM_BULK_OUT_PACKET_SIZE, 0U,
    }};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333"&gt;Shouldn't it be index 1 (&lt;EM&gt;g_UsbDeviceCdcVcomDicEndpoints[&lt;STRONG&gt;1&lt;/STRONG&gt;].maxPacketSize)&lt;/EM&gt; passed in parameter to the function ? In this case it won't change anything as both max packet size for BULK_IN and BULK_OUT have the same value but I just want to clarify my understanding of USB stack.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333"&gt;Thanks&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333"&gt;Hugio&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 16:32:13 GMT</pubDate>
    <dc:creator>h_bouchard</dc:creator>
    <dc:date>2020-09-29T16:32:13Z</dc:date>
    <item>
      <title>Error in USB VCOM CDC example ?</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Error-in-USB-VCOM-CDC-example/m-p/1160821#M10325</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I have a question concerning the USB virtual com example. In the following &lt;FONT color="#333333"&gt;code&lt;/FONT&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;usb_status_t USB_DeviceCdcVcomCallback(class_handle_t handle, uint32_t event, void *param)
{
    usb_status_t error = kStatus_USB_Error;
    uint32_t len;
    uint8_t *uartBitmap;
    usb_cdc_acm_info_t *acmInfo = &amp;amp;s_usbCdcAcmInfo;
    usb_device_cdc_acm_request_param_struct_t *acmReqParam;
    usb_device_endpoint_callback_message_struct_t *epCbParam;
    acmReqParam = (usb_device_cdc_acm_request_param_struct_t *)param;
    epCbParam   = (usb_device_endpoint_callback_message_struct_t *)param;
    switch (event)
    {
        case kUSB_DeviceCdcEventSendResponse:
        {
            if ((epCbParam-&amp;gt;length != 0) &amp;amp;&amp;amp; (!(epCbParam-&amp;gt;length % g_UsbDeviceCdcVcomDicEndpoints[0].maxPacketSize)))
            {
                /* If the last packet is the size of endpoint, then send also zero-ended packet,
                 ** meaning that we want to inform the host that we do not have any additional
                 ** data, so it can flush the output.
                 */
                error = USB_DeviceCdcAcmSend(handle, USB_CDC_VCOM_BULK_IN_ENDPOINT, NULL, 0);
            }
            else if ((1 == s_cdcVcom.attach) &amp;amp;&amp;amp; (1 == s_cdcVcom.startTransactions))
            {
                if ((epCbParam-&amp;gt;buffer != NULL) || ((epCbParam-&amp;gt;buffer == NULL) &amp;amp;&amp;amp; (epCbParam-&amp;gt;length == 0)))
                {
                    /* User: add your own code for send complete event */
                    /* Schedule buffer for next receive event */
                    error = USB_DeviceCdcAcmRecv(handle, USB_CDC_VCOM_BULK_OUT_ENDPOINT, s_currRecvBuf,
                                                 g_UsbDeviceCdcVcomDicEndpoints[0].maxPacketSize);
#if defined(FSL_FEATURE_USB_KHCI_KEEP_ALIVE_ENABLED) &amp;amp;&amp;amp; (FSL_FEATURE_USB_KHCI_KEEP_ALIVE_ENABLED &amp;gt; 0U) &amp;amp;&amp;amp; \
    defined(USB_DEVICE_CONFIG_KEEP_ALIVE_MODE) &amp;amp;&amp;amp; (USB_DEVICE_CONFIG_KEEP_ALIVE_MODE &amp;gt; 0U) &amp;amp;&amp;amp;             \
    defined(FSL_FEATURE_USB_KHCI_USB_RAM) &amp;amp;&amp;amp; (FSL_FEATURE_USB_KHCI_USB_RAM &amp;gt; 0U)
                    s_waitForDataReceive = 1;
                    USB0-&amp;gt;INTEN &amp;amp;= ~USB_INTEN_SOFTOKEN_MASK;
#endif
                }
            }
        }
        break;
        case kUSB_DeviceCdcEventRecvResponse:
        {
            if ((1 == s_cdcVcom.attach) &amp;amp;&amp;amp; (1 == s_cdcVcom.startTransactions))
            {
                s_recvSize = epCbParam-&amp;gt;length;

#if defined(FSL_FEATURE_USB_KHCI_KEEP_ALIVE_ENABLED) &amp;amp;&amp;amp; (FSL_FEATURE_USB_KHCI_KEEP_ALIVE_ENABLED &amp;gt; 0U) &amp;amp;&amp;amp; \
    defined(USB_DEVICE_CONFIG_KEEP_ALIVE_MODE) &amp;amp;&amp;amp; (USB_DEVICE_CONFIG_KEEP_ALIVE_MODE &amp;gt; 0U) &amp;amp;&amp;amp;             \
    defined(FSL_FEATURE_USB_KHCI_USB_RAM) &amp;amp;&amp;amp; (FSL_FEATURE_USB_KHCI_USB_RAM &amp;gt; 0U)
                s_waitForDataReceive = 0;
                USB0-&amp;gt;INTEN |= USB_INTEN_SOFTOKEN_MASK;
#endif
                if (!s_recvSize)
                {
                    /* Schedule buffer for next receive event */
                    error = USB_DeviceCdcAcmRecv(handle, USB_CDC_VCOM_BULK_OUT_ENDPOINT, s_currRecvBuf,
                                                 g_UsbDeviceCdcVcomDicEndpoints[0].maxPacketSize);
#if defined(FSL_FEATURE_USB_KHCI_KEEP_ALIVE_ENABLED) &amp;amp;&amp;amp; (FSL_FEATURE_USB_KHCI_KEEP_ALIVE_ENABLED &amp;gt; 0U) &amp;amp;&amp;amp; \
    defined(USB_DEVICE_CONFIG_KEEP_ALIVE_MODE) &amp;amp;&amp;amp; (USB_DEVICE_CONFIG_KEEP_ALIVE_MODE &amp;gt; 0U) &amp;amp;&amp;amp;             \
    defined(FSL_FEATURE_USB_KHCI_USB_RAM) &amp;amp;&amp;amp; (FSL_FEATURE_USB_KHCI_USB_RAM &amp;gt; 0U)
                    s_waitForDataReceive = 1;
                    USB0-&amp;gt;INTEN &amp;amp;= ~USB_INTEN_SOFTOKEN_MASK;
#endif
                }
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333"&gt;For cases &lt;EM&gt;kUSB_DeviceCdcEventSendResponse &lt;/EM&gt;and &lt;EM&gt;kUSB_DeviceCdcEventRecvResponse&lt;/EM&gt;, in the &lt;EM&gt;USB_DeviceCdcAcmRecv&lt;/EM&gt; function call, endpoint index 0 is used to get max packet size&amp;nbsp; (&lt;EM&gt;g_UsbDeviceCdcVcomDicEndpoints[&lt;STRONG&gt;0&lt;/STRONG&gt;].maxPacketSize&lt;/EM&gt;). However, this call reference BULK_OUT endpoint which is define at index 1 of g_UsbDeviceCdcVcomDicEndpoints variable:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/* Define endpoint for data class */
usb_device_endpoint_struct_t g_UsbDeviceCdcVcomDicEndpoints[USB_CDC_VCOM_ENDPOINT_DIC_COUNT] = {
    {
        USB_CDC_VCOM_BULK_IN_ENDPOINT | (USB_IN &amp;lt;&amp;lt; 7U), USB_ENDPOINT_BULK, FS_CDC_VCOM_BULK_IN_PACKET_SIZE, 0U,
    },
    {
        USB_CDC_VCOM_BULK_OUT_ENDPOINT | (USB_OUT &amp;lt;&amp;lt; 7U), USB_ENDPOINT_BULK, FS_CDC_VCOM_BULK_OUT_PACKET_SIZE, 0U,
    }};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333"&gt;Shouldn't it be index 1 (&lt;EM&gt;g_UsbDeviceCdcVcomDicEndpoints[&lt;STRONG&gt;1&lt;/STRONG&gt;].maxPacketSize)&lt;/EM&gt; passed in parameter to the function ? In this case it won't change anything as both max packet size for BULK_IN and BULK_OUT have the same value but I just want to clarify my understanding of USB stack.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333"&gt;Thanks&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333"&gt;Hugio&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:32:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Error-in-USB-VCOM-CDC-example/m-p/1160821#M10325</guid>
      <dc:creator>h_bouchard</dc:creator>
      <dc:date>2020-09-29T16:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Error in USB VCOM CDC example ?</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Error-in-USB-VCOM-CDC-example/m-p/1162335#M10364</link>
      <description>&lt;P&gt;Hi Hugio,&lt;/P&gt;
&lt;P&gt;I checked this and I agree with you. Even though there is no much consequence as this is an error scenario, the index should be 1. Thanks for pointing this out for us.&lt;/P&gt;
&lt;P&gt;Have a great day,&lt;/P&gt;
&lt;P&gt;Felipe&lt;/P&gt;
&lt;P&gt;-------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;Note:&lt;/P&gt;
&lt;P&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;
&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored. Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;/P&gt;
&lt;P&gt;------------------------------------------------------------------------------&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 15:38:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Error-in-USB-VCOM-CDC-example/m-p/1162335#M10364</guid>
      <dc:creator>FelipeGarcia</dc:creator>
      <dc:date>2020-10-02T15:38:45Z</dc:date>
    </item>
  </channel>
</rss>

