cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

Corrado90
New Contributor

Dear community,

I have to implement a virtual COM with the FX3 as an alternative to the UART module for the cyfx3s_fatfs example; so I need a set of API similar to CyU3PUartReceiveBytes and CyU3PUartTransmitBytes and the possibility to write buffer with DMA (as in cyfx3s_fatfs) but working through an USB Virtual COM.
I started working with UsbUart example by modifing the DMA configuration and sockets (in attached) to use the "void CyFxUartSendBuffer(uint8_t *Buffer_Print,uint8_t cnt_read)" function, but without results.
Please, someone could give me some ideas or code example?
Consider that is my first time with this MCU, this architecture and in general with the USB.

Many thanks in advance, regards,
Corrado90

0 Likes
1 Solution
Hemanth
Moderator
Moderator

Hi Corrado90,

In the attached firmware, you can comment the following section as you are not using UART block:

if (glIsApplnActive)
        {
            /* While the application is active, check for data sent during the last 50 ms. If no data
               has been sent to the host, use the channel wrap-up feature to send any partial buffer to
               the USB host.
            */
            if (glPktsPending == 0)
            {
                /* Disable UART Receiver Block */
                UART->lpp_uart_config = regValueDs;

                CyU3PDmaChannelSetWrapUp (&glChHandleUarttoUsb);

                /* Enable UART Receiver Block */
                UART->lpp_uart_config = regValueEn;
            }

            glPktsPending = 0;
        }

In CyFxUartSendBuffer(), you cannot use APIs CyU3PDmaChannelSetupSendBuffer() and CyU3PDmaChannelWaitForCompletion() - as they are for DMA override mode. Please refer https://community.cypress.com/t5/Knowledge-Base-Articles/DMA-Channel-in-Override-Mode-in-FX3-CX3-KBA...

Instead you can use CyU3PDmaChannelCommitBuffer() when you get DMA callback. When you are not using override mode, for MANUAL_IN channel you get PROD event when a DMA buffer is available from producer and for MANUAL_OUT you get CONS event when a buffer is consumed by consumer. For these events to be available you can refer to UsbBulkSrcSink example of FX3 SDK (You can only refer to DMA channel creation part and callback function part of the firmware). In your firmware you will have to take care of dmaCfg.notification and dmaCfg.cb accordingly.

For your use case, Override mode is not suitable for USB to CPU channel. For CPU to USB channel you can either go with override mode(as in the case of cyfx3s_fatfs example) or normal mode (as in UsbBulkSrcSink example).

Path for UsbBulkSrcSink: {FX3_SDK_Installation_Path}\1.3\firmware\basic_examples\cyfxbulksrcsink

Regards,

Hemanth

View solution in original post

0 Likes
3 Replies