SEGGER_SYSVIEW_Config_RTThread.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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.38 *
  42. * *
  43. **********************************************************************
  44. -------------------------- END-OF-HEADER -----------------------------
  45. File : SEGGER_SYSVIEW_Config_RTThread.c
  46. Purpose : Sample setup configuration of SystemView with RT-Thread.
  47. Revision: $Rev: 3735 $
  48. */
  49. #include "rtthread.h"
  50. #include "SEGGER_SYSVIEW.h"
  51. #include "SEGGER_SYSVIEW_RTThread.h"
  52. //
  53. // SystemcoreClock can be used in most CMSIS compatible projects.
  54. // In non-CMSIS projects define SYSVIEW_CPU_FREQ.
  55. //
  56. extern unsigned int SystemCoreClock;
  57. /*********************************************************************
  58. *
  59. * Defines, configurable
  60. *
  61. **********************************************************************
  62. */
  63. // The application name to be displayed in SystemViewer
  64. #ifndef SYSVIEW_APP_NAME
  65. #define SYSVIEW_APP_NAME "RT-Thread Trace"
  66. #endif
  67. // The target device name
  68. #ifndef SYSVIEW_DEVICE_NAME
  69. #define SYSVIEW_DEVICE_NAME "Cortex-M4"
  70. #endif
  71. // Frequency of the timestamp. Must match SEGGER_SYSVIEW_Conf.h
  72. #ifndef SYSVIEW_TIMESTAMP_FREQ
  73. #define SYSVIEW_TIMESTAMP_FREQ (SystemCoreClock)
  74. #endif
  75. // System Frequency. SystemcoreClock is used in most CMSIS compatible projects.
  76. #ifndef SYSVIEW_CPU_FREQ
  77. #define SYSVIEW_CPU_FREQ (SystemCoreClock)
  78. #endif
  79. // The lowest RAM address used for IDs (pointers)
  80. #ifndef SYSVIEW_RAM_BASE
  81. #define SYSVIEW_RAM_BASE (0x20000000)
  82. #endif
  83. #ifndef SYSVIEW_SYSDESC0
  84. #define SYSVIEW_SYSDESC0 "I#15=SysTick"
  85. #endif
  86. // Define as 1 if the Cortex-M cycle counter is used as SystemView timestamp. Must match SEGGER_SYSVIEW_Conf.h
  87. #ifndef USE_CYCCNT_TIMESTAMP
  88. #define USE_CYCCNT_TIMESTAMP 1
  89. #endif
  90. #ifndef SYSVIEW_SYSDESC1
  91. #define SYSVIEW_SYSDESC1 "I#53=IntUart1,I#77=IntEth0"
  92. #endif
  93. //#ifndef SYSVIEW_SYSDESC2
  94. // #define SYSVIEW_SYSDESC2 ""
  95. //#endif
  96. /*********************************************************************
  97. *
  98. * Defines, fixed
  99. *
  100. **********************************************************************
  101. */
  102. #define DWT_CTRL (*(volatile rt_uint32_t*) (0xE0001000uL)) // DWT Control Register
  103. #define NOCYCCNT_BIT (1uL << 25) // Cycle counter support bit
  104. #define CYCCNTENA_BIT (1uL << 0) // Cycle counter enable bit
  105. /*********************************************************************
  106. *
  107. * _cbSendSystemDesc()
  108. *
  109. * Function description
  110. * Sends SystemView description strings.
  111. */
  112. static void _cbSendSystemDesc(void) {
  113. SEGGER_SYSVIEW_SendSysDesc("N="SYSVIEW_APP_NAME",O=RTThread,D="SYSVIEW_DEVICE_NAME);
  114. #ifdef SYSVIEW_SYSDESC0
  115. SEGGER_SYSVIEW_SendSysDesc(SYSVIEW_SYSDESC0);
  116. #endif
  117. #ifdef SYSVIEW_SYSDESC1
  118. SEGGER_SYSVIEW_SendSysDesc(SYSVIEW_SYSDESC1);
  119. #endif
  120. #ifdef SYSVIEW_SYSDESC2
  121. SEGGER_SYSVIEW_SendSysDesc(SYSVIEW_SYSDESC2);
  122. #endif
  123. }
  124. extern const SEGGER_SYSVIEW_OS_API SYSVIEW_X_OS_TraceAPI;
  125. /*********************************************************************
  126. *
  127. * Global functions
  128. *
  129. **********************************************************************
  130. */
  131. void SEGGER_SYSVIEW_Conf(void) {
  132. #if USE_CYCCNT_TIMESTAMP
  133. //
  134. // The cycle counter must be activated in order
  135. // to use time related functions.
  136. //
  137. if ((DWT_CTRL & NOCYCCNT_BIT) == 0) { // Cycle counter supported?
  138. if ((DWT_CTRL & CYCCNTENA_BIT) == 0) { // Cycle counter not enabled?
  139. DWT_CTRL |= CYCCNTENA_BIT; // Enable Cycle counter
  140. }
  141. }
  142. #endif
  143. SEGGER_SYSVIEW_Init(SYSVIEW_TIMESTAMP_FREQ, SYSVIEW_CPU_FREQ,
  144. &SYSVIEW_X_OS_TraceAPI, _cbSendSystemDesc);
  145. SEGGER_SYSVIEW_SetRAMBase(SYSVIEW_RAM_BASE);
  146. }
  147. /*************************** End of file ****************************/