SEGGER.h 7.1 KB

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