38.6.1.5 DPRAM Management
Pipes and endpoints can only be allocated in ascending order, from pipe/endpoint 0 to the last pipe/endpoint to be allocated. The user should therefore configure them in the same order.
The allocation of a pipe/endpoint x starts when the Endpoint Memory Allocate bit in the Endpoint x Configuration register (USBHS_DEVEPTCFGx.ALLOC) is written to one. Then, the hardware allocates a memory area in the DPRAM and inserts it between the x - 1 and x+ 1 pipes/endpoints. The x+ 1 pipe/endpoint memory window slides up and its data is lost. Note that the following pipe/endpoint memory windows (from x+ 2) do not slide.
Disabling a pipe, by writing a zero to the Pipe x Enable bit in the Host Pipe register (USBHS_HSTPIP.PENx), or disabling an endpoint, by writing a zero to the Endpoint x Enable bit in the Device Endpoint register (USBHS_DEVEPT.EPENx), does not reset the USBHS_DEVEPTCFGx.ALLOC bit or the Pipe/Endpoint configuration:
- Pipe Configuration
- Pipe Banks (USBHS_HSTPIPCFGx.PBK)
- Pipe Size (USBHS_HSTPIPCFGx.PSIZE)
- Pipe Token (USBHS_HSTPIPCFGx.PTOKEN)
- Pipe Type (USBHS_HSTPIPCFGx.PTYPE)
- Pipe Endpoint Number (USBHS_HSTPIPCFGx.PEPNUM)
- Pipe Interrupt Request Frequency (USBHS_HSTPIPCFGx.INTFRQ)
- Endpoint Configuration
- Endpoint Banks (USBHS_DEVEPTCFGx.EPBK)
- Endpoint Size (USBHS_DEVEPTCFGx. EPSIZE)
- Endpoint Direction (USBHS_DEVEPTCFGx.EPDIR)
- Endpoint Type (USBHS_DEVEPTCFGx.EPTYPE)
To free endpoint memory, the user must write a zero to the USBHS_DEVEPTCFGx.ALLOC bit. The x+ 1 pipe/endpoint memory window then slides down and its data is lost. Note that the following pipe/endpoint memory windows (from x + 2) do not slide.
The following figure illustrates the allocation and reorganization of the DPRAM in a typical example.