|
QP/C++
|
00001 00002 // Product: QS/C++ 00003 // Last Updated for Version: 4.2.00 00004 // Date of the Last Update: Jul 05, 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 00028 #ifndef qs_pkg_h 00029 #define qs_pkg_h 00030 00034 00035 #include "qs_port.h" // QS port 00036 00037 #ifdef Q_USE_NAMESPACE 00038 namespace QP { 00039 #endif 00040 00042 typedef uint16_t QSCtr; 00043 00047 #define QS_INSERT_BYTE(b_) \ 00048 QS_ring_[QS_head_] = (b_); \ 00049 ++QS_head_; \ 00050 if (QS_head_ == QS_end_) { \ 00051 QS_head_ = (QSCtr)0; \ 00052 } \ 00053 ++QS_used_; 00054 00056 #define QS_INSERT_ESC_BYTE(b_) \ 00057 QS_chksum_ = (uint8_t)(QS_chksum_ + (b_)); \ 00058 if (((b_) == QS_FRAME) || ((b_) == QS_ESC)) { \ 00059 QS_INSERT_BYTE(QS_ESC) \ 00060 QS_INSERT_BYTE((uint8_t)((b_) ^ QS_ESC_XOR)) \ 00061 } \ 00062 else { \ 00063 QS_INSERT_BYTE(b_) \ 00064 } 00065 00068 #define QS_INSERT_CHKSUM_BYTE() \ 00069 QS_chksum_ = (uint8_t)~QS_chksum_; \ 00070 if ((QS_chksum_ == QS_FRAME) || (QS_chksum_ == QS_ESC)) { \ 00071 QS_INSERT_BYTE(QS_ESC) \ 00072 QS_INSERT_BYTE((uint8_t)(QS_chksum_ ^ QS_ESC_XOR)) \ 00073 } \ 00074 else { \ 00075 QS_INSERT_BYTE(QS_chksum_) \ 00076 } 00077 00078 00080 #define QS_FRAME ((uint8_t)0x7E) 00081 00083 #define QS_ESC ((uint8_t)0x7D) 00084 00089 #define QS_ESC_XOR 0x20 00090 00091 #ifndef Q_ROM_BYTE 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 #define Q_ROM_BYTE(rom_var_) (rom_var_) 00106 #endif 00107 00108 //............................................................................ 00109 extern uint8_t *QS_ring_; 00110 extern QSCtr QS_end_; 00111 extern QSCtr QS_head_; 00112 extern QSCtr QS_tail_; 00113 extern QSCtr QS_used_; 00114 extern uint8_t QS_seq_; 00115 extern uint8_t QS_chksum_; 00116 extern uint8_t QS_full_; 00117 00118 00119 #ifdef Q_USE_NAMESPACE 00120 } // namespace QP 00121 #endif 00122 00123 #endif // qs_pkg_h
1.7.5.1