STM32F10xxx USB firmware library UM0424 - User manual
10/59
Buffer description table functions
These functions are used in order to set or get the endpoints’ receive and transmit buffer
addresses and sizes.
a) Tx/Rx buffer address fields
SetEPTxAddr : void SetEPTxAddr(u8 bEpNum,u16 wAddr);
SetEPRxAddr : void SetEPRxAddr(u8 bEpNum,u16 wAddr);
bEpNum = endpoint number
wAddr = address to be set (expressed as PMA buffer address)
GetEPTxAddr : u16 GetEPTxAddr(u8 bEpNum);
GetEPRxAddr : u16 GetEPRxAddr(u8 bEpNum);
bEpNum = endpoint number
return value : address value (expressed as PMA buffer address)
b) Tx/Rx buffer counter fields
SetEPTxCount : void SetEPTxCount(u8 bEpNum,u16 wCount);
SetEPRxCount : void SetEPRxCount(u8 bEpNum,u16 wCount);
bEpNum = endpoint number
wCount = counter to be set
GetEPTxCount : u16 GetEPTxCount(u8 bEpNum);
GetEPRxCount : u16 GetEPRxCount(u8 bEpNum);
bEpNum = endpoint number
return value : counter value
Double-buffered endpoints 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