|
QP-nano
|
00001 /***************************************************************************** 00002 * Product: QEP-nano public interface 00003 * Last Updated for Version: 4.3.00 00004 * Date of the Last Update: Oct 28, 2011 00005 * 00006 * Q u a n t u m L e a P s 00007 * --------------------------- 00008 * innovating embedded systems 00009 * 00010 * Copyright (C) 2002-2011 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 qepn_h 00029 #define qepn_h 00030 00041 /****************************************************************************/ 00048 #define QP_VERSION 0x4300U 00049 00050 /****************************************************************************/ 00051 #ifndef Q_ROM /* if NOT defined, provide the default definition */ 00052 00066 #define Q_ROM 00067 #endif 00068 #ifndef Q_ROM_VAR /* if NOT defined, provide the default definition */ 00069 00084 #define Q_ROM_VAR 00085 #endif 00086 #ifndef Q_REENTRANT /* if NOT defined, provide the default definition */ 00087 00100 #define Q_REENTRANT 00101 #endif 00102 00103 /****************************************************************************/ 00105 #define Q_DIM(array_) (sizeof(array_) / sizeof(array_[0])) 00106 00107 /****************************************************************************/ 00114 char const Q_ROM * Q_ROM_VAR QP_getVersion(void); 00115 00118 typedef uint8_t QSignal; 00119 00120 /****************************************************************************/ 00121 #ifndef Q_PARAM_SIZE 00122 00125 #define Q_PARAM_SIZE 0 00126 #endif 00127 #if (Q_PARAM_SIZE == 0) 00128 #elif (Q_PARAM_SIZE == 1) 00129 00139 typedef uint8_t QParam; 00140 #elif (Q_PARAM_SIZE == 2) 00141 typedef uint16_t QParam; 00142 #elif (Q_PARAM_SIZE == 4) 00143 typedef uint32_t QParam; 00144 #else 00145 #error "Q_PARAM_SIZE defined incorrectly, expected 0, 1, 2, or 4" 00146 #endif 00147 00154 typedef struct QEventTag { 00155 QSignal sig; 00156 #if (Q_PARAM_SIZE != 0) 00157 QParam par; 00158 #endif 00159 } QEvent; 00160 00161 /****************************************************************************/ 00163 enum QReservedSignals { 00164 Q_ENTRY_SIG = 1, 00165 Q_EXIT_SIG, 00166 Q_INIT_SIG, 00167 Q_TIMEOUT_SIG, 00168 Q_USER_SIG 00169 }; 00170 00171 /****************************************************************************/ 00172 00174 typedef uint8_t QState; 00175 00177 typedef QState (*QStateHandler)(void *me); 00178 00195 typedef struct QFsmTag { 00196 QStateHandler state; 00197 QEvent evt; 00198 } QFsm; 00199 00204 #define Q_SIG(me_) (((QFsm *)(me_))->evt.sig) 00205 00206 #if (Q_PARAM_SIZE != 0) 00207 00212 #define Q_PAR(me_) (((QFsm *)(me_))->evt.par) 00213 #endif 00214 00215 #ifndef Q_NFSM 00216 00224 #define QFsm_ctor(me_, initial_) ((me_)->state = (initial_)) 00225 00234 void QFsm_init(QFsm *me); 00235 00236 #ifndef QK_PREEMPTIVE 00237 00244 void QFsm_dispatch(QFsm *me); 00245 #else 00246 void QFsm_dispatch(QFsm *me) Q_REENTRANT; 00247 #endif 00248 00249 #endif /* Q_NFSM */ 00250 00251 00255 #define Q_RET_HANDLED ((QState)0) 00256 00265 #define Q_HANDLED() (Q_RET_HANDLED) 00266 00270 #define Q_RET_IGNORED ((QState)1) 00271 00279 #define Q_IGNORED() (Q_RET_IGNORED) 00280 00284 #define Q_RET_TRAN ((QState)2) 00285 00291 /*lint -e960 */ /* ignore MISRA Rule 42 (comma operator) for this macro */ 00292 #define Q_TRAN(target_) \ 00293 (((QFsm *)me)->state = (QStateHandler)(target_), Q_RET_TRAN) 00294 00298 #define Q_RET_SUPER ((QState)3) 00299 00304 /*lint -e960 */ /* ignore MISRA Rule 42 (comma operator) for this macro */ 00305 #define Q_SUPER(super_) \ 00306 (((QFsm *)me)->state = (QStateHandler)(super_), Q_RET_SUPER) 00307 00308 00309 /****************************************************************************/ 00310 #ifndef Q_NHSM 00311 00328 typedef struct QFsmTag QHsm; 00329 00330 /* public methods */ 00338 #define QHsm_ctor(me_, initial_) ((me_)->state = (initial_)) 00339 00348 void QHsm_init(QHsm *me); 00349 00350 #ifndef QK_PREEMPTIVE 00351 00358 void QHsm_dispatch(QHsm *me); 00359 #else 00360 void QHsm_dispatch(QHsm *me) Q_REENTRANT; 00361 #endif 00362 00363 /* protected methods... */ 00364 00373 QState QHsm_top(QHsm *me); 00374 00375 #endif /* Q_NHSM */ 00376 00377 #include "qassert.h" /* include the QP-nano assertions (for DbC) */ 00378 00379 #endif /* qepn_h */
1.7.5.1