RKH
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 site: http://vortexmakes.com/que-es/
28  * RKH GitHub: https://github.com/vortexmakes/RKH
29  * RKH Sourceforge: https://sourceforge.net/projects/rkh-reactivesys/
30  * e-mail: lf@vortexmakes.com
31  * ---------------------------------------------------------------------------
32  */
33 
51 /* -------------------------- Development history -------------------------- */
52 /*
53  * 2015.10.24 LeFr v2.4.05 Initial version
54  */
55 
56 /* -------------------------------- Authors -------------------------------- */
57 /*
58  * LeFr Leandro Francucci lf@vortexmakes.com
59  */
60 
61 /* --------------------------------- Notes --------------------------------- */
62 /* --------------------------------- Module -------------------------------- */
63 #ifndef __RKHDEF_H__
64 #define __RKHDEF_H__
65 
66 /* ----------------------------- Include files ----------------------------- */
67 /* ---------------------- External C language linkage ---------------------- */
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
72 /* --------------------------------- Macros -------------------------------- */
73 /*
74  * Bit's macros.
75  */
76 
88 #define RKH_BIT(bit) (1u << (bit))
89 
101 #define RKH_BIT08(bit) ((rui8_t)((rui8_t) 1u << (bit)))
102 #define RKH_BIT16(bit) ((rui16_t)((rui16_t) 1u << (bit)))
103 #define RKH_BIT32(bit) ((rui32_t)((rui32_t) 1u << (bit)))
118 #define RKH_BIT_MASK(bit_mask, bit_shift) \
119  ((bit_mask) << (bit_shift))
120 
133 #define RKH_BIT_MASK_08(bit_mask, bit_shift) \
134  ((rui8_t)((rui8_t)(bit_mask) << (bit_shift)))
135 #define RKH_BIT_MASK_16(bit_mask, bit_shift) \
136  ((rui16_t)((rui16_t)(bit_mask) << (bit_shift)))
137 #define RKH_BIT_MASK_32(bit_mask, bit_shift) \
138  ((rui32_t)((rui32_t)(bit_mask) << (bit_shift)))
153 #define RKH_BIT_SET_08(val, mask) \
154  ((val) = (rui8_t)(((rui8_t)(val)) | ((rui8_t)(mask))))
155 #define RKH_BIT_SET_16(val, mask) \
156  ((val) = (rui16_t)(((rui16_t)(val)) | ((rui16_t)(mask))))
157 #define RKH_BIT_SET_32(val, mask) \
158  ((val) = (rui32_t)(((rui32_t)(val)) | ((rui32_t)(mask))))
173 #define RKH_BIT_CLR_08(val, mask) \
174  ((val) = (rui8_t)(((rui8_t)(val)) & ((rui8_t) ~(mask))))
175 #define RKH_BIT_CLR_16(val, mask) \
176  ((val) = (rui16_t)(((rui16_t)(val)) & ((rui16_t) ~(mask))))
177 #define RKH_BIT_CLR_32(val, mask) \
178  ((val) = (rui32_t)(((rui32_t)(val)) & ((rui32_t) ~(mask))))
194 #define RKH_BIT_IS_SET(val, mask) \
195  ((((mask) != 0u) && \
196  (((val) & (mask)) == (mask))) ? (RKH_YES) : (RKH_NO))
197 
211 #define RKH_BIT_IS_CLR(val, mask) \
212  ((((mask) != 0u) && \
213  (((val) & (mask)) == 0u)) ? (RKH_YES) : (RKH_NO))
214 
228 #define RKH_BIT_IS_SET_ANY(val, mask) \
229  ((((val) & (mask)) == 0u) ? (RKH_NO) : (RKH_YES))
230 
244 #define RKH_BIT_IS_CLR_ANY(val, mask) \
245  ((((val) & (mask)) == (mask)) ? (RKH_NO) : (RKH_YES))
246 
247 /* -------------------------------- Constants ------------------------------ */
248 #define RKH_NULL ((void *) 0)
249 
256 #define RKH_FALSE 0u
257 #define RKH_TRUE 1u
258 
259 #define RKH_NO 0u
260 #define RKH_YES 1u
261 
262 #define RKH_DISABLED 0u
263 #define RKH_ENABLED 1u
264 
265 #define RKH_INACTIVE 0u
266 #define RKH_ACTIVE 1u
267 
268 #define RKH_INVALID 0u
269 #define RKH_VALID 1u
270 
271 #define RKH_OFF 0u
272 #define RKH_ON 1u
273 
274 #define RKH_CLR 0u
275 #define RKH_SET 1u
276 
277 #define RKH_FAIL 0u
278 #define RKH_OK 1u
281 /* ------------------------------- Data types ------------------------------ */
282 /* -------------------------- External variables --------------------------- */
283 /* -------------------------- Function prototypes -------------------------- */
284 /* -------------------- External C language linkage end -------------------- */
285 #ifdef __cplusplus
286 }
287 #endif
288 
289 /* ------------------------------ Module end ------------------------------- */
290 #endif
291 
292 /* ------------------------------ End of file ------------------------------ */