USB Generic HID Device Example Code - What is the benefit of enabling the double buffer?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

USB Generic HID Device Example Code - What is the benefit of enabling the double buffer?

1,711件の閲覧回数
nbgatgi
Contributor IV

I'm using the LPCXpresso54608 SDK for MCUXpresso.  In particular, I'm running the generic HID device with FreeRTOS example code (link to my code/setup).

One of the settings is to enable the double buffer in usb_device_lpcip3511.h:

#define USB_DEVICE_IP3511_DOUBLE_BUFFER_ENABLE (1u)

The double buffer is enabled by default.  It seems to add a layer of complexity that I'm not sure I need, and I'm not so sure it is even working correctly with the example!

Could someone enlighten me on the purpose/intended use of the double buffer?

2 返答(返信)

1,487件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi Nick:

Double buffering is used for more efficient transfers.

Data in one buffer are being processed while the next set of data is read into the other one.

I hope it helps.

Regards

Daniel

0 件の賞賛
返信

1,487件の閲覧回数
nbgatgi
Contributor IV

I should have been more clear in my question.  I generally understand the purpose of double-buffering.  I'm looking for more of a walk-through of this particular implementation.  I can see the buffer index toggle, and see that every packet received goes into the alternate buffer, but within "USB_DeviceHidGenericCallback", the case "kUSB_DeviceHidEventRecvResponse" first calls "USB_DeviceHidSend" without toggling the buffer index, which echoes the data received the the IN-ENDPOINT (to the PC).  Right after that, the buffer index is toggled which generally makes sense to me.  THEN "USB_DeviceHidRecv" is called using the newly toggled buffer index.  WHAT IS THIS DOING?!?!

0 件の賞賛
返信