qpc/source/qs_pkg.h

94 lines
3.1 KiB
C
Raw Normal View History

2014-04-06 11:43:13 -04:00
/**
2015-04-28 13:45:35 -04:00
* @file
* @ingroup qs
* @brief Internal (package scope) QS/C interface.
* @cond
2014-04-06 11:43:13 -04:00
******************************************************************************
2015-12-24 14:33:20 -05:00
* Last updated for version 5.6.0
* Last updated on 2015-12-18
2012-08-14 18:07:04 -04:00
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
2015-09-04 12:08:22 -04:00
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
2012-08-14 18:07:04 -04:00
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
2012-08-14 18:07:04 -04:00
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact information:
2015-09-04 12:08:22 -04:00
* http://www.state-machine.com
* mailto:info@state-machine.com
2014-04-06 11:43:13 -04:00
******************************************************************************
2015-04-28 13:45:35 -04:00
* @endcond
2014-04-06 11:43:13 -04:00
*/
2012-08-14 18:07:04 -04:00
#ifndef qs_pkg_h
#define qs_pkg_h
2014-04-06 11:43:13 -04:00
/****************************************************************************/
/*! Internal QS macro to insert an un-escaped byte into the QS buffer */
2012-08-14 18:07:04 -04:00
#define QS_INSERT_BYTE(b_) \
2015-09-29 11:33:40 -04:00
QS_PTR_AT_(buf, head) = (b_); \
2013-09-23 14:34:35 -04:00
++head; \
if (head == end) { \
head = (QSCtr)0; \
}
2012-08-14 18:07:04 -04:00
2014-04-06 11:43:13 -04:00
/*! Internal QS macro to insert an escaped byte into the QS buffer */
2012-08-14 18:07:04 -04:00
#define QS_INSERT_ESC_BYTE(b_) \
2013-09-23 14:34:35 -04:00
chksum = (uint8_t)(chksum + (b_)); \
if (((b_) != QS_FRAME) && ((b_) != QS_ESC)) { \
2012-08-14 18:07:04 -04:00
QS_INSERT_BYTE(b_) \
} \
else { \
2013-09-23 14:34:35 -04:00
QS_INSERT_BYTE(QS_ESC) \
QS_INSERT_BYTE((uint8_t)((b_) ^ QS_ESC_XOR)) \
++QS_priv_.used; \
2012-08-14 18:07:04 -04:00
}
2015-04-28 13:45:35 -04:00
/*! Internal QS macro to increment the given pointer parameter @p ptr_ */
2014-04-06 11:43:13 -04:00
/**
2015-04-28 13:45:35 -04:00
* @note Incrementing a pointer violates the MISRA-C 2004 Rule 17.4(req),
2012-08-14 18:07:04 -04:00
* pointer arithmetic other than array indexing. Encapsulating this violation
* in a macro allows to selectively suppress this specific deviation.
*/
#define QS_PTR_INC_(ptr_) (++(ptr_))
2014-04-06 11:43:13 -04:00
/*! Frame character of the QS output protocol */
2012-08-14 18:07:04 -04:00
#define QS_FRAME ((uint8_t)0x7E)
2014-04-06 11:43:13 -04:00
/*! Escape character of the QS output protocol */
2012-08-14 18:07:04 -04:00
#define QS_ESC ((uint8_t)0x7D)
2015-09-04 12:08:22 -04:00
/*! The expected checksum value over an uncorrupted QS record */
#define QS_GOOD_CHKSUM ((uint8_t)0xFF)
2014-04-06 11:43:13 -04:00
/*! Escape modifier of the QS output protocol */
/**
2015-04-28 13:45:35 -04:00
* @description
2012-08-14 18:07:04 -04:00
* The escaped byte is XOR-ed with the escape modifier before it is inserted
* into the QS buffer.
*/
#define QS_ESC_XOR ((uint8_t)0x20)
2015-09-04 12:08:22 -04:00
/*! send the Target info (object sizes, build time-stamp, QP version) */
void QS_target_info_(uint8_t isReset);
2014-04-06 11:43:13 -04:00
#endif /* qs_pkg_h */
2012-08-14 18:07:04 -04:00