|
QP-nano
|
00001 /***************************************************************************** 00002 * Product: QF-nano public interface 00003 * Last Updated for Version: 4.3.00 00004 * Date of the Last Update: Oct 29, 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 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 /* default macros for accessing data in ROM */ 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 #if (QF_TIMEEVT_CTR_SIZE != 0) 00150 00152 QTimeEvtCtr tickCtr; 00153 #endif 00154 00157 uint8_t prio; 00158 00161 uint8_t head; 00162 00165 uint8_t tail; 00166 00170 uint8_t nUsed; 00171 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 00245 void QF_tickISR(void); 00246 00248 #define QF_tick() QF_tickISR() 00249 00250 #if (QF_TIMEEVT_CTR_SIZE == 1) /* single-byte tick counter? */ 00251 00272 #define QActive_arm(me_, tout_) ((me_)->tickCtr = (QTimeEvtCtr)(tout_)) 00273 00284 #define QActive_disarm(me_) ((me_)->tickCtr = (QTimeEvtCtr)0) 00285 00286 #else /* multi-byte tick counter */ 00287 00308 void QActive_arm(QActive *me, QTimeEvtCtr tout); 00309 00320 void QActive_disarm(QActive *me); 00321 00322 #endif /* (QF_TIMEEVT_CTR_SIZE == 1) */ 00323 00324 #endif /* (QF_TIMEEVT_CTR_SIZE != 0) */ 00325 00326 /* protected methods ...*/ 00327 00341 void QF_init(void); 00342 00350 void QF_stop(void); 00351 00360 void QF_onStartup(void); 00361 00376 void QF_run(void); 00377 00378 00379 #ifndef QK_PREEMPTIVE 00380 00400 void QF_onIdle(void); 00401 #endif 00402 00403 /****************************************************************************/ 00414 typedef struct QActiveCBTag { 00415 QActive *act; 00416 QEvent *queue; 00417 uint8_t end; 00418 } QActiveCB; 00419 00421 extern QActiveCB const Q_ROM Q_ROM_VAR QF_active[]; 00422 00433 extern uint8_t volatile QF_readySet_; 00434 00435 #endif /* qfn_h */
1.7.5.1