]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/SilLabs_Code/emlib/inc/em_common.h
Add EFM32 Giant Gecko Starter Kit demo - still a work in progress as the low power...
[freertos] / FreeRTOS / Demo / CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio / Source / SilLabs_Code / emlib / inc / em_common.h
1 /***************************************************************************//**\r
2  * @file em_common.h\r
3  * @brief EFM32 general purpose utilities.\r
4  * @version 4.0.0\r
5  *******************************************************************************\r
6  * @section License\r
7  * <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>\r
8  *******************************************************************************\r
9  *\r
10  * Permission is granted to anyone to use this software for any purpose,\r
11  * including commercial applications, and to alter it and redistribute it\r
12  * freely, subject to the following restrictions:\r
13  *\r
14  * 1. The origin of this software must not be misrepresented; you must not\r
15  *    claim that you wrote the original software.\r
16  * 2. Altered source versions must be plainly marked as such, and must not be\r
17  *    misrepresented as being the original software.\r
18  * 3. This notice may not be removed or altered from any source distribution.\r
19  *\r
20  * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no\r
21  * obligation to support this Software. Silicon Labs is providing the\r
22  * Software "AS IS", with no express or implied warranties of any kind,\r
23  * including, but not limited to, any implied warranties of merchantability\r
24  * or fitness for any particular purpose or warranties against infringement\r
25  * of any proprietary rights of a third party.\r
26  *\r
27  * Silicon Labs will not be liable for any consequential, incidental, or\r
28  * special damages, or any other relief, or for any claim by any third party,\r
29  * arising from your use of this Software.\r
30  *\r
31  ******************************************************************************/\r
32 \r
33 \r
34 #ifndef __SILICON_LABS_EM_COMMON_H_\r
35 #define __SILICON_LABS_EM_COMMON_H_\r
36 \r
37 #include <stdint.h>\r
38 #include <stdbool.h>\r
39 \r
40 \r
41 #ifdef __cplusplus\r
42 extern "C" {\r
43 #endif\r
44 \r
45 /***************************************************************************//**\r
46  * @addtogroup EM_Library\r
47  * @{\r
48  ******************************************************************************/\r
49 \r
50 /***************************************************************************//**\r
51  * @addtogroup COMMON\r
52  * @brief EFM32 general purpose utilities.\r
53  * @{\r
54  ******************************************************************************/\r
55 \r
56 #if !defined(__GNUC__)\r
57 \r
58 /** Macro for getting minimum value. */\r
59 #define EFM32_MIN(a, b)    ((a) < (b) ? (a) : (b))\r
60 /** Macro for getting maximum value. */\r
61 #define EFM32_MAX(a, b)    ((a) > (b) ? (a) : (b))\r
62 \r
63 /** Macros for handling packed structs. */\r
64 #define STRINGIZE(X) #X\r
65 #define EFM32_PACK_START(X) _Pragma( STRINGIZE( pack( X ) ) )\r
66 #define EFM32_PACK_END()    _Pragma( "pack()" )\r
67 #define __attribute__(...)\r
68 \r
69 #ifdef __CC_ARM\r
70 /** Macros for handling aligned structs. */\r
71 #define EFM32_ALIGN(X) __align(X)\r
72 #endif\r
73 #ifdef __ICCARM__\r
74 /** Macros for handling aligned structs. */\r
75 #define EFM32_ALIGN(X) _Pragma( STRINGIZE( data_alignment=X ) )\r
76 #endif\r
77 \r
78 #else\r
79 \r
80 /** Macro for getting minimum value. No sideeffects, a and b are evaluated once only. */\r
81 #define EFM32_MIN(a, b)    ({ __typeof__(a) _a = (a); __typeof__(b) _b = (b); _a < _b ? _a : _b; })\r
82 /** Macro for getting maximum value. No sideeffects, a and b are evaluated once only. */\r
83 #define EFM32_MAX(a, b)    ({ __typeof__(a) _a = (a); __typeof__(b) _b = (b); _a > _b ? _a : _b; })\r
84 \r
85 /** Macro for handling packed structs.\r
86  *  @n Use this macro before the struct definition.\r
87  *  @n X denotes the maximum alignment of struct members. X is not supported on\r
88  *  gcc, gcc always use 1 byte maximum alignment.\r
89  */\r
90 #define EFM32_PACK_START( x )\r
91 \r
92 /** Macro for handling packed structs.\r
93  *  @n Use this macro after the struct definition.\r
94  *  @n On gcc add __attribute__ ((packed)) after the closing } of the struct\r
95  *  definition.\r
96  */\r
97 #define EFM32_PACK_END()\r
98 \r
99 /** Macro for aligning a variable.\r
100  *  @n Use this macro before the variable definition.\r
101  *  @n X denotes the storage alignment value in bytes.\r
102  *  @n On gcc use __attribute__ ((aligned(X))) before the ; on normal variables.\r
103  *  Use __attribute__ ((aligned(X))) before the opening { on struct variables.\r
104  */\r
105 #define EFM32_ALIGN(X)\r
106 \r
107 #endif\r
108 \r
109 /** @} (end addtogroup COMMON) */\r
110 /** @} (end addtogroup EM_Library) */\r
111 \r
112 #ifdef __cplusplus\r
113 }\r
114 #endif\r
115 \r
116 #endif /* __SILICON_LABS_EM_COMMON_H_ */\r