00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef qfn_h
00029 #define qfn_h
00030
00041
00042 #if (QF_MAX_ACTIVE < 1) || (8 < QF_MAX_ACTIVE)
00043 #error "QF_MAX_ACTIVE not defined or out of range. Valid range is 1..8."
00044 #endif
00045 #if (defined QF_FSM_ACTIVE) && (defined Q_NFSM)
00046 #error "QF_FSM_ACTIVE and Q_NFSM cannot be defined at the same time."
00047 #endif
00048 #if (!defined QF_FSM_ACTIVE) && (defined Q_NHSM)
00049 #error "Q_NHSM defined without defining QF_FSM_ACTIVE."
00050 #endif
00051
00052
00053
00054
00055 #ifndef Q_ROM_BYTE
00056
00071 #define Q_ROM_BYTE(rom_var_) (rom_var_)
00072 #endif
00073 #ifndef Q_ROM_PTR
00074
00090 #define Q_ROM_PTR(rom_var_) (rom_var_)
00091 #endif
00092
00093 #ifndef QF_TIMEEVT_CTR_SIZE
00094
00097 #define QF_TIMEEVT_CTR_SIZE 0
00098 #endif
00099 #if (QF_TIMEEVT_CTR_SIZE == 0)
00100 #elif (QF_TIMEEVT_CTR_SIZE == 1)
00101 typedef uint8_t QTimeEvtCtr;
00102 #elif (QF_TIMEEVT_CTR_SIZE == 2)
00103
00114 typedef uint16_t QTimeEvtCtr;
00115 #elif (QF_TIMEEVT_CTR_SIZE == 4)
00116 typedef uint32_t QTimeEvtCtr;
00117 #else
00118 #error "QF_TIMER_SIZE defined incorrectly, expected 1, 2, or 4"
00119 #endif
00120
00121
00142 typedef struct QActiveTag {
00143
00144 #ifndef QF_FSM_ACTIVE
00145 QHsm super;
00146 #else
00147 QFsm super;
00148 #endif
00149
00152 uint8_t prio;
00153
00156 uint8_t head;
00157
00160 uint8_t tail;
00161
00165 uint8_t nUsed;
00166
00167 #if (QF_TIMEEVT_CTR_SIZE != 0)
00168
00170 QTimeEvtCtr tickCtr;
00171 #endif
00172 } QActive;
00173
00174
00183 #ifndef QF_FSM_ACTIVE
00184 #define QActive_ctor(me_, initial_) QHsm_ctor(&(me_)->super, initial_)
00185 #else
00186 #define QActive_ctor(me_, initial_) QFsm_ctor(&(me_)->super, initial_)
00187 #endif
00188
00189
00190 #if (Q_PARAM_SIZE != 0)
00191
00215 void QActive_post(QActive *me, QSignal sig, QParam par);
00216
00228 void QActive_postISR(QActive *me, QSignal sig, QParam par);
00229 #else
00230 void QActive_post(QActive *me, QSignal sig);
00231 void QActive_postISR(QActive *me, QSignal sig);
00232 #endif
00233
00234 #if (QF_TIMEEVT_CTR_SIZE != 0)
00235
00244 void QF_tick(void);
00245
00246 #if (QF_TIMEEVT_CTR_SIZE == 1)
00247
00268 #define QActive_arm(me_, tout_) ((me_)->tickCtr = (QTimeEvtCtr)(tout_))
00269
00280 #define QActive_disarm(me_) ((me_)->tickCtr = (QTimeEvtCtr)0)
00281
00282 #else
00283
00304 void QActive_arm(QActive *me, QTimeEvtCtr tout);
00305
00316 void QActive_disarm(QActive *me);
00317
00318 #endif
00319
00320 #endif
00321
00322
00323
00331 void QF_stop(void);
00332
00341 void QF_onStartup(void);
00342
00357 void QF_run(void);
00358
00359
00360 #ifndef QK_PREEMPTIVE
00361
00381 void QF_onIdle(void);
00382 #endif
00383
00384
00395 typedef struct QActiveCBTag {
00396 QActive *act;
00397 QEvent *queue;
00398 uint8_t end;
00399 } QActiveCB;
00400
00402 extern QActiveCB const Q_ROM Q_ROM_VAR QF_active[];
00403
00414 extern uint8_t volatile QF_readySet_;
00415
00416 #endif