|
QP/C
|
00001 /***************************************************************************** 00002 * Product: QEP/C platform-independent public interface 00003 * Last Updated for Version: 4.4.00 00004 * Date of the Last Update: Jan 17, 2012 00005 * 00006 * Q u a n t u m L e a P s 00007 * --------------------------- 00008 * innovating embedded systems 00009 * 00010 * Copyright (C) 2002-2012 Quantum Leaps, LLC. All rights reserved. 00011 * 00012 * This software may be distributed and modified under the terms of the GNU 00013 * General Public License version 2 (GPL) as published by the Free Software 00014 * Foundation and appearing in the file GPL.TXT included in the packaging of 00015 * this file. Please note that GPL Section 2[b] requires that all works based 00016 * on this software must also be made publicly available under the terms of 00017 * the GPL ("Copyleft"). 00018 * 00019 * Alternatively, this software may be distributed and modified under the 00020 * terms of Quantum Leaps commercial licenses, which expressly supersede 00021 * the GPL and are specifically designed for licensees interested in 00022 * retaining the proprietary status of their code. 00023 * 00024 * Contact information: 00025 * Quantum Leaps Web site: http://www.quantum-leaps.com 00026 * e-mail: info@quantum-leaps.com 00027 *****************************************************************************/ 00028 #ifndef qep_h 00029 #define qep_h 00030 00040 #include "qevent.h" /* QEP event processor needs the QEvent facility */ 00041 00042 /****************************************************************************/ 00049 char_t const Q_ROM * Q_ROM_VAR QEP_getVersion(void); 00050 00051 /****************************************************************************/ 00052 00054 typedef uint8_t QState; 00055 00057 typedef QState (*QStateHandler)(void *me, QEvent const *e); 00058 00065 #define Q_STATE_CAST(handler_) ((QStateHandler)(handler_)) 00066 00067 /****************************************************************************/ 00084 typedef struct QFsmTag { 00085 QStateHandler state; 00086 } QFsm; 00087 00100 #define QFsm_ctor(me_, initial_) ((me_)->state = (initial_)) 00101 00102 /****************************************************************************/ 00114 void QFsm_init(QFsm *me, QEvent const *e); 00115 00127 void QFsm_dispatch(QFsm *me, QEvent const *e); 00128 00129 00130 /****************************************************************************/ 00148 typedef struct QFsmTag QHsm; 00149 00150 /* public methods */ 00151 00166 #define QHsm_ctor(me_, initial_) ((me_)->state = (initial_)) 00167 00179 void QHsm_init(QHsm *me, QEvent const *e); 00180 00192 void QHsm_dispatch(QHsm *me, QEvent const *e); 00193 00200 uint8_t QHsm_isIn(QHsm *me, QStateHandler state); 00201 00202 /* protected methods */ 00203 00212 QState QHsm_top(void *me, QEvent const *e); 00213 00217 #define Q_RET_IGNORED ((QState)1) 00218 00226 #define Q_IGNORED() (Q_RET_IGNORED) 00227 00231 #define Q_RET_HANDLED ((QState)0) 00232 00241 #define Q_HANDLED() (Q_RET_HANDLED) 00242 00246 #define Q_RET_TRAN ((QState)2) 00247 00253 #define Q_TRAN(target_) \ 00254 (((QFsm *)me)->state = Q_STATE_CAST(target_), Q_RET_TRAN) 00255 00259 #define Q_RET_SUPER ((QState)3) 00260 00265 #define Q_SUPER(super_) \ 00266 (((QHsm *)me)->state = Q_STATE_CAST(super_), Q_RET_SUPER) 00267 00268 00275 #define Q_EVENT_CAST(class_) ((class_ const *)e) 00276 00277 /****************************************************************************/ 00279 enum QReservedSignals { 00280 Q_ENTRY_SIG = 1, 00281 Q_EXIT_SIG, 00282 Q_INIT_SIG, 00283 Q_USER_SIG 00284 }; 00285 00286 #ifdef Q_SPY 00287 00288 #if (Q_SIGNAL_SIZE == 1) 00289 00294 #define QS_SIG_(sig_) QS_u8_(sig_) 00295 #elif (Q_SIGNAL_SIZE == 2) 00296 #define QS_SIG_(sig_) QS_u16_(sig_) 00297 #elif (Q_SIGNAL_SIZE == 4) 00298 #define QS_SIG_(sig_) QS_u32_(sig_) 00299 #endif 00300 00301 #endif /* Q_SPY */ 00302 00303 #endif /* qep_h */
1.7.6.1