RKH
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rkhdef.h
Go to the documentation of this file.
1 /*
2  * --------------------------------------------------------------------------
3  *
4  * Framework RKH
5  * -------------
6  *
7  * State-machine framework for reactive embedded systems
8  *
9  * Copyright (C) 2010 Leandro Francucci.
10  * All rights reserved. Protected by international copyright laws.
11  *
12  *
13  * RKH is free software: you can redistribute it and/or modify it under the
14  * terms of the GNU General Public License as published by the Free Software
15  * Foundation, either version 3 of the License, or (at your option) any
16  * later version.
17  *
18  * RKH is distributed in the hope that it will be useful, but WITHOUT ANY
19  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21  * more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with RKH, see copying.txt file.
25  *
26  * Contact information:
27  * RKH web site: http://sourceforge.net/projects/rkh-reactivesys/
28  * e-mail: francuccilea@gmail.com
29  * ---------------------------------------------------------------------------
30  */
31 
50 /* -------------------------- Development history -------------------------- */
51 /*
52  * 2015.10.24 LeFr v2.4.05 Initial version
53  */
54 
55 /* -------------------------------- Authors -------------------------------- */
56 /*
57  * LeFr Leandro Francucci francuccilea@gmail.com
58  */
59 
60 /* --------------------------------- Notes --------------------------------- */
61 /* --------------------------------- Module -------------------------------- */
62 #ifndef __RKHDEF_H__
63 #define __RKHDEF_H__
64 
65 /* ----------------------------- Include files ----------------------------- */
66 /* ---------------------- External C language linkage ---------------------- */
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
71 /* --------------------------------- Macros -------------------------------- */
72 /*
73  * Bit's macros.
74  */
75 
87 #define RKH_BIT(bit) (1u << (bit))
88 
100 #define RKH_BIT08(bit) ((rui8_t)((rui8_t) 1u << (bit)))
101 #define RKH_BIT16(bit) ((rui16_t)((rui16_t) 1u << (bit)))
102 #define RKH_BIT32(bit) ((rui32_t)((rui32_t) 1u << (bit)))
103 
117 #define RKH_BIT_MASK(bit_mask, bit_shift) \
118  ((bit_mask) << (bit_shift))
119 
132 #define RKH_BIT_MASK_08(bit_mask, bit_shift) \
133  ((rui8_t)((rui8_t)(bit_mask) << (bit_shift)))
134 #define RKH_BIT_MASK_16(bit_mask, bit_shift) \
135  ((rui16_t)((rui16_t)(bit_mask) << (bit_shift)))
136 #define RKH_BIT_MASK_32(bit_mask, bit_shift) \
137  ((rui32_t)((rui32_t)(bit_mask) << (bit_shift)))
138 
152 #define RKH_BIT_SET_08(val, mask) \
153  ((val) = (rui8_t)(((rui8_t)(val)) | ((rui8_t)(mask))))
154 #define RKH_BIT_SET_16(val, mask) \
155  ((val) = (rui16_t)(((rui16_t)(val)) | ((rui16_t)(mask))))
156 #define RKH_BIT_SET_32(val, mask) \
157  ((val) = (rui32_t)(((rui32_t)(val)) | ((rui32_t)(mask))))
158 
172 #define RKH_BIT_CLR_08(val, mask) \
173  ((val) = (rui8_t)(((rui8_t)(val)) & ((rui8_t) ~(mask))))
174 #define RKH_BIT_CLR_16(val, mask) \
175  ((val) = (rui16_t)(((rui16_t)(val)) & ((rui16_t) ~(mask))))
176 #define RKH_BIT_CLR_32(val, mask) \
177  ((val) = (rui32_t)(((rui32_t)(val)) & ((rui32_t) ~(mask))))
178 
193 #define RKH_BIT_IS_SET(val, mask) \
194  ((((mask) != 0u) && \
195  (((val) & (mask)) == (mask))) ? (RKH_YES) : (RKH_NO))
196 
210 #define RKH_BIT_IS_CLR(val, mask) \
211  ((((mask) != 0u) && \
212  (((val) & (mask)) == 0u)) ? (RKH_YES) : (RKH_NO))
213 
227 #define RKH_BIT_IS_SET_ANY(val, mask) \
228  ((((val) & (mask)) == 0u) ? (RKH_NO) : (RKH_YES))
229 
243 #define RKH_BIT_IS_CLR_ANY(val, mask) \
244  ((((val) & (mask)) == (mask)) ? (RKH_NO) : (RKH_YES))
245 
246 /* -------------------------------- Constants ------------------------------ */
247 #define RKH_NULL ((void *) 0)
248 
255 #define RKH_FALSE 0u
256 #define RKH_TRUE 1u
257 
258 #define RKH_NO 0u
259 #define RKH_YES 1u
260 
261 #define RKH_DISABLED 0u
262 #define RKH_ENABLED 1u
263 
264 #define RKH_INACTIVE 0u
265 #define RKH_ACTIVE 1u
266 
267 #define RKH_INVALID 0u
268 #define RKH_VALID 1u
269 
270 #define RKH_OFF 0u
271 #define RKH_ON 1u
272 
273 #define RKH_CLR 0u
274 #define RKH_SET 1u
275 
276 #define RKH_FAIL 0u
277 #define RKH_OK 1u
278 
280 /* ------------------------------- Data types ------------------------------ */
281 /* -------------------------- External variables --------------------------- */
282 /* -------------------------- Function prototypes -------------------------- */
283 /* -------------------- External C language linkage end -------------------- */
284 #ifdef __cplusplus
285 }
286 #endif
287 
288 /* ------------------------------ Module end ------------------------------- */
289 #endif
290 
291 /* ------------------------------ End of file ------------------------------ */