STR7/STR9 USB firmware library UM0290
10/76
4. Double-buffered endpoint functions: To obtain high data transfer throughput in bulk
or isochronous modes, double-buffered mode has to be programmed.
In this operating mode some fields of the endpoint registers and buffer description table
cells have different meanings.
To ease the use of this feature, several functions have been developed.
SetEPDoubleBuff: An endpoint programmed to work in bulk mode can be set as
double-buffered by setting the EP-KIND bit. The function SetEPDoubleBuff()
accomplishes this task.
SetEPDoubleBuff : void SetEPDoubleBuff(u8 bEpNum);
bEpNum = endpoint number
FreeUserBuffer: In double-buffered mode the endpoints become mono-directional and
buffer description table cells of the unused direction are applied to handle a second
buffer.
Addresses and counters must be handled in a different way. Rx and Tx Addresses and
counter cells become Buffer0 and Buffer1 cells. Functions dedicated to this operating
mode are provided for in the library.
During a bulk transfer the line fills one buffer while the other buffer is reserved to the
application. A user application has to process data before the arrival of bulk needing a
buffer. The buffer reserved to the application has to be freed in time.
To free the buffer in use from the application the FreeUserBuffer function is
provided:
FreeUserBuffer: void FreeUserBuffer(u8 bEpNum, u8 bDir);
bEpNum = endpoint number
a) Double buffer addresses
These functions set or get the buffer address value in the buffer description table
for double buffered mode.
SetEPDblBuffAddr : void SetEPDblBuffAddr(u8 bEpNum,u16
wBuf0Addr,u16 wBuf1Addr);
SetEPDblbuf0Addr : void SetEPDblBuf0Addr(u8 bEpNum,u16 wBuf0Addr);
SetEPDblbuf1Addr : void SetEPDblBuf1Addr(u8 bEpNum,u16 wBuf1Addr);
bEpNum = endpoint number
wBuf0Addr, wBuf1Addr = buffer addresses (expressed as PMA buffer
addresses)
GetEPDblBuf0Addr : u16 GetEPDblBuf0Addr(u8 bEpNum);
GetEPDblbuf1Addr : u16 GetEPDblBuf1Addr(u8 bEpNum);
bEpNum = endpoint number
return value : buffer addresses
b) Double buffer counters
These functions set or get the buffer counter value in the buffer description table
for double buffered mode.
SetEPDblBuffCount: void SetEPDblBuffCount(u8 bEpNum, u8 bDir, u16
wCount);
SetEPDblBuf0Count: void SetEPDblBuf0Count(u8 bEpNum, u8 bDir, u16
wCount);
SetEPDblBuf1Count: void SetEPDblBuf1Count(u8 bEpNum, u8 bDir, u16