RKH
rkhfwk_rdygrp.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 
41 /* -------------------------- Development history -------------------------- */
42 /*
43  * 2018.08.07 LeFr v3.1.00 Initial version
44  */
45 
46 /* -------------------------------- Authors -------------------------------- */
47 /*
48  * LeFr Leandro Francucci lf@vortexmakes.com
49  */
50 
51 /* --------------------------------- Notes --------------------------------- */
52 /* --------------------------------- Module -------------------------------- */
53 #ifndef __RKHFWK_RDYGRP_H__
54 #define __RKHFWK_RDYGRP_H__
55 
56 /* ----------------------------- Include files ----------------------------- */
57 #include "rkhitl.h"
58 
59 /* ---------------------- External C language linkage ---------------------- */
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 /* --------------------------------- Macros -------------------------------- */
65 /* -------------------------------- Constants ------------------------------ */
66 #if RKH_CFG_FWK_MAX_SMA <= 8
67  #define RKH_NUM_RDYGRP 1
68 #elif RKH_CFG_FWK_MAX_SMA > 8 && RKH_CFG_FWK_MAX_SMA <= 16
69  #define RKH_NUM_RDYGRP 2
70 #elif RKH_CFG_FWK_MAX_SMA > 16 && RKH_CFG_FWK_MAX_SMA <= 24
71  #define RKH_NUM_RDYGRP 3
72 #elif RKH_CFG_FWK_MAX_SMA > 24 && RKH_CFG_FWK_MAX_SMA <= 32
73  #define RKH_NUM_RDYGRP 4
74 #elif RKH_CFG_FWK_MAX_SMA > 32 && RKH_CFG_FWK_MAX_SMA <= 40
75  #define RKH_NUM_RDYGRP 5
76 #elif RKH_CFG_FWK_MAX_SMA > 40 && RKH_CFG_FWK_MAX_SMA <= 48
77  #define RKH_NUM_RDYGRP 6
78 #elif RKH_CFG_FWK_MAX_SMA > 48 && RKH_CFG_FWK_MAX_SMA <= 56
79  #define RKH_NUM_RDYGRP 7
80 #elif RKH_CFG_FWK_MAX_SMA > 56 && RKH_CFG_FWK_MAX_SMA <= 64
81  #define RKH_NUM_RDYGRP 8
82 #endif
83 
84 /* ------------------------------- Data types ------------------------------ */
125 typedef struct
126 {
132  rui8_t grp;
133 
139  rui8_t tbl[RKH_NUM_RDYGRP];
140 } RKHRdyGrp;
141 
142 typedef struct RdyCbArg RdyCbArg;
143 struct RdyCbArg
144 {
145  rui8_t aoRdyPrio;
146 };
147 
148 /* -------------------------- External variables --------------------------- */
149 /* -------------------------- Function prototypes -------------------------- */
156 void rkh_rdygrp_init(RKHRdyGrp *const me);
157 
164 rbool_t rkh_rdygrp_isReady(RKHRdyGrp *const me);
165 
177 void rkh_rdygrp_setReady(RKHRdyGrp *const me, rui8_t prio);
178 
190 void rkh_rdygrp_setUnready(RKHRdyGrp *const me, rui8_t prio);
191 
206 
220 rui8_t rkh_rdygrp_traverse(RKHRdyGrp *const me, void (*rdyCb)(RdyCbArg *),
221  RdyCbArg *rdyCbArg);
222 
223 /* -------------------- External C language linkage end -------------------- */
224 #ifdef __cplusplus
225 }
226 #endif
227 
228 /* ------------------------------ Module end ------------------------------- */
229 #endif
230 
231 /* ------------------------------ End of file ------------------------------ */
void rkh_rdygrp_setReady(RKHRdyGrp *const me, rui8_t prio)
Making an active object ready inserting it into the ready list.
rbool_t rkh_rdygrp_isReady(RKHRdyGrp *const me)
Evaluates to true if any active object is ready.
void rkh_rdygrp_setUnready(RKHRdyGrp *const me, rui8_t prio)
Removing an active object from the ready list.
rui8_t rkh_rdygrp_findHighest(RKHRdyGrp *const me)
Finding the highest priority active object ready.
rui8_t rkh_rdygrp_traverse(RKHRdyGrp *const me, void(*rdyCb)(RdyCbArg *), RdyCbArg *rdyCbArg)
Traverse a ready list to find the ready active objects and thus invoking a callback function.
void rkh_rdygrp_init(RKHRdyGrp *const me)
Initializes the ready mechanism for active objects.
RKH engine interface.This header file is directly included in RKH interface file, rkh....
SMA ready table.
rui8_t grp
Each bit in rkhrg.grp is used to indicate whenever any SMA in a group is ready to run.