rti.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * File : rti.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2018-06-05 flybreak first version
  23. */
  24. #ifndef __RTI_H__
  25. #define __RTI_H__
  26. #include <rtthread.h>
  27. #include <rthw.h>
  28. #include "rti_config.h"
  29. #define RTI_LOG (0u)
  30. #define RTI_WARNING (1u)
  31. #define RTI_ERROR (2u)
  32. /* rti events. First 32 IDs from 0 .. 31 are Compatible for Systemvie */
  33. #define RTI_ID_NOP (0u)
  34. #define RTI_ID_OVERFLOW (1u)
  35. #define RTI_ID_ISR_ENTER (2u)
  36. #define RTI_ID_ISR_EXIT (3u)
  37. #define RTI_ID_THREAD_START_EXEC (4u)
  38. #define RTI_ID_THREAD_STOP_EXEC (5u)
  39. #define RTI_ID_THREAD_START_READY (6u)
  40. #define RTI_ID_THREAD_STOP_READY (7u)
  41. #define RTI_ID_THREAD_CREATE (8u)
  42. #define RTI_ID_THREAD_INFO (9u)
  43. #define RTI_ID_START (10u)
  44. #define RTI_ID_STOP (11u)
  45. #define RTI_ID_SYSTIME_CYCLES (12u)
  46. #define RTI_ID_SYSTIME_US (13u)
  47. #define RTI_ID_SYSDESC (14u)
  48. #define RTI_ID_USER_START (15u)
  49. #define RTI_ID_USER_STOP (16u)
  50. #define RTI_ID_IDLE (17u)
  51. #define RTI_ID_ISR_TO_SCHEDULER (18u)
  52. #define RTI_ID_TIMER_ENTER (19u)
  53. #define RTI_ID_TIMER_EXIT (20u)
  54. #define RTI_ID_STACK_INFO (21u)
  55. #define RTI_ID_MODULEDESC (22u)
  56. #define RTI_ID_INIT (24u)
  57. #define RTI_ID_NAME_RESOURCE (25u)
  58. #define RTI_ID_PRINT_FORMATTED (26u)
  59. #define RTI_ID_NUMMODULES (27u)
  60. #define RTI_ID_END_CALL (28u)
  61. #define RTI_ID_THREAD_TERMINATE (29u)
  62. #define RTI_ID_EX (31u)
  63. #define RTI_ID_SEM_BASE (40u)
  64. #define RTI_ID_SEM_TRYTAKE ( 1u + RTI_ID_SEM_BASE)
  65. #define RTI_ID_SEM_TAKEN ( 2u + RTI_ID_SEM_BASE)
  66. #define RTI_ID_SEM_RELEASE ( 3u + RTI_ID_SEM_BASE)
  67. #define RTI_ID_MUTEX_BASE (50u)
  68. #define RTI_ID_MUTEX_TRYTAKE ( 1u + RTI_ID_MUTEX_BASE)
  69. #define RTI_ID_MUTEX_TAKEN ( 2u + RTI_ID_MUTEX_BASE)
  70. #define RTI_ID_MUTEX_RELEASE ( 3u + RTI_ID_MUTEX_BASE)
  71. #define RTI_ID_EVENT_BASE (60u)
  72. #define RTI_ID_EVENT_TRYTAKE ( 1u + RTI_ID_EVENT_BASE)
  73. #define RTI_ID_EVENT_TAKEN ( 2u + RTI_ID_EVENT_BASE)
  74. #define RTI_ID_EVENT_RELEASE ( 3u + RTI_ID_EVENT_BASE)
  75. #define RTI_ID_MAILBOX_BASE (70u)
  76. #define RTI_ID_MAILBOX_TRYTAKE ( 1u + RTI_ID_MAILBOX_BASE)
  77. #define RTI_ID_MAILBOX_TAKEN ( 2u + RTI_ID_MAILBOX_BASE)
  78. #define RTI_ID_MAILBOX_RELEASE ( 3u + RTI_ID_MAILBOX_BASE)
  79. #define RTI_ID_QUEUE_BASE (80u)
  80. #define RTI_ID_QUEUE_TRYTAKE ( 1u + RTI_ID_QUEUE_BASE)
  81. #define RTI_ID_QUEUE_TAKEN ( 2u + RTI_ID_QUEUE_BASE)
  82. #define RTI_ID_QUEUE_RELEASE ( 3u + RTI_ID_QUEUE_BASE)
  83. /*trace event flag*/
  84. #define RTI_SEM_NUM (0)
  85. #define RTI_MUTEX_NUM (1)
  86. #define RTI_EVENT_NUM (2)
  87. #define RTI_MAILBOX_NUM (3)
  88. #define RTI_QUEUE_NUM (4)
  89. #define RTI_THREAD_NUM (5)
  90. #define RTI_SCHEDULER_NUM (6)
  91. #define RTI_INTERRUPT_NUM (7)
  92. #define RTI_TIMER_NUM (8)
  93. #define RTI_TRACE_NUM (9)
  94. #define RTI_SEM (1 << RTI_SEM_NUM )
  95. #define RTI_MUTEX (1 << RTI_MUTEX_NUM )
  96. #define RTI_EVENT (1 << RTI_EVENT_NUM )
  97. #define RTI_MAILBOX (1 << RTI_MAILBOX_NUM )
  98. #define RTI_QUEUE (1 << RTI_QUEUE_NUM )
  99. #define RTI_THREAD (1 << RTI_THREAD_NUM )
  100. #define RTI_SCHEDULER (1 << RTI_SCHEDULER_NUM)
  101. #define RTI_INTERRUPT (1 << RTI_INTERRUPT_NUM)
  102. #define RTI_TIMER (1 << RTI_TIMER_NUM )
  103. #define RTI_ALL (0x01FF)
  104. /* rti data size */
  105. #define RTI_INFO_SIZE (9)
  106. #define RTI_VALUE_SIZE (5)
  107. /* rti enable status */
  108. #define RTI_DISABLE 0
  109. #define RTI_ENABLE 1
  110. #define RTI_OVERFLOW 2
  111. /* rti api */
  112. void rti_start(void);
  113. void rti_stop(void);
  114. void rti_trace_enable(rt_uint16_t flag);
  115. void rti_trace_disable(rt_uint16_t flag);
  116. rt_size_t rti_data_get(rt_uint8_t *ptr, rt_uint16_t length);
  117. rt_size_t rti_buffer_used(void);
  118. void rti_data_new_data_notify_set_hook(void (*hook)(void));
  119. void rti_print(const char *s);
  120. #endif