SEGGER.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2017 SEGGER Microcontroller GmbH & Co. KG
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. /*********************************************************************
  7. * SEGGER Microcontroller GmbH & Co. KG *
  8. * The Embedded Experts *
  9. **********************************************************************
  10. * *
  11. * (c) 2015 - 2017 SEGGER Microcontroller GmbH & Co. KG *
  12. * *
  13. * www.segger.com Support: support@segger.com *
  14. * *
  15. **********************************************************************
  16. * *
  17. * SEGGER SystemView * Real-time application analysis *
  18. * *
  19. **********************************************************************
  20. * *
  21. * All rights reserved. *
  22. * *
  23. * SEGGER strongly recommends to not make any changes *
  24. * to or modify the source code of this software in order to stay *
  25. * compatible with the RTT protocol and J-Link. *
  26. * *
  27. * Redistribution and use in source and binary forms, with or *
  28. * without modification, are permitted provided that the following *
  29. * conditions are met: *
  30. * *
  31. * o Redistributions of source code must retain the above copyright *
  32. * notice, this list of conditions and the following disclaimer. *
  33. * *
  34. * o Redistributions in binary form must reproduce the above *
  35. * copyright notice, this list of conditions and the following *
  36. * disclaimer in the documentation and/or other materials provided *
  37. * with the distribution. *
  38. * *
  39. * o Neither the name of SEGGER Microcontroller GmbH & Co. KG *
  40. * nor the names of its contributors may be used to endorse or *
  41. * promote products derived from this software without specific *
  42. * prior written permission. *
  43. * *
  44. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
  45. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
  46. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
  47. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
  48. * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
  49. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
  50. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
  51. * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
  52. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
  53. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
  54. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
  55. * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
  56. * DAMAGE. *
  57. * *
  58. **********************************************************************
  59. * *
  60. * SystemView version: V2.42 *
  61. * *
  62. **********************************************************************
  63. ----------------------------------------------------------------------
  64. File : SEGGER.h
  65. Purpose : Global types etc & general purpose utility functions
  66. ---------------------------END-OF-HEADER------------------------------
  67. */
  68. #ifndef SEGGER_H // Guard against multiple inclusion
  69. #define SEGGER_H
  70. #include "Global.h" // Type definitions: U8, U16, U32, I8, I16, I32
  71. #if defined(__cplusplus)
  72. extern "C" { /* Make sure we have C-declarations in C++ programs */
  73. #endif
  74. /*********************************************************************
  75. *
  76. * Keywords/specifiers
  77. *
  78. **********************************************************************
  79. */
  80. #ifndef INLINE
  81. #ifdef _WIN32
  82. //
  83. // Microsoft VC6 and newer.
  84. // Force inlining without cost checking.
  85. //
  86. #define INLINE __forceinline
  87. #else
  88. #if (defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) || defined(__RX) || defined(__ICCRX__))
  89. //
  90. // Other known compilers.
  91. //
  92. #define INLINE inline
  93. #else
  94. //
  95. // Unknown compilers.
  96. //
  97. #define INLINE
  98. #endif
  99. #endif
  100. #endif
  101. /*********************************************************************
  102. *
  103. * Function-like macros
  104. *
  105. **********************************************************************
  106. */
  107. #define SEGGER_COUNTOF(a) (sizeof((a))/sizeof((a)[0]))
  108. #define SEGGER_MIN(a,b) (((a) < (b)) ? (a) : (b))
  109. #define SEGGER_MAX(a,b) (((a) > (b)) ? (a) : (b))
  110. /*********************************************************************
  111. *
  112. * Types
  113. *
  114. **********************************************************************
  115. */
  116. typedef struct {
  117. char *pBuffer;
  118. int BufferSize;
  119. int Cnt;
  120. } SEGGER_BUFFER_DESC;
  121. typedef struct {
  122. int CacheLineSize; // 0: No Cache. Most Systems such as ARM9 use a 32 bytes cache line size.
  123. void (*pfDMB) (void); // Optional DMB function for Data Memory Barrier to make sure all memory operations are completed.
  124. void (*pfClean) (void *p, unsigned NumBytes); // Optional clean function for cached memory.
  125. void (*pfInvalidate)(void *p, unsigned NumBytes); // Optional invalidate function for cached memory.
  126. } SEGGER_CACHE_CONFIG;
  127. /*********************************************************************
  128. *
  129. * Utility functions
  130. *
  131. **********************************************************************
  132. */
  133. void SEGGER_ARM_memcpy (void *pDest, const void *pSrc, int NumBytes);
  134. void SEGGER_memcpy (void *pDest, const void *pSrc, int NumBytes);
  135. void SEGGER_memxor (void *pDest, const void *pSrc, unsigned NumBytes);
  136. void SEGGER_StoreChar (SEGGER_BUFFER_DESC *p, char c);
  137. void SEGGER_PrintUnsigned(SEGGER_BUFFER_DESC *pBufferDesc, U32 v, unsigned Base, int NumDigits);
  138. void SEGGER_PrintInt (SEGGER_BUFFER_DESC *pBufferDesc, I32 v, unsigned Base, unsigned NumDigits);
  139. int SEGGER_snprintf (char *pBuffer, int BufferSize, const char *sFormat, ...);
  140. #if defined(__cplusplus)
  141. } /* Make sure we have C-declarations in C++ programs */
  142. #endif
  143. #endif // Avoid multiple inclusion
  144. /*************************** End of file ****************************/