AnsweredAssumed Answered

Can we pass buffer defined in the local SRAM to the function call USBD_API->hw->ReadEP when we use USBD ROM stack for generic HID device?

Question asked by S S on Mar 8, 2019
Latest reply on Mar 10, 2019 by jeremyzhou

Hi,

When we use the USBD ROM STACK in LPC4357, can we pass a buffer which is defined in the local SRAM (refer LP4357 memory map 0x1000 0000 -- ) to the function call USBD_API->hw->ReadEP

 or should it only be in AHB SRAM (0x2000 0000 ) . The same question for the function call USBD_API->hw->WriteEP.

 

Example

In hid_generic .c

 

Char outbuffer[64] ;

Char inbuffer[64];

 

Somewhere in our EpHandler

 USBD_API->hw->ReadEP(hUsb, pHidCtrl->epout_adr, outbuffer);

USBD_API->hw->WriteEP(hUsb, pHidCtrl->epin_adr, inbuffer, 64);

 

 

Or do we need to do the following way.

uint8_t *outbuffer;

uint8_t *inbuffer;

During the initialization

hid_param.mem_base = USB_STACK_MEMBASE ;   //0x2000 0000  -- of course done much elegantly but this what the code does.

 

hid_param.mem_size = 0x2000;

outbuffer =  (uint8_t *) hid_param.mem_base;

hid_param.mem_base += 64;

hid_param.mem_size += 64;

inbuffer = (uint8_t *) hid_param.mem_base;

hid_param.mem_base += 64;

 

hid_param.mem_size += 64;

 

In the sample hid_generic.c the memory size is also updated (hid_param.mem_size += 64). Why is it required?

 Thanks

Outcomes