EFR32 Blue Gecko 12 Software Documentation  efr32bg12-doc-5.1.2
Macros

Detailed Description

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. More...
 
#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. More...
 
#define USBX_STRING_DESC(_name, ...)
 Macro for creating USB-Compliant UTF-16LE UNICODE string descriptor. More...
 

Macro Definition Documentation

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

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 218 of file em_usbxpress.h.

#define USBX_BUF (   x,
 
)    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 204 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()
Macro for handling packed structs. Use this macro after the struct definition. With GCC...
Definition: em_common.h:157
#define SL_ALIGN(X)
Macro for aligning a variable. Use this macro before the variable definition. X denotes the stora...
Definition: em_common.h:168
#define SL_PACK_START(x)
Macro for handling packed structs. Use this macro before the struct definition. X denotes the max...
Definition: em_common.h:150
#define SL_ATTRIBUTE_ALIGN(X)
GCC style macro for aligning a variable.
Definition: em_common.h:160
#define SL_ATTRIBUTE_PACKED
GCC style macro for handling packed structs.
Definition: em_common.h:143

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 173 of file em_usbxpress.h.