There's no specific API to get the DMA buffer count.
If you are using MANUAL channel, there is a possibility of getting the buffer count in a way but if AUTO channel is being used, there's no way to get the count.
Please follow the steps below to get the buffer count:
1.) Declare a global array variable ( let's say uint32_t count __attribute__ ((aligned (32))).
2.)Also, create another global variable to store the buffer counter value ( let's say uint8_t bufCount = 0).
3.)Change the dmaCfg.notification = CY_U3P_DMA_CB_PROD_EVENT | CY_U3P_DMA_CB_CONS_EVENT;
4.) Whenever the master writes data to the GPIF block, a CY_U3P_DMA_CB_PROD_EVENT will be generated in the CyFxSlFifoUtoPDmaCallback () API and that buffer will get committed to the USB block.
5.) Increment the variable here=> bufCount++ after the commitbuffer API is called and assign the value of bufCount to the first location of the array using count = bufCount .
6.) Add another if condition in the same API with else if (type == CY_U3P_DMA_CB_CONS_EVENT) and just decrement the variable here => bufCount-- and assign the value ot the first element of the array as count = bufCount .
7.) In the CyFxSlFifoApplnUSBSetupCB() , create a else if (bType == CY_U3P_USB_VENDOR_RQT).
8.) In the else if, add if (bRequest == 0xAC) and in that if condition, we will send the data of bufCount to the host by using CyU3PUsbSendEP0Data (8, (uint32_t *)count); and then close the if condition.
9.) Now, if you send 0xAC ( can be changed to any hex value) over the control endpoint at any point of time, there will be a count value of the buffers that are yet to be committed which can help you decide how much data should be requested in the URB.