|
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 #include "qs_pkg.h" 00029 00034 00035 #ifdef Q_USE_NAMESPACE 00036 namespace QP { 00037 #endif 00038 00039 //............................................................................ 00040 uint8_t QS::glbFilter_[32]; // global QS filter 00041 00042 //............................................................................ 00043 uint8_t *QS_ring_; // pointer to the start of the ring buffer 00044 QSCtr QS_end_; // offset of the end of the ring buffer 00045 QSCtr QS_head_; // offset to where next byte will be inserted 00046 QSCtr QS_tail_; // offset of where next byte will be extracted 00047 QSCtr QS_used_; // number of bytes currently in the ring buffer 00048 uint8_t QS_seq_; // the record sequence number 00049 uint8_t QS_chksum_; // the checksum of the current record 00050 uint8_t QS_full_; // the ring buffer is temporarily full 00051 00052 //............................................................................ 00053 //lint -e970 -e971 ignore MISRA rules 13 and 14 in this function 00054 char const Q_ROM * Q_ROM_VAR QS::getVersion(void) { 00055 static char const Q_ROM Q_ROM_VAR version[] = { 00056 (char)(((QP_VERSION >> 12U) & 0xFU) + (uint8_t)'0'), 00057 '.', 00058 (char)(((QP_VERSION >> 8U) & 0xFU) + (uint8_t)'0'), 00059 '.', 00060 (char)(((QP_VERSION >> 4U) & 0xFU) + (uint8_t)'0'), 00061 (char)((QP_VERSION & 0xFU) + (uint8_t)'0'), 00062 '\0' 00063 }; 00064 return version; 00065 } 00066 //............................................................................ 00067 void QS::initBuf(uint8_t sto[], uint32_t stoSize) { 00068 QS_ring_ = &sto[0]; 00069 QS_end_ = (QSCtr)stoSize; 00070 } 00071 //............................................................................ 00072 void QS::filterOn(uint8_t rec) { 00073 if (rec == QS_ALL_RECORDS) { 00074 uint8_t i; 00075 for (i = (uint8_t)0; i < (uint8_t)sizeof(glbFilter_); ++i) { 00076 glbFilter_[i] = (uint8_t)0xFF; 00077 } 00078 } 00079 else { 00080 glbFilter_[rec >> 3] |= (uint8_t)(1U << (rec & 0x07)); 00081 } 00082 } 00083 //............................................................................ 00084 void QS::filterOff(uint8_t rec) { 00085 if (rec == QS_ALL_RECORDS) { 00086 uint8_t i; 00087 for (i = (uint8_t)0; i < (uint8_t)sizeof(glbFilter_); ++i) { 00088 glbFilter_[i] = (uint8_t)0; 00089 } 00090 } 00091 else { 00092 glbFilter_[rec >> 3] &= (uint8_t)(~(1U << (rec & 0x07))); 00093 } 00094 } 00095 //............................................................................ 00096 void QS::begin(uint8_t rec) { 00097 QS_chksum_ = (uint8_t)0; // clear the checksum 00098 ++QS_seq_; // always increment the sequence number 00099 QS_INSERT_ESC_BYTE(QS_seq_) // store the sequence number 00100 QS_INSERT_ESC_BYTE(rec) // store the record ID 00101 } 00102 //............................................................................ 00103 void QS::end(void) { 00104 QS_INSERT_CHKSUM_BYTE() 00105 QS_INSERT_BYTE(QS_FRAME) 00106 if (QS_used_ > QS_end_) { // overrun over the old data? 00107 QS_tail_ = QS_head_; // shift the tail to the old data 00108 QS_used_ = QS_end_; // the whole buffer is used 00109 } 00110 } 00111 //............................................................................ 00112 void QS::u8(uint8_t format, uint8_t d) { 00113 QS_INSERT_ESC_BYTE(format) 00114 QS_INSERT_ESC_BYTE(d) 00115 } 00116 //............................................................................ 00117 void QS::u16(uint8_t format, uint16_t d) { 00118 QS_INSERT_ESC_BYTE(format) 00119 QS_INSERT_ESC_BYTE((uint8_t)d) 00120 d >>= 8; 00121 QS_INSERT_ESC_BYTE((uint8_t)d) 00122 } 00123 //............................................................................ 00124 void QS::u32(uint8_t format, uint32_t d) { 00125 QS_INSERT_ESC_BYTE(format) 00126 QS_INSERT_ESC_BYTE((uint8_t)d) 00127 d >>= 8; 00128 QS_INSERT_ESC_BYTE((uint8_t)d) 00129 d >>= 8; 00130 QS_INSERT_ESC_BYTE((uint8_t)d) 00131 d >>= 8; 00132 QS_INSERT_ESC_BYTE((uint8_t)d) 00133 } 00134 00135 #ifdef Q_USE_NAMESPACE 00136 } // namespace QP 00137 #endif
1.7.5.1