Mistake on this page?
Report an issue in GitHub or email us
stm32_wpan_common.h
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  * @file stm32_wpan_common.h
4  * @author MCD Application Team
5  * @brief Common file to utilities
6  ******************************************************************************
7  * @attention
8  *
9  * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
10  * All rights reserved.</center></h2>
11  *
12  * This software component is licensed by ST under BSD 3-Clause license,
13  * the "License"; You may not use this file except in compliance with the
14  * License. You may obtain a copy of the License at:
15  * opensource.org/licenses/BSD-3-Clause
16  *
17  ******************************************************************************
18  */
19 
20 
21 /* Define to prevent recursive inclusion -------------------------------------*/
22 #ifndef __STM32_WPAN_COMMON_H
23 #define __STM32_WPAN_COMMON_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include <stdint.h>
30 #include <string.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <stdarg.h>
34 
35  /* -------------------------------- *
36  * Basic definitions *
37  * -------------------------------- */
38 
39 #undef NULL
40 #define NULL 0U
41 
42 #undef FALSE
43 #define FALSE 0U
44 
45 #undef TRUE
46 #define TRUE (!0U)
47 
48  /* -------------------------------- *
49  * Critical Section definition *
50  * -------------------------------- */
51 #undef BACKUP_PRIMASK
52 #define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK()
53 
54 #undef DISABLE_IRQ
55 #define DISABLE_IRQ() __disable_irq()
56 
57 #undef RESTORE_PRIMASK
58 #define RESTORE_PRIMASK() __set_PRIMASK(primask_bit)
59 
60  /* -------------------------------- *
61  * Macro delimiters *
62  * -------------------------------- */
63 #undef M_BEGIN
64 #define M_BEGIN do {
65 
66 #undef M_END
67 #define M_END } while(0)
68 
69  /* -------------------------------- *
70  * Some useful macro definitions *
71  * -------------------------------- */
72 #undef MAX
73 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
74 
75 #undef MIN
76 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
77 
78 #undef MODINC
79 #define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END
80 
81 #undef MODDEC
82 #define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END
83 
84 #undef MODADD
85 #define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END
86 
87 #undef MODSUB
88 #define MODSUB( a, b, m ) MODADD( a, (m)-(b), m )
89 
90 #undef ALIGN
91 #ifdef WIN32
92 #define ALIGN(n)
93 #else
94 #define ALIGN(n) __attribute__((aligned(n)))
95 #endif
96 
97 #undef PAUSE
98 #define PAUSE( t ) M_BEGIN \
99  volatile int _i; \
100  for ( _i = t; _i > 0; _i -- ); \
101  M_END
102 #undef DIVF
103 #define DIVF( x, y ) ((x)/(y))
104 
105 #undef DIVC
106 #define DIVC( x, y ) (((x)+(y)-1)/(y))
107 
108 #undef DIVR
109 #define DIVR( x, y ) (((x)+((y)/2))/(y))
110 
111 #undef SHRR
112 #define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1)
113 
114 #undef BITN
115 #define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1)
116 
117 #undef BITNSET
118 #define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END
119 
120 /* -------------------------------- *
121  * Section attribute *
122  * -------------------------------- */
123 #undef PLACE_IN_SECTION
124 #define PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
125 
126 /* ----------------------------------- *
127  * Packed usage (compiler dependent) *
128  * ----------------------------------- */
129 #undef PACKED__
130 #undef PACKED_STRUCT
131 
132 #if defined ( __CC_ARM )
133  #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050U)
134  #define PACKED__ __attribute__((packed))
135  #define PACKED_STRUCT struct PACKED__
136  #else
137  #define PACKED__(TYPE) __packed TYPE
138  #define PACKED_STRUCT PACKED__(struct)
139  #endif
140 #elif defined ( __GNUC__ )
141  #define PACKED__ __attribute__((packed))
142  #define PACKED_STRUCT struct PACKED__
143 #elif defined (__ICCARM__)
144  #define PACKED_STRUCT __packed struct
145 #elif
146  #define PACKED_STRUCT __packed struct
147 #endif
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #endif /*__STM32_WPAN_COMMON_H */
154 
155 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.