QP-nano
qkn.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002 * Product: QK-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 qkn_h
00029 #define qkn_h
00030 
00049 #define QK_PREEMPTIVE   1
00050 
00057 void QK_init(void);
00058 
00064 uint8_t QK_schedPrio_(void) Q_REENTRANT;
00065 
00072 void QK_sched_(uint8_t p) Q_REENTRANT;
00073 
00074 extern uint8_t volatile QK_currPrio_;              
00076 #ifndef QF_ISR_NEST
00077 
00079     #define QK_SCHEDULE_() do { \
00080         uint8_t p = QK_schedPrio_(); \
00081         if (p != (uint8_t)0) { \
00082             QK_sched_(p); \
00083         } \
00084     } while(0)
00085 #else
00086     #define QK_SCHEDULE_() \
00087         if (QK_intNest_ == (uint8_t)0) { \
00088             uint8_t p = QK_schedPrio_(); \
00089             if (p != (uint8_t)0) { \
00090                 QK_sched_(p); \
00091             } \
00092         } else ((void)0)
00093 
00094     extern uint8_t volatile QK_intNest_;       
00096 #endif
00097 
00104 #define QK_schedule_() do { \
00105     uint8_t p = QK_schedPrio_(); \
00106     if (p != (uint8_t)0) { \
00107         QK_sched_(p); \
00108     } \
00109 } while(0)
00110 
00111 
00122 void QK_onIdle(void);
00123 
00124 #ifdef QK_MUTEX
00125 
00132     typedef uint8_t QMutex;
00133 
00142     QMutex QK_mutexLock(uint8_t prioCeiling);
00143 
00150     void QK_mutexUnlock(QMutex mutex);
00151 
00152 #endif                                                          /* QK_MUTEX */
00153 
00154 #endif                                                             /* qkn_h */