-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathuic_enum.h
85 lines (78 loc) · 2.2 KB
/
uic_enum.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/******************************************************************************
* # License
* <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
******************************************************************************
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
*****************************************************************************/
/**
* @defgroup unify_enums Unify Enums types
* @ingroup unify_definitions
* @brief Contains defines to make enums with specified underlying types
*
* @{
*/
#ifndef UIC_ENUM_H
#define UIC_ENUM_H
#include <inttypes.h>
/**
* @brief Enum with <type> as size, where type may be any integer type
*
* Usage:
* typedef enum {
* MY_ENTRY_1,
* MY_ENTRY_2,
* MY_ENTRY_X
* ) UIC_ENUM(my_type, int16_t);
* my_type x; //<< this will be of type int16_6
* my_type_enum y; //<< this will be of enum type
*/
#define UIC_ENUM(name, type) \
name_enum; \
typedef type name
/**
* @brief Enum with 8 bit size
*
* Usage:
* typedef enum {
* MY_ENTRY_1,
* MY_ENTRY_2,
* MY_ENTRY_X
* ) UIC_ENUM8(my_type);
* my_type x; //<< this will be of type uint8_t
* my_type_enum y; //<< this will be of enum type
*/
#define UIC_ENUM8(name) UIC_ENUM(name, uint8_t)
/**
* @brief Enum with 16 bit size
*
* Usage:
* typedef enum {
* MY_ENTRY_1,
* MY_ENTRY_2,
* MY_ENTRY_X
* ) UIC_ENUM16(my_type);
* my_type x; //<< this will be of type uint16_t
* my_type_enum y; //<< this will be of enum type
*/
#define UIC_ENUM16(name) UIC_ENUM(name, uint16_t)
/**
* @brief Enum with 32 bit size
*
* Usage:
* typedef enum {
* MY_ENTRY_1,
* MY_ENTRY_2,
* MY_ENTRY_X
* ) UIC_ENUM32(my_type);
* my_type x; //<< this will be of type uint32_t
* my_type_enum y; //<< this will be of enum type
*/
#define UIC_ENUM32(name) UIC_ENUM(name, uint32_t)
#endif //UIC_ENUM_H
/** @} end uic_enum */