diff options
| author | hathach <[email protected]> | 2018-08-21 14:51:59 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-08-21 14:51:59 +0700 |
| commit | 7b35cd0203bc409d7c1aefc075672103cb4a913e (patch) | |
| tree | 30851c68b2833d9e73e59caedafcf3ecbdbfd97e /src | |
| parent | d996bd529591c98f366ddedbde63ac21755996e2 (diff) | |
add string desc helper
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/tusb_types.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h index c3ed4f2bd..ee9e849bf 100644 --- a/src/common/tusb_types.h +++ b/src/common/tusb_types.h @@ -416,9 +416,14 @@ static inline uint8_t descriptor_len(uint8_t const p_desc[]) return p_desc[DESC_OFFSET_LEN];
}
+// Length of the string descriptors in bytes with slen characters
+#define TUD_DESC_STRLEN(_slen) (2*(_slen) + 2)
+
+// Header of string descriptors with len + string type
+#define TUD_DESC_STR_HEADER(_slen) ( (uint16_t) ( (TUSB_DESC_STRING << 8 ) | TUD_DESC_STRLEN(_slen)) )
// Convert comma-separated string to descriptor unicode format
-#define TUD_DESC_STRCONV( ... ) (const uint16_t[]) { (TUSB_DESC_STRING << 8 ) | (2*VA_ARGS_NUM_(__VA_ARGS__) + 2), __VA_ARGS__ }
+#define TUD_DESC_STRCONV( ... ) (const uint16_t[]) { TUD_DESC_STR_HEADER(VA_ARGS_NUM_(__VA_ARGS__)), __VA_ARGS__ }
#ifdef __cplusplus
}
|
