MacrosPlatform Middleware > USBXpress

Macros

#define STATIC_USBX_BUF (x, y)
Macro for creating WORD (4 byte) aligned static uint8_t array with size which is a multiple of WORD size.
#define USBX_BUF (x, y) SL_ALIGN (4) uint8_t x[((y) + 3) & ~3] SL_ATTRIBUTE_ALIGN (4)
Macro for creating WORD (4 byte) aligned uint8_t array with size which is a multiple of WORD size.
#define USBX_STRING_DESC (_name, ...)
Macro for creating USB-Compliant UTF-16LE UNICODE string descriptor.

Macro Definition Documentation

#define STATIC_USBX_BUF ( x,
y
)
Value:
static uint8_t x[((y) + 3) & ~3] SL_ATTRIBUTE_ALIGN (4)
#define SL_ALIGN(X)
A macro for aligning a variable. Use this macro before the variable definition. X denotes the sto...
Definition: em_common.h:190
#define SL_ATTRIBUTE_ALIGN(X)
GCC style macro for aligning a variable.
Definition: em_common.h:182

Macro for creating WORD (4 byte) aligned static uint8_t array with size which is a multiple of WORD size.


Example:
STATIC_USBX_BUF(rxBuffer, 37) ; => uint8_t rxBuffer[40];

Note
Any data buffer which is written to or read by the USB hardware must be aligned on a WORD (4 byte) boundary. This macro provides an easy way to create static USB data buffers which are guaranteed to be correctly aligned.

Definition at line 221 of file em_usbxpress.h .

#define USBX_BUF ( x,
y
) SL_ALIGN (4) uint8_t x[((y) + 3) & ~3] SL_ATTRIBUTE_ALIGN (4)

Macro for creating WORD (4 byte) aligned uint8_t array with size which is a multiple of WORD size.


Example:
USBX_BUF(rxBuffer, 37) ; => uint8_t rxBuffer[40];

Note
Any data buffer which is written to or read by the USB hardware must be aligned on a WORD (4 byte) boundary. This macro provides an easy way to create USB data buffers which are guaranteed to be correctly aligned.

Definition at line 207 of file em_usbxpress.h .

#define USBX_STRING_DESC ( _name,
...
)
Value:
typedef struct \
{ \
uint8_t len; \
uint8_t type; \
char16_t name[1 + sizeof (( char16_t []){ __VA_ARGS__ }) / 2]; \
static const _##_name _name SL_ATTRIBUTE_ALIGN (4) = \
{ \
.len = sizeof (_##_name) - 2, \
.type = 3, \
.name = { __VA_ARGS__ }, \
.name[(( sizeof (_##_name) - 2) / 2) - 1] = '\0' \
} \
#define SL_PACK_END()
A macro for handling packed structures. Use this macro after the structure definition. With GCC, add SL_ATTRIBUTE_PACKED after the closing curly braces of the structure definition.
Definition: em_common.h:179
#define SL_ALIGN(X)
A macro for aligning a variable. Use this macro before the variable definition. X denotes the sto...
Definition: em_common.h:190
#define SL_PACK_START(x)
A macro for handling packed structures. Use this macro before the structure definition. X denotes the maximum alignment of structure members. X is not supported with GCC. GCC always uses 1 byte maximum alignment.
Definition: em_common.h:172
unsigned short char16_t
Definition: em_usb.h:249
#define SL_ATTRIBUTE_ALIGN(X)
GCC style macro for aligning a variable.
Definition: em_common.h:182
#define SL_ATTRIBUTE_PACKED
A GCC style macro for handling packed structures.
Definition: em_common.h:165

Macro for creating USB-Compliant UTF-16LE UNICODE string descriptor.


Example: USBX_STRING_DESC(iManufacturer, 'S','i','l','i','c','o','n',' ' \ 'L','a','b','s');

Note
The size of the resulting struct will be two bytes larger than a USB string descriptor. This is to accommodate a terminating null char for the string. The value assigned to the 'len' member does not take this into account and is therefore correct USB-wise.

Definition at line 176 of file em_usbxpress.h .