Macros
Description
Macros.
Macros |
|
#define | USBX_STRING_DESC (_name, ...) |
Macro for creating USB-Compliant UTF-16LE UNICODE string descriptor.
|
|
#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 | 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.
|
|
Macro Definition Documentation
◆ USBX_STRING_DESC
#define USBX_STRING_DESC | ( |
_name,
|
|
...
|
|||
) |
Value:
SL_PACK_START(1) \
typedef
struct
\
{ \
uint8_t len; \
uint8_t type; \
char16_t name[1 +
sizeof
((
char16_t
[]){ __VA_ARGS__ }) / 2]; \
} SL_ATTRIBUTE_PACKED _##_name; \
SL_PACK_END() \
SL_ALIGN(4) \
SL_PACK_START(1) \
static
const
_##_name _name SL_ATTRIBUTE_ALIGN(4) = \
{ \
.len =
sizeof
(_##_name) - 2, \
.type = 3, \
.name = { __VA_ARGS__ }, \
.name[((
sizeof
(_##_name) - 2) / 2) - 1] =
'\0'
\
} \
SL_PACK_END()
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.
◆ USBX_BUF
#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.
◆ STATIC_USBX_BUF
#define STATIC_USBX_BUF | ( |
x,
|
|
y
|
|||
) |
Value:
SL_ALIGN(4) \
static uint8_t x[((y) + 3) & ~3] SL_ATTRIBUTE_ALIGN(4)
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.