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?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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?

742 Views
ssudhir
Contributor II

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

0 Kudos
Reply
1 Reply

689 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
In theory, it's okay to assign the stack in the local RAM, however, the variable values may overlap the USB stack area, it definitely would make the USB ROM API don't work normally.
So it's a recommended way to assign the variable values and USB stack in tow independent RAM area respectively.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- 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.
-------------------------------------------------------------------------------

0 Kudos
Reply