qs_64bit.c 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * @file
  3. * @brief QS long-long (64-bit) output
  4. * @ingroup qs
  5. * @cond
  6. ******************************************************************************
  7. * Last updated for version 5.4.0
  8. * Last updated on 2015-04-13
  9. *
  10. * Q u a n t u m L e a P s
  11. * ---------------------------
  12. * innovating embedded systems
  13. *
  14. * Copyright (C) Quantum Leaps, www.state-machine.com.
  15. *
  16. * This program is open source software: you can redistribute it and/or
  17. * modify it under the terms of the GNU General Public License as published
  18. * by the Free Software Foundation, either version 3 of the License, or
  19. * (at your option) any later version.
  20. *
  21. * Alternatively, this program may be distributed and modified under the
  22. * terms of Quantum Leaps commercial licenses, which expressly supersede
  23. * the GNU General Public License and are specifically designed for
  24. * licensees interested in retaining the proprietary status of their code.
  25. *
  26. * This program is distributed in the hope that it will be useful,
  27. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29. * GNU General Public License for more details.
  30. *
  31. * You should have received a copy of the GNU General Public License
  32. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  33. *
  34. * Contact information:
  35. * Web: www.state-machine.com
  36. * Email: info@state-machine.com
  37. ******************************************************************************
  38. * @endcond
  39. */
  40. #include "qs_port.h" /* QS port */
  41. #if (QS_OBJ_PTR_SIZE == 8) || (QS_FUN_PTR_SIZE == 8)
  42. #include "qs_pkg.h"
  43. /****************************************************************************/
  44. /** @note This function is only to be used through macros, never in the
  45. * client code directly.
  46. */
  47. void QS_u64_(uint64_t d) {
  48. uint8_t chksum = QS_priv_.chksum;
  49. uint8_t *buf = QS_priv_.buf;
  50. QSCtr head = QS_priv_.head;
  51. QSCtr end = QS_priv_.end;
  52. int_fast8_t i;
  53. QS_priv_.used += (QSCtr)8; /* 8 bytes are about to be added */
  54. for (i = (int_fast8_t)8; i != (int_fast8_t)0; --i) {
  55. uint8_t b = (uint8_t)d;
  56. QS_INSERT_ESC_BYTE(b)
  57. d >>= 8;
  58. }
  59. QS_priv_.head = head; /* save the head */
  60. QS_priv_.chksum = chksum; /* save the checksum */
  61. }
  62. /****************************************************************************/
  63. /** @note This function is only to be used through macros, never in the
  64. * client code directly.
  65. */
  66. void QS_u64(uint8_t format, uint64_t d) {
  67. uint8_t chksum = QS_priv_.chksum;
  68. uint8_t *buf = QS_priv_.buf;
  69. QSCtr head = QS_priv_.head;
  70. QSCtr end = QS_priv_.end;
  71. int_fast8_t i;
  72. QS_priv_.used += (QSCtr)9; /* 9 bytes are about to be added */
  73. QS_INSERT_ESC_BYTE(format) /* insert the format byte */
  74. /* output 8 bytes of data... */
  75. for (i = (int_fast8_t)8; i != (int_fast8_t)0; --i) {
  76. format = (uint8_t)d;
  77. QS_INSERT_ESC_BYTE(format)
  78. d >>= 8;
  79. }
  80. QS_priv_.head = head; /* save the head */
  81. QS_priv_.chksum = chksum; /* save the checksum */
  82. }
  83. #endif /* (QS_OBJ_PTR_SIZE == 8) || (QS_FUN_PTR_SIZE == 8) */