|
QP/C
|
00001 /***************************************************************************** 00002 * Product: QS/C 00003 * Last Updated for Version: 4.5.04 00004 * Date of the Last Update: Feb 01, 2013 00005 * 00006 * Q u a n t u m L e a P s 00007 * --------------------------- 00008 * innovating embedded systems 00009 * 00010 * Copyright (C) 2002-2013 Quantum Leaps, LLC. All rights reserved. 00011 * 00012 * This program is open source software: you can redistribute it and/or 00013 * modify it under the terms of the GNU General Public License as published 00014 * by the Free Software Foundation, either version 2 of the License, or 00015 * (at your option) any later version. 00016 * 00017 * Alternatively, this program may be distributed and modified under the 00018 * terms of Quantum Leaps commercial licenses, which expressly supersede 00019 * the GNU General Public License and are specifically designed for 00020 * licensees interested in retaining the proprietary status of their code. 00021 * 00022 * This program is distributed in the hope that it will be useful, 00023 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 * GNU General Public License for more details. 00026 * 00027 * You should have received a copy of the GNU General Public License 00028 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00029 * 00030 * Contact information: 00031 * Quantum Leaps Web sites: http://www.quantum-leaps.com 00032 * http://www.state-machine.com 00033 * e-mail: info@quantum-leaps.com 00034 *****************************************************************************/ 00035 #ifndef qs_pkg_h 00036 #define qs_pkg_h 00037 00044 #include "qs_port.h" /* QS port */ 00045 00047 typedef uint16_t QSCtr; 00048 00049 /*..........................................................................*/ 00053 #define QS_INSERT_BYTE(b_) \ 00054 QS_PTR_AT_(QS_head_) = (b_); \ 00055 ++QS_head_; \ 00056 if (QS_head_ == QS_end_) { \ 00057 QS_head_ = (QSCtr)0; \ 00058 } \ 00059 ++QS_used_; 00060 00062 #define QS_INSERT_ESC_BYTE(b_) \ 00063 QS_chksum_ = (uint8_t)(QS_chksum_ + (b_)); \ 00064 if (((b_) == QS_FRAME) || ((b_) == QS_ESC)) { \ 00065 QS_INSERT_BYTE(QS_ESC) \ 00066 QS_INSERT_BYTE((uint8_t)((b_) ^ QS_ESC_XOR)) \ 00067 } \ 00068 else { \ 00069 QS_INSERT_BYTE(b_) \ 00070 } 00071 00075 #define QS_INSERT_CHKSUM_BYTE() \ 00076 QS_chksum_ = (uint8_t)~QS_chksum_; \ 00077 if ((QS_chksum_ == QS_FRAME) || (QS_chksum_ == QS_ESC)) { \ 00078 QS_INSERT_BYTE(QS_ESC) \ 00079 QS_INSERT_BYTE((uint8_t)(QS_chksum_ ^ QS_ESC_XOR)) \ 00080 } \ 00081 else { \ 00082 QS_INSERT_BYTE(QS_chksum_) \ 00083 } 00084 00092 #define QS_PTR_AT_(i_) (QS_ring_[(i_)]) 00093 00100 #define QS_PTR_INC_(ptr_) (++(ptr_)) 00101 00103 #define QS_FRAME ((uint8_t)0x7E) 00104 00106 #define QS_ESC ((uint8_t)0x7D) 00107 00113 #define QS_ESC_XOR ((uint8_t)0x20) 00114 00115 #ifndef Q_ROM_BYTE 00116 00130 #define Q_ROM_BYTE(rom_var_) (rom_var_) 00131 #endif 00132 00133 /*..........................................................................*/ 00134 extern uint8_t *QS_ring_; 00135 extern QSCtr QS_end_; 00136 extern QSCtr QS_head_; 00137 extern QSCtr QS_tail_; 00138 extern QSCtr QS_used_; 00139 extern uint8_t QS_seq_; 00140 extern uint8_t QS_chksum_; 00141 extern uint8_t QS_full_; 00143 #endif /* qs_pkg_h */ 00144
1.7.6.1