Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
qs.cpp
00001 ////////////////////////////////////////////////////////////////////////////// 00002 // Product: QS/C++ 00003 // Last Updated for Version: 4.1.03 00004 // Date of the Last Update: Feb 15, 2010 00005 // 00006 // Q u a n t u m L e a P s 00007 // --------------------------- 00008 // innovating embedded systems 00009 // 00010 // Copyright (C) 2002-2010 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 #include "qs_pkg.h" 00029 00030 /// \file 00031 /// \ingroup qs 00032 /// \brief QS internal variables definitions and core QS functions 00033 /// implementations. 00034 00035 //............................................................................ 00036 uint8_t QS::glbFilter_[32]; // global QS filter 00037 00038 //............................................................................ 00039 uint8_t *QS_ring_; // pointer to the start of the ring buffer 00040 QSCtr QS_end_; // offset of the end of the ring buffer 00041 QSCtr QS_head_; // offset to where next byte will be inserted 00042 QSCtr QS_tail_; // offset of where next byte will be extracted 00043 QSCtr QS_used_; // number of bytes currently in the ring buffer 00044 uint8_t QS_seq_; // the record sequence number 00045 uint8_t QS_chksum_; // the checksum of the current record 00046 uint8_t QS_full_; // the ring buffer is temporarily full 00047 00048 //............................................................................ 00049 //lint -e970 -e971 ignore MISRA rules 13 and 14 in this function 00050 char const Q_ROM * Q_ROM_VAR QS::getVersion(void) { 00051 static char const Q_ROM Q_ROM_VAR version[] = { 00052 ((QP_VERSION >> 12) & 0xF) + '0', 00053 '.', 00054 ((QP_VERSION >> 8) & 0xF) + '0', 00055 '.', 00056 ((QP_VERSION >> 4) & 0xF) + '0', 00057 (QP_VERSION & 0xF) + '0', 00058 '\0' 00059 }; 00060 return version; 00061 } 00062 //............................................................................ 00063 void QS::initBuf(uint8_t sto[], uint32_t stoSize) { 00064 QS_ring_ = &sto[0]; 00065 QS_end_ = (QSCtr)stoSize; 00066 } 00067 //............................................................................ 00068 void QS::filterOn(uint8_t rec) { 00069 if (rec == QS_ALL_RECORDS) { 00070 uint8_t i; 00071 for (i = (uint8_t)0; i < (uint8_t)sizeof(glbFilter_); ++i) { 00072 glbFilter_[i] = (uint8_t)0xFF; 00073 } 00074 } 00075 else { 00076 glbFilter_[rec >> 3] |= (uint8_t)(1U << (rec & 0x07)); 00077 } 00078 } 00079 //............................................................................ 00080 void QS::filterOff(uint8_t rec) { 00081 if (rec == QS_ALL_RECORDS) { 00082 uint8_t i; 00083 for (i = (uint8_t)0; i < (uint8_t)sizeof(glbFilter_); ++i) { 00084 glbFilter_[i] = (uint8_t)0; 00085 } 00086 } 00087 else { 00088 glbFilter_[rec >> 3] &= (uint8_t)(~(1U << (rec & 0x07))); 00089 } 00090 } 00091 //............................................................................ 00092 void QS::begin(uint8_t rec) { 00093 QS_chksum_ = (uint8_t)0; // clear the checksum 00094 ++QS_seq_; // always increment the sequence number 00095 QS_INSERT_ESC_BYTE(QS_seq_) // store the sequence number 00096 QS_INSERT_ESC_BYTE(rec) // store the record ID 00097 } 00098 //............................................................................ 00099 void QS::end(void) { 00100 QS_INSERT_CHKSUM_BYTE() 00101 QS_INSERT_BYTE(QS_FRAME) 00102 if (QS_used_ > QS_end_) { // overrun over the old data? 00103 QS_tail_ = QS_head_; // shift the tail to the old data 00104 QS_used_ = QS_end_; // the whole buffer is used 00105 } 00106 } 00107 //............................................................................ 00108 void QS::u8(uint8_t format, uint8_t d) { 00109 QS_INSERT_ESC_BYTE(format) 00110 QS_INSERT_ESC_BYTE(d) 00111 } 00112 //............................................................................ 00113 void QS::u16(uint8_t format, uint16_t d) { 00114 QS_INSERT_ESC_BYTE(format) 00115 QS_INSERT_ESC_BYTE((uint8_t)d) 00116 d >>= 8; 00117 QS_INSERT_ESC_BYTE((uint8_t)d) 00118 } 00119 //............................................................................ 00120 void QS::u32(uint8_t format, uint32_t d) { 00121 QS_INSERT_ESC_BYTE(format) 00122 QS_INSERT_ESC_BYTE((uint8_t)d) 00123 d >>= 8; 00124 QS_INSERT_ESC_BYTE((uint8_t)d) 00125 d >>= 8; 00126 QS_INSERT_ESC_BYTE((uint8_t)d) 00127 d >>= 8; 00128 QS_INSERT_ESC_BYTE((uint8_t)d) 00129 }
Generated on Tue Jul 12 2022 20:22:36 by
1.7.2