SEGGER.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*********************************************************************
  2. * SEGGER MICROCONTROLLER GmbH & Co. KG *
  3. * Solutions for real time microcontroller applications *
  4. **********************************************************************
  5. * *
  6. * (c) 2015 - 2016 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. * * This software may in its unmodified form be freely redistributed *
  19. * in source form. *
  20. * * The source code may be modified, provided the source code *
  21. * retains the above copyright notice, this list of conditions and *
  22. * the following disclaimer. *
  23. * * Modified versions of this software in source or linkable form *
  24. * may not be distributed without prior consent of SEGGER. *
  25. * *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND *
  27. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, *
  28. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
  29. * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
  30. * SEGGER Microcontroller BE LIABLE FOR ANY DIRECT, INDIRECT, *
  31. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
  32. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS *
  33. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
  34. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, *
  35. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
  36. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
  37. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
  38. * *
  39. **********************************************************************
  40. * *
  41. * SystemView version: V2.40 *
  42. * *
  43. **********************************************************************
  44. ----------------------------------------------------------------------
  45. File : SEGGER.h
  46. Purpose : Global types etc & general purpose utility functions
  47. ---------------------------END-OF-HEADER------------------------------
  48. */
  49. #ifndef SEGGER_H // Guard against multiple inclusion
  50. #define SEGGER_H
  51. #include "Global.h" // Type definitions: U8, U16, U32, I8, I16, I32
  52. #if defined(__cplusplus)
  53. extern "C" { /* Make sure we have C-declarations in C++ programs */
  54. #endif
  55. /*********************************************************************
  56. *
  57. * Keywords/specifiers
  58. *
  59. **********************************************************************
  60. */
  61. #ifndef INLINE
  62. #ifdef _WIN32
  63. //
  64. // Microsoft VC6 and newer.
  65. // Force inlining without cost checking.
  66. //
  67. #define INLINE __forceinline
  68. #else
  69. #if (defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) || defined(__RX) || defined(__ICCRX__))
  70. //
  71. // Other known compilers.
  72. //
  73. #define INLINE inline
  74. #else
  75. //
  76. // Unknown compilers.
  77. //
  78. #define INLINE
  79. #endif
  80. #endif
  81. #endif
  82. /*********************************************************************
  83. *
  84. * Function-like macros
  85. *
  86. **********************************************************************
  87. */
  88. #define SEGGER_COUNTOF(a) (sizeof((a))/sizeof((a)[0]))
  89. #define SEGGER_MIN(a,b) (((a) < (b)) ? (a) : (b))
  90. #define SEGGER_MAX(a,b) (((a) > (b)) ? (a) : (b))
  91. /*********************************************************************
  92. *
  93. * Types
  94. *
  95. **********************************************************************
  96. */
  97. typedef struct {
  98. char *pBuffer;
  99. int BufferSize;
  100. int Cnt;
  101. } SEGGER_BUFFER_DESC;
  102. typedef struct {
  103. int CacheLineSize; // 0: No Cache. Most Systems such as ARM9 use a 32 bytes cache line size.
  104. void (*pfDMB) (void); // Optional DMB function for Data Memory Barrier to make sure all memory operations are completed.
  105. void (*pfClean) (void *p, unsigned NumBytes); // Optional clean function for cached memory.
  106. void (*pfInvalidate)(void *p, unsigned NumBytes); // Optional invalidate function for cached memory.
  107. } SEGGER_CACHE_CONFIG;
  108. /*********************************************************************
  109. *
  110. * Utility functions
  111. *
  112. **********************************************************************
  113. */
  114. void SEGGER_ARM_memcpy (void *pDest, const void *pSrc, int NumBytes);
  115. void SEGGER_memcpy (void *pDest, const void *pSrc, int NumBytes);
  116. void SEGGER_memxor (void *pDest, const void *pSrc, unsigned NumBytes);
  117. void SEGGER_StoreChar (SEGGER_BUFFER_DESC *p, char c);
  118. void SEGGER_PrintUnsigned(SEGGER_BUFFER_DESC *pBufferDesc, U32 v, unsigned Base, int NumDigits);
  119. void SEGGER_PrintInt (SEGGER_BUFFER_DESC *pBufferDesc, I32 v, unsigned Base, unsigned NumDigits);
  120. int SEGGER_snprintf (char *pBuffer, int BufferSize, const char *sFormat, ...);
  121. #if defined(__cplusplus)
  122. } /* Make sure we have C-declarations in C++ programs */
  123. #endif
  124. #endif // Avoid multiple inclusion
  125. /*************************** End of file ****************************/