RKH
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rkhrdy.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 
38 /* -------------------------- Development history -------------------------- */
39 /*
40  * 2015.10.24 LeFr v2.4.05 Initial version
41  */
42 
43 /* -------------------------------- Authors -------------------------------- */
44 /*
45  * LeFr Leandro Francucci francuccilea@gmail.com
46  */
47 
48 /* --------------------------------- Notes --------------------------------- */
49 /* --------------------------------- Module -------------------------------- */
50 #ifndef __RKHRDY_H__
51 #define __RKHRDY_H__
52 
53 /* ----------------------------- Include files ----------------------------- */
54 #include "rkhcfg.h"
55 #include "rkhtype.h"
56 
57 /* ---------------------- External C language linkage ---------------------- */
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 /* --------------------------------- Macros -------------------------------- */
69 #define RKH_RDY_IS_EMPTY(rg) \
70  ((rg).grp == 0)
71 
78 #define RKH_RDY_ISNOT_EMPTY(rg) \
79  ((rg).grp != 0)
80 
93 #define RKH_RDY_INSERT(rg, p) \
94  (rg).grp |= rkh_maptbl[(p) >> 3]; \
95  (rg).tbl[(p) >> 3] |= rkh_maptbl[(p) & 0x07]
96 
108 #define RKH_RDY_REM(rg, p) \
109  if (((rg).tbl[(p) >> 3] &= ~rkh_maptbl[(p) & 0x07]) == 0) \
110  (rg).grp &= ~rkh_maptbl[(p) >> 3]
111 
126 #define RKH_RDY_FIND_HIGHEST(rg, p) \
127  (p) = rkh_unmaptbl[(rg).grp]; \
128  (p) = (rui8_t)(((p) << 3) + \
129  (rui8_t)rkh_unmaptbl[(rg).tbl[(p)]])
130 
131 /* -------------------------------- Constants ------------------------------ */
132 #if RKH_CFG_FWK_MAX_SMA <= 8
133  #define RKH_NUM_RDYGRP 1
134 #elif RKH_CFG_FWK_MAX_SMA > 8 && RKH_CFG_FWK_MAX_SMA <= 16
135  #define RKH_NUM_RDYGRP 2
136 #elif RKH_CFG_FWK_MAX_SMA > 16 && RKH_CFG_FWK_MAX_SMA <= 24
137  #define RKH_NUM_RDYGRP 3
138 #elif RKH_CFG_FWK_MAX_SMA > 24 && RKH_CFG_FWK_MAX_SMA <= 32
139  #define RKH_NUM_RDYGRP 4
140 #elif RKH_CFG_FWK_MAX_SMA > 32 && RKH_CFG_FWK_MAX_SMA <= 40
141  #define RKH_NUM_RDYGRP 5
142 #elif RKH_CFG_FWK_MAX_SMA > 40 && RKH_CFG_FWK_MAX_SMA <= 48
143  #define RKH_NUM_RDYGRP 6
144 #elif RKH_CFG_FWK_MAX_SMA > 48 && RKH_CFG_FWK_MAX_SMA <= 56
145  #define RKH_NUM_RDYGRP 7
146 #elif RKH_CFG_FWK_MAX_SMA > 56 && RKH_CFG_FWK_MAX_SMA <= 64
147  #define RKH_NUM_RDYGRP 8
148 #endif
149 
150 /* ------------------------------- Data types ------------------------------ */
193 typedef struct
194 {
200  rui8_t grp;
201 
207  unsigned char tbl[RKH_NUM_RDYGRP];
208 } RKH_RG_T;
209 
210 /* -------------------- External C language linkage end -------------------- */
211 #ifdef __cplusplus
212 }
213 #endif
214 
215 /* ------------------------------ Module end ------------------------------- */
216 #endif
217 
218 /* ------------------------------ End of file ------------------------------ */
RKH user configurations.
SMA ready table.
Definition: rkhrdy.h:193
rui8_t grp
Each bit in rkhrg.grp is used to indicate whenever any SMA in a group is ready to run...
Definition: rkhrdy.h:200
Defines the data types that uses RKH.