rti.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /** @file rti.h
  2. * @brief RTI Driver Header File
  3. * @date 29.May.2013
  4. * @version 03.05.02
  5. *
  6. * This file contains:
  7. * - Definitions
  8. * - Types
  9. * - Interface Prototypes
  10. * .
  11. * which are relevant for the RTI driver.
  12. */
  13. /* (c) Texas Instruments 2009-2013, All rights reserved. */
  14. #ifndef __RTI_H__
  15. #define __RTI_H__
  16. #include "reg_rti.h"
  17. /* USER CODE BEGIN (0) */
  18. /* USER CODE END */
  19. /* RTI General Definitions */
  20. /** @def rtiCOUNTER_BLOCK0
  21. * @brief Alias name for RTI counter block 0
  22. *
  23. * This is an alias name for the RTI counter block 0.
  24. *
  25. * @note This value should be used for API argument @a counter
  26. */
  27. #define rtiCOUNTER_BLOCK0 0U
  28. /** @def rtiCOUNTER_BLOCK1
  29. * @brief Alias name for RTI counter block 1
  30. *
  31. * This is an alias name for the RTI counter block 1.
  32. *
  33. * @note This value should be used for API argument @a counter
  34. */
  35. #define rtiCOUNTER_BLOCK1 1U
  36. /** @def rtiCOMPARE0
  37. * @brief Alias name for RTI compare 0
  38. *
  39. * This is an alias name for the RTI compare 0.
  40. *
  41. * @note This value should be used for API argument @a compare
  42. */
  43. #define rtiCOMPARE0 0U
  44. /** @def rtiCOMPARE1
  45. * @brief Alias name for RTI compare 1
  46. *
  47. * This is an alias name for the RTI compare 1.
  48. *
  49. * @note This value should be used for API argument @a compare
  50. */
  51. #define rtiCOMPARE1 1U
  52. /** @def rtiCOMPARE2
  53. * @brief Alias name for RTI compare 2
  54. *
  55. * This is an alias name for the RTI compare 2.
  56. *
  57. * @note This value should be used for API argument @a compare
  58. */
  59. #define rtiCOMPARE2 2U
  60. /** @def rtiCOMPARE3
  61. * @brief Alias name for RTI compare 3
  62. *
  63. * This is an alias name for the RTI compare 3.
  64. *
  65. * @note This value should be used for API argument @a compare
  66. */
  67. #define rtiCOMPARE3 3U
  68. /** @def rtiNOTIFICATION_COMPARE0
  69. * @brief Alias name for RTI compare 0 notification
  70. *
  71. * This is an alias name for the RTI compare 0 notification.
  72. *
  73. * @note This value should be used for API argument @a notification
  74. */
  75. #define rtiNOTIFICATION_COMPARE0 1U
  76. /** @def rtiNOTIFICATION_COMPARE1
  77. * @brief Alias name for RTI compare 1 notification
  78. *
  79. * This is an alias name for the RTI compare 1 notification.
  80. *
  81. * @note This value should be used for API argument @a notification
  82. */
  83. #define rtiNOTIFICATION_COMPARE1 2U
  84. /** @def rtiNOTIFICATION_COMPARE2
  85. * @brief Alias name for RTI compare 2 notification
  86. *
  87. * This is an alias name for the RTI compare 2 notification.
  88. *
  89. * @note This value should be used for API argument @a notification
  90. */
  91. #define rtiNOTIFICATION_COMPARE2 4U
  92. /** @def rtiNOTIFICATION_COMPARE3
  93. * @brief Alias name for RTI compare 3 notification
  94. *
  95. * This is an alias name for the RTI compare 3 notification.
  96. *
  97. * @note This value should be used for API argument @a notification
  98. */
  99. #define rtiNOTIFICATION_COMPARE3 8U
  100. /** @def rtiNOTIFICATION_TIMEBASE
  101. * @brief Alias name for RTI timebase notification
  102. *
  103. * This is an alias name for the RTI timebase notification.
  104. *
  105. * @note This value should be used for API argument @a notification
  106. */
  107. #define rtiNOTIFICATION_TIMEBASE 0x10000U
  108. /** @def rtiNOTIFICATION_COUNTER0
  109. * @brief Alias name for RTI counter block 0 overflow notification
  110. *
  111. * This is an alias name for the RTI counter block 0 overflow notification.
  112. *
  113. * @note This value should be used for API argument @a notification
  114. */
  115. #define rtiNOTIFICATION_COUNTER0 0x20000U
  116. /** @def rtiNOTIFICATION_COUNTER1
  117. * @brief Alias name for RTI counter block 1 overflow notification
  118. *
  119. * This is an alias name for the RTI counter block 1 overflow notification.
  120. *
  121. * @note This value should be used for API argument @a notification
  122. */
  123. #define rtiNOTIFICATION_COUNTER1 0x40000U
  124. /* USER CODE BEGIN (1) */
  125. /* USER CODE END */
  126. /** @enum dwdViolationTag
  127. * @brief DWD Violations
  128. */
  129. typedef enum dwdViolationTag
  130. {
  131. NoTime_Violation = 0U,
  132. Time_Window_Violation = 1U,
  133. EndTime_Window_Violation = 2U,
  134. StartTime_Window_Violation = 3U,
  135. Key_Seq_Violation = 4U
  136. }dwdViolation_t;
  137. /* USER CODE BEGIN (2) */
  138. /* USER CODE END */
  139. /** @enum dwdResetStatusTag
  140. * @brief DWD Reset status
  141. */
  142. typedef enum dwdResetStatusTag
  143. {
  144. No_Reset_Generated = 0U,
  145. Reset_Generated = 1U
  146. }dwdResetStatus_t;
  147. /* USER CODE BEGIN (3) */
  148. /* USER CODE END */
  149. /** @enum dwwdReactionTag
  150. * @brief DWWD Reaction on vioaltion
  151. */
  152. typedef enum dwwdReactionTag
  153. {
  154. Generate_Reset = 0x00000005U,
  155. Generate_NMI = 0x0000000AU
  156. }dwwdReaction_t;
  157. /* USER CODE BEGIN (4) */
  158. /* USER CODE END */
  159. /** @enum dwwdWindowSizeTag
  160. * @brief DWWD Window size
  161. */
  162. typedef enum dwwdWindowSizeTag
  163. {
  164. Size_100_Percent = 0x00000005U,
  165. Size_50_Percent = 0x00000050U,
  166. Size_25_Percent = 0x00000500U,
  167. Size_12_5_Percent = 0x00005000U,
  168. Size_6_25_Percent = 0x00050000U,
  169. Size_3_125_Percent = 0x00500000U
  170. }dwwdWindowSize_t;
  171. /* USER CODE BEGIN (5) */
  172. /* USER CODE END */
  173. /* Configuration registers */
  174. typedef struct rti_config_reg
  175. {
  176. uint32 CONFIG_GCTRL;
  177. uint32 CONFIG_TBCTRL;
  178. uint32 CONFIG_CAPCTRL;
  179. uint32 CONFIG_COMPCTRL;
  180. uint32 CONFIG_UDCP0;
  181. uint32 CONFIG_UDCP1;
  182. uint32 CONFIG_UDCP2;
  183. uint32 CONFIG_UDCP3;
  184. uint32 CONFIG_TBLCOMP;
  185. uint32 CONFIG_TBHCOMP;
  186. uint32 CONFIG_SETINT;
  187. uint32 CONFIG_DWDCTRL;
  188. uint32 CONFIG_DWDPRLD;
  189. uint32 CONFIG_WWDRXNCTRL;
  190. uint32 CONFIG_WWDSIZECTRL;
  191. } rti_config_reg_t;
  192. /* Configuration registers initial value */
  193. #define RTI_GCTRL_CONFIGVALUE (1U << 16U) | 0x00000000U
  194. #define RTI_TBCTRL_CONFIGVALUE 0x00000000U
  195. #define RTI_CAPCTRL_CONFIGVALUE 0U | 0U
  196. #define RTI_COMPCTRL_CONFIGVALUE 0x00001000U | 0x00000100U | 0x00000000U | 0x00000000U
  197. #define RTI_UDCP0_CONFIGVALUE 10000U
  198. #define RTI_UDCP1_CONFIGVALUE 50000U
  199. #define RTI_UDCP2_CONFIGVALUE 80000U
  200. #define RTI_UDCP3_CONFIGVALUE 100000U
  201. #define RTI_TBLCOMP_CONFIGVALUE 0U
  202. #define RTI_TBHCOMP_CONFIGVALUE 0U
  203. #define RTI_SETINT_CONFIGVALUE 0U
  204. #define RTI_DWDCTRL_CONFIGVALUE 0x5312ACEDU
  205. #define RTI_DWDPRLD_CONFIGVALUE 0xFFFU
  206. #define RTI_WWDRXNCTRL_CONFIGVALUE 0x5U
  207. #define RTI_WWDSIZECTRL_CONFIGVALUE 0x5U
  208. /**
  209. * @defgroup RTI RTI
  210. * @brief Real Time Interrupt Module.
  211. *
  212. * The real-time interrupt (RTI) module provides timer functionality for operating systems and for
  213. * benchmarking code. The RTI module can incorporate several counters that define the timebases needed
  214. * for scheduling in the operating system.
  215. *
  216. * Related Files
  217. * - reg_rti.h
  218. * - rti.h
  219. * - rti.c
  220. * @addtogroup RTI
  221. * @{
  222. */
  223. /* RTI Interface Functions */
  224. void rtiInit(void);
  225. void rtiStartCounter(uint32 counter);
  226. void rtiStopCounter(uint32 counter);
  227. uint32 rtiResetCounter(uint32 counter);
  228. void rtiSetPeriod(uint32 compare, uint32 period);
  229. uint32 rtiGetPeriod(uint32 compare);
  230. uint32 rtiGetCurrentTick(uint32 compare);
  231. void rtiEnableNotification(uint32 notification);
  232. void rtiDisableNotification(uint32 notification);
  233. void dwdInit(uint16 dwdPreload);
  234. void dwwdInit(dwwdReaction_t Reaction, uint16 dwdPreload, dwwdWindowSize_t Window_Size);
  235. uint32 dwwdGetCurrentDownCounter(void);
  236. void dwdCounterEnable(void);
  237. void dwdSetPreload(uint16 dwdPreload);
  238. void dwdReset(void);
  239. void dwdGenerateSysReset(void);
  240. boolean IsdwdKeySequenceCorrect(void);
  241. dwdResetStatus_t dwdGetStatus(void);
  242. dwdViolation_t dwdGetViolationStatus(void);
  243. void dwdClearFlag(void);
  244. void rtiGetConfigValue(rti_config_reg_t *config_reg, config_value_type_t type);
  245. /** @fn void rtiNotification(uint32 notification)
  246. * @brief Notification of RTI module
  247. * @param[in] notification Select notification of RTI module:
  248. * - rtiNOTIFICATION_COMPARE0: RTI compare 0 notification
  249. * - rtiNOTIFICATION_COMPARE1: RTI compare 1 notification
  250. * - rtiNOTIFICATION_COMPARE2: RTI compare 2 notification
  251. * - rtiNOTIFICATION_COMPARE3: RTI compare 3 notification
  252. * - rtiNOTIFICATION_TIMEBASE: RTI Timebase notification
  253. * - rtiNOTIFICATION_COUNTER0: RTI counter 0 overflow notification
  254. * - rtiNOTIFICATION_COUNTER1: RTI counter 1 overflow notification
  255. *
  256. * @note This function has to be provide by the user.
  257. */
  258. void rtiNotification(uint32 notification);
  259. /**@}*/
  260. /* USER CODE BEGIN (6) */
  261. /* USER CODE END */
  262. #endif