qfn.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 * Product: QF-nano public interface
00003 * Last Updated for Version: 4.0.01
00004 * Date of the Last Update:  Jun 08, 2008
00005 *
00006 *                    Q u a n t u m     L e a P s
00007 *                    ---------------------------
00008 *                    innovating embedded systems
00009 *
00010 * Copyright (C) 2002-2008 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 
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)                 /* single-byte tick counter? */
00247 
00268     #define QActive_arm(me_, tout_) ((me_)->tickCtr = (QTimeEvtCtr)(tout_))
00269 
00280     #define QActive_disarm(me_)     ((me_)->tickCtr = (QTimeEvtCtr)0)
00281 
00282 #else                                            /* multi-byte tick counter */
00283 
00304     void QActive_arm(QActive *me, QTimeEvtCtr tout);
00305 
00316     void QActive_disarm(QActive *me);
00317 
00318 #endif                                        /* (QF_TIMEEVT_CTR_SIZE == 1) */
00319 
00320 #endif                                        /* (QF_TIMEEVT_CTR_SIZE != 0) */
00321 
00322 /* protected methods ...*/
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                                                             /* qfn_h */

Generated on Sat Nov 15 13:56:09 2008 for QP-nano by  doxygen 1.5.4