rti.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. /** @file rti.c
  2. * @brief RTI Driver Source File
  3. * @date 29.May.2013
  4. * @version 03.05.02
  5. *
  6. * This file contains:
  7. * - API Functions
  8. * - Interrupt Handlers
  9. * .
  10. * which are relevant for the RTI driver.
  11. */
  12. /* (c) Texas Instruments 2009-2013, All rights reserved. */
  13. /* USER CODE BEGIN (0) */
  14. /* USER CODE END */
  15. /* Include Files */
  16. #include "rti.h"
  17. /* USER CODE BEGIN (1) */
  18. /* USER CODE END */
  19. /** @fn void rtiInit(void)
  20. * @brief Initializes RTI Driver
  21. *
  22. * This function initializes the RTI driver.
  23. *
  24. */
  25. /* USER CODE BEGIN (2) */
  26. /* USER CODE END */
  27. void rtiInit(void)
  28. {
  29. /* USER CODE BEGIN (3) */
  30. /* USER CODE END */
  31. /** @b Initialize @b RTI1: */
  32. /** - Setup NTU source, debug options and disable both counter blocks */
  33. rtiREG1->GCTRL = (1U << 16U) | 0x00000000U;
  34. /** - Setup timebase for free running counter 0 */
  35. rtiREG1->TBCTRL = 0x00000000U;
  36. /** - Enable/Disable capture event sources for both counter blocks */
  37. rtiREG1->CAPCTRL = 0U | 0U;
  38. /** - Setup input source compare 0-3 */
  39. rtiREG1->COMPCTRL = 0x00001000U | 0x00000100U | 0x00000000U | 0x00000000U;
  40. /** - Reset up counter 0 */
  41. rtiREG1->CNT[0U].UCx = 0x00000000U;
  42. /** - Reset free running counter 0 */
  43. rtiREG1->CNT[0U].FRCx = 0x00000000U;
  44. /** - Setup up counter 0 compare value
  45. * - 0x00000000: Divide by 2^32
  46. * - 0x00000001-0xFFFFFFFF: Divide by (CPUC0 + 1)
  47. */
  48. rtiREG1->CNT[0U].CPUCx = 9U;
  49. /** - Reset up counter 1 */
  50. rtiREG1->CNT[1U].UCx = 0x00000000U;
  51. /** - Reset free running counter 1 */
  52. rtiREG1->CNT[1U].FRCx = 0x00000000U;
  53. /** - Setup up counter 1 compare value
  54. * - 0x00000000: Divide by 2^32
  55. * - 0x00000001-0xFFFFFFFF: Divide by (CPUC1 + 1)
  56. */
  57. rtiREG1->CNT[1U].CPUCx = 9U;
  58. /** - Setup compare 0 value. This value is compared with selected free running counter. */
  59. rtiREG1->CMP[0U].COMPx = 10000U;
  60. /** - Setup update compare 0 value. This value is added to the compare 0 value on each compare match. */
  61. rtiREG1->CMP[0U].UDCPx = 10000U;
  62. /** - Setup compare 1 value. This value is compared with selected free running counter. */
  63. rtiREG1->CMP[1U].COMPx = 50000U;
  64. /** - Setup update compare 1 value. This value is added to the compare 1 value on each compare match. */
  65. rtiREG1->CMP[1U].UDCPx = 50000U;
  66. /** - Setup compare 2 value. This value is compared with selected free running counter. */
  67. rtiREG1->CMP[2U].COMPx = 80000U;
  68. /** - Setup update compare 2 value. This value is added to the compare 2 value on each compare match. */
  69. rtiREG1->CMP[2U].UDCPx = 80000U;
  70. /** - Setup compare 3 value. This value is compared with selected free running counter. */
  71. rtiREG1->CMP[3U].COMPx = 100000U;
  72. /** - Setup update compare 3 value. This value is added to the compare 3 value on each compare match. */
  73. rtiREG1->CMP[3U].UDCPx = 100000U;
  74. /** - Clear all pending interrupts */
  75. rtiREG1->INTFLAG = 0x0007000FU;
  76. /** - Disable all interrupts */
  77. rtiREG1->CLEARINT = 0x00070F0FU;
  78. /** @note This function has to be called before the driver can be used.\n
  79. * This function has to be executed in privileged mode.\n
  80. * This function does not start the counters.
  81. */
  82. /* USER CODE BEGIN (4) */
  83. /* USER CODE END */
  84. }
  85. /* USER CODE BEGIN (5) */
  86. /* USER CODE END */
  87. /** @fn void rtiStartCounter(uint32 counter)
  88. * @brief Starts RTI Counter block
  89. * @param[in] counter Select counter block to be started:
  90. * - rtiCOUNTER_BLOCK0: RTI counter block 0 will be started
  91. * - rtiCOUNTER_BLOCK1: RTI counter block 1 will be started
  92. *
  93. * This function starts selected counter block of the selected RTI module.
  94. */
  95. /* USER CODE BEGIN (6) */
  96. /* USER CODE END */
  97. void rtiStartCounter(uint32 counter)
  98. {
  99. /* USER CODE BEGIN (7) */
  100. /* USER CODE END */
  101. rtiREG1->GCTRL |= (1U << (counter & 3U));
  102. /** @note The function rtiInit has to be called before this function can be used.\n
  103. * This function has to be executed in privileged mode.
  104. */
  105. /* USER CODE BEGIN (8) */
  106. /* USER CODE END */
  107. }
  108. /* USER CODE BEGIN (9) */
  109. /* USER CODE END */
  110. /** @fn void rtiStopCounter(uint32 counter)
  111. * @brief Stops RTI Counter block
  112. * @param[in] counter Select counter to be stopped:
  113. * - rtiCOUNTER_BLOCK0: RTI counter block 0 will be stopped
  114. * - rtiCOUNTER_BLOCK1: RTI counter block 1 will be stopped
  115. *
  116. * This function stops selected counter block of the selected RTI module.
  117. */
  118. /* USER CODE BEGIN (10) */
  119. /* USER CODE END */
  120. void rtiStopCounter(uint32 counter)
  121. {
  122. /* USER CODE BEGIN (11) */
  123. /* USER CODE END */
  124. rtiREG1->GCTRL &= ~(1U << (counter & 3U));
  125. /** @note The function rtiInit has to be called before this function can be used.\n
  126. * This function has to be executed in privileged mode.
  127. */
  128. /* USER CODE BEGIN (12) */
  129. /* USER CODE END */
  130. }
  131. /* USER CODE BEGIN (13) */
  132. /* USER CODE END */
  133. /** @fn uint32 rtiResetCounter(uint32 counter)
  134. * @brief Reset RTI Counter block
  135. * @param[in] counter Select counter block to be reset:
  136. * - rtiCOUNTER_BLOCK0: RTI counter block 0 will be reset
  137. * - rtiCOUNTER_BLOCK1: RTI counter block 1 will be reset
  138. * @return The function will return:
  139. * - 0: When the counter reset wasn't successful
  140. * - 1: When the counter reset was successful
  141. *
  142. * This function resets selected counter block of the selected RTI module.
  143. */
  144. /* USER CODE BEGIN (14) */
  145. /* USER CODE END */
  146. uint32 rtiResetCounter(uint32 counter)
  147. {
  148. uint32 success = 0U;
  149. /* USER CODE BEGIN (15) */
  150. /* USER CODE END */
  151. if ((!(rtiREG1->GCTRL & (1U << (counter & 3U)))) != 0U)
  152. {
  153. rtiREG1->CNT[counter].UCx = 0x00000000U;
  154. rtiREG1->CNT[counter].FRCx = 0x00000000U;
  155. success = 1U;
  156. }
  157. /** @note The function rtiInit has to be called before this function can be used.\n
  158. * This function has to be executed in privileged mode.\n
  159. * The selected counter block has to be stopped before it can reset.
  160. */
  161. /* USER CODE BEGIN (16) */
  162. /* USER CODE END */
  163. return success;
  164. }
  165. /* USER CODE BEGIN (17) */
  166. /* USER CODE END */
  167. /** @fn void rtiSetPeriod(uint32 compare, uint32 period)
  168. * @brief Set new period of RTI compare
  169. * @param[in] compare Select compare to change period:
  170. * - rtiCOMPARE0: RTI compare 0 will change the period
  171. * - rtiCOMPARE1: RTI compare 1 will change the period
  172. * - rtiCOMPARE2: RTI compare 2 will change the period
  173. * - rtiCOMPARE3: RTI compare 3 will change the period
  174. * @param[in] period new period in [ticks - 1]:
  175. * - 0x00000000: Divide by 1
  176. * - n: Divide by n + 1
  177. *
  178. * This function will change the period of the selected compare.
  179. */
  180. /* USER CODE BEGIN (18) */
  181. /* USER CODE END */
  182. void rtiSetPeriod(uint32 compare, uint32 period)
  183. {
  184. /* USER CODE BEGIN (19) */
  185. /* USER CODE END */
  186. rtiREG1->CMP[compare].UDCPx = period;
  187. /** @note The function rtiInit has to be called before this function can be used.\n
  188. * This function has to be executed in privileged mode.\n
  189. * When the corresponding counter block is not stopped,\n
  190. * the period will change on the next compare match of the old period.
  191. */
  192. /* USER CODE BEGIN (20) */
  193. /* USER CODE END */
  194. }
  195. /* USER CODE BEGIN (21) */
  196. /* USER CODE END */
  197. /** @fn uint32 rtiGetPeriod(uint32 compare)
  198. * @brief Get current period of RTI compare
  199. * @param[in] compare Select compare to return the current period:
  200. * - rtiCOMPARE0: RTI compare 0 will return the current period
  201. * - rtiCOMPARE1: RTI compare 1 will return the current period
  202. * - rtiCOMPARE2: RTI compare 2 will return the current period
  203. * - rtiCOMPARE3: RTI compare 3 will return the current period
  204. * @return Current period of selected compare in [ticks - 1]:
  205. * - 0x00000000: Divide by 1
  206. * - n: Divide by n + 1
  207. *
  208. * This function will return the period of the selected compare.
  209. */
  210. /* USER CODE BEGIN (22) */
  211. /* USER CODE END */
  212. uint32 rtiGetPeriod(uint32 compare)
  213. {
  214. uint32 period;
  215. /* USER CODE BEGIN (23) */
  216. /* USER CODE END */
  217. period = rtiREG1->CMP[compare].UDCPx;
  218. /** @note The function rtiInit has to be called before this function can be used.
  219. */
  220. /* USER CODE BEGIN (24) */
  221. /* USER CODE END */
  222. return period;
  223. }
  224. /* USER CODE BEGIN (25) */
  225. /* USER CODE END */
  226. /** @fn uint32 rtiGetCurrentTick(uint32 compare)
  227. * @brief Get current tick of RTI compare
  228. * @param[in] compare Select compare to return the current tick:
  229. * - rtiCOMPARE0: RTI compare 0 will return the current tick
  230. * - rtiCOMPARE1: RTI compare 1 will return the current tick
  231. * - rtiCOMPARE2: RTI compare 2 will return the current tick
  232. * - rtiCOMPARE3: RTI compare 3 will return the current tick
  233. * @return Current tick of selected compare
  234. *
  235. * This function will return the current tick of the selected compare.
  236. */
  237. /* USER CODE BEGIN (26) */
  238. /* USER CODE END */
  239. uint32 rtiGetCurrentTick(uint32 compare)
  240. {
  241. uint32 tick;
  242. uint32 counter = ((rtiREG1->COMPCTRL & (1U << (compare << 2U))) !=0U ) ? 1U : 0U;
  243. /* USER CODE BEGIN (27) */
  244. /* USER CODE END */
  245. tick = rtiREG1->CNT[counter].FRCx - (rtiREG1->CMP[compare].COMPx - rtiREG1->CMP[compare].UDCPx);
  246. /** @note The function rtiInit has to be called before this function can be used.
  247. */
  248. /* USER CODE BEGIN (28) */
  249. /* USER CODE END */
  250. return tick;
  251. }
  252. /* USER CODE BEGIN (29) */
  253. /* USER CODE END */
  254. /** @fn void dwdInit(uint16 dwdPreload)
  255. * @brief Initialize DWD Expiration Period
  256. * @param[in] dwdPreload DWD Preload value for expiration time.
  257. * - Texp = (dwdPreload +1) / RTICLK
  258. * - n: Divide by n + 1
  259. *
  260. * This function can be called to set the DWD expiration
  261. *
  262. */
  263. void dwdInit(uint16 dwdPreload)
  264. {
  265. /* USER CODE BEGIN (30) */
  266. /* USER CODE END */
  267. /* Clear the violations if already present */
  268. rtiREG1->WDSTATUS = 0xFFU;
  269. rtiREG1->DWDPRLD = dwdPreload;
  270. /* USER CODE BEGIN (31) */
  271. /* USER CODE END */
  272. }
  273. /* USER CODE BEGIN (32) */
  274. /* USER CODE END */
  275. /** @fn void dwwdInit(dwwdReaction_t Reaction, uint16 dwdPreload, dwwdWindowSize_t Window_Size)
  276. * @brief Initialize DWD Expiration Period
  277. * @param[in] Reaction DWWD reaction if the watchdog is serviced outside the time window.
  278. * - Generate_Reset
  279. * - Generate_NMI
  280. * @param[in] dwdPreload DWWD Preload value for the watchdog expiration time.
  281. * - Texp = (dwdPreload +1) / RTICLK
  282. * - n: Divide by n + 1
  283. * @param[in] Window_Size DWWD time window size
  284. * - Size_100_Percent
  285. * - Size_50_Percent
  286. * - Size_25_Percent
  287. * - Size_12_5_Percent
  288. * - Size_6_25_Percent
  289. * - Size_3_125_Percent
  290. *
  291. * This function can be called to set the DWD expiration
  292. *
  293. */
  294. void dwwdInit(dwwdReaction_t Reaction, uint16 dwdPreload, dwwdWindowSize_t Window_Size)
  295. {
  296. /* USER CODE BEGIN (33) */
  297. /* USER CODE END */
  298. /* Clear the violations if already present */
  299. rtiREG1->WDSTATUS = 0xFFU;
  300. rtiREG1->WWDSIZECTRL = (uint32) Window_Size;
  301. rtiREG1->DWDPRLD = (uint32) dwdPreload;
  302. rtiREG1->WWDRXNCTRL = (uint32) Reaction;
  303. /* USER CODE BEGIN (34) */
  304. /* USER CODE END */
  305. }
  306. /* USER CODE BEGIN (35) */
  307. /* USER CODE END */
  308. /** @fn uint32 dwwdGetCurrentDownCounter(void)
  309. * @brief Get the current DWWD Down Counter
  310. * @return Current tick of selected compare
  311. *
  312. * This function will get the current DWWD down counter value.
  313. *
  314. */
  315. uint32 dwwdGetCurrentDownCounter(void)
  316. {
  317. /* USER CODE BEGIN (36) */
  318. /* USER CODE END */
  319. return (rtiREG1->DWDCNTR);
  320. /* USER CODE BEGIN (37) */
  321. /* USER CODE END */
  322. }
  323. /* USER CODE BEGIN (38) */
  324. /* USER CODE END */
  325. /** @fn void dwdCounterEnable(void)
  326. * @brief Enable DWD
  327. *
  328. * This function will Enable the DWD counter.
  329. *
  330. */
  331. void dwdCounterEnable(void)
  332. {
  333. /* USER CODE BEGIN (39) */
  334. /* USER CODE END */
  335. rtiREG1->DWDCTRL = 0xA98559DAU;
  336. /* USER CODE BEGIN (40) */
  337. /* USER CODE END */
  338. }
  339. /* USER CODE BEGIN (41) */
  340. /* USER CODE END */
  341. /* USER CODE BEGIN (42) */
  342. /* USER CODE END */
  343. /* USER CODE BEGIN (43) */
  344. /* USER CODE END */
  345. /* USER CODE BEGIN (44) */
  346. /* USER CODE END */
  347. /** @fn void dwdSetPreload(uint16 dwdPreload)
  348. * @brief Initialize DWD Expiration Period
  349. * @param[in] dwdPreload DWD Preload value for the watchdog expiration time.
  350. * - Texp = (dwdPreload +1) / RTICLK
  351. * - n: Divide by n + 1
  352. *
  353. * This function can be called to set the Preload value for the watchdog expiration time.
  354. *
  355. */
  356. void dwdSetPreload(uint16 dwdPreload)
  357. {
  358. /* USER CODE BEGIN (45) */
  359. /* USER CODE END */
  360. rtiREG1->DWDPRLD = dwdPreload;
  361. /* USER CODE BEGIN (46) */
  362. /* USER CODE END */
  363. }
  364. /* USER CODE BEGIN (47) */
  365. /* USER CODE END */
  366. /** @fn void dwdReset(void)
  367. * @brief Reset Digital Watchdog
  368. *
  369. * This function can be called to reset Digital Watchdog.
  370. *
  371. */
  372. void dwdReset(void)
  373. {
  374. /* USER CODE BEGIN (48) */
  375. /* USER CODE END */
  376. rtiREG1->WDKEY = 0x0000E51AU;
  377. rtiREG1->WDKEY = 0x0000A35CU;
  378. /* USER CODE BEGIN (49) */
  379. /* USER CODE END */
  380. }
  381. /** @fn void dwdGenerateSysReset(void)
  382. * @brief Generate System Reset through DWD
  383. *
  384. * This function can be called to generate system reset using DWD.
  385. *
  386. */
  387. void dwdGenerateSysReset(void)
  388. {
  389. /* USER CODE BEGIN (50) */
  390. /* USER CODE END */
  391. rtiREG1->WDKEY = 0x0000E51AU;
  392. rtiREG1->WDKEY = 0x00002345U;
  393. /* USER CODE BEGIN (51) */
  394. /* USER CODE END */
  395. }
  396. /* USER CODE BEGIN (52) */
  397. /* USER CODE END */
  398. /** @fn boolean IsdwdKeySequenceCorrect(void)
  399. * @brief Check if DWD Key sequence correct.
  400. * @return The function will return:
  401. * - TRUE: When the DWD key sequence is written correctly.
  402. * - FALSE: When the DWD key sequence is written incorrectly / not written.
  403. *
  404. * This function will get status of the DWD Key sequence.
  405. *
  406. */
  407. boolean IsdwdKeySequenceCorrect(void)
  408. {
  409. boolean Status;
  410. /* USER CODE BEGIN (53) */
  411. /* USER CODE END */
  412. if((rtiREG1->WDSTATUS & 0x4U) == 0x4U)
  413. {
  414. Status = FALSE;
  415. }
  416. else
  417. {
  418. Status = TRUE;
  419. }
  420. /* USER CODE BEGIN (54) */
  421. /* USER CODE END */
  422. return Status;
  423. }
  424. /* USER CODE BEGIN (55) */
  425. /* USER CODE END */
  426. /** @fn dwdResetStatus_t dwdGetStatus(void)
  427. * @brief Check if Reset is generated due to DWD.
  428. * @return The function will return:
  429. * - Reset_Generated: When the Reset is generated due to DWD.
  430. * - No_Reset_Generated: No Reset is generated due to DWD.
  431. *
  432. * This function will get dwd Reset status.
  433. *
  434. */
  435. dwdResetStatus_t dwdGetStatus(void)
  436. {
  437. /* USER CODE BEGIN (56) */
  438. /* USER CODE END */
  439. dwdResetStatus_t Reset_Status;
  440. if((rtiREG1->WDSTATUS & 0x2U) == 0x2U)
  441. {
  442. Reset_Status = Reset_Generated;
  443. }
  444. else
  445. {
  446. Reset_Status = No_Reset_Generated;
  447. }
  448. /* USER CODE BEGIN (57) */
  449. /* USER CODE END */
  450. return Reset_Status;
  451. }
  452. /* USER CODE BEGIN (58) */
  453. /* USER CODE END */
  454. /** @fn void dwdClearFlag(void)
  455. * @brief Clear the DWD violation flag.
  456. *
  457. * This function will clear dwd status register.
  458. *
  459. */
  460. void dwdClearFlag(void)
  461. {
  462. /* USER CODE BEGIN (59) */
  463. /* USER CODE END */
  464. rtiREG1->WDSTATUS = 0xFFU;
  465. /* USER CODE BEGIN (60) */
  466. /* USER CODE END */
  467. }
  468. /* USER CODE BEGIN (61) */
  469. /* USER CODE END */
  470. /** @fn dwdViolation_t dwdGetViolationStatus(void)
  471. * @brief Check the status of the DWD or DWWD violation happened.
  472. * @return The function will return one of following violations occured:
  473. * - NoTime_Violation
  474. * - Key_Seq_Violation
  475. * - Time_Window_Violation
  476. * - EndTime_Window_Violation
  477. * - StartTime_Window_Violation
  478. *
  479. * This function will get status of the DWD or DWWD violation status.
  480. *
  481. */
  482. dwdViolation_t dwdGetViolationStatus(void)
  483. {
  484. /* USER CODE BEGIN (62) */
  485. /* USER CODE END */
  486. dwdViolation_t Violation_Status;
  487. if ((rtiREG1->WDSTATUS & 0x20U) == 0x20U)
  488. {
  489. Violation_Status = Time_Window_Violation;
  490. }
  491. else if ((rtiREG1->WDSTATUS & 0x04U) == 0x04U)
  492. {
  493. Violation_Status = Key_Seq_Violation;
  494. }
  495. else if((rtiREG1->WDSTATUS & 0x8U) == 0x8U)
  496. {
  497. Violation_Status = StartTime_Window_Violation;
  498. }
  499. else if ((rtiREG1->WDSTATUS & 0x10U) == 0x10U)
  500. {
  501. Violation_Status = EndTime_Window_Violation;
  502. }
  503. else
  504. {
  505. Violation_Status = NoTime_Violation;
  506. }
  507. /* USER CODE BEGIN (63) */
  508. /* USER CODE END */
  509. return Violation_Status;
  510. }
  511. /* USER CODE BEGIN (64) */
  512. /* USER CODE END */
  513. /** @fn void rtiEnableNotification(uint32 notification)
  514. * @brief Enable notification of RTI module
  515. * @param[in] notification Select notification of RTI module:
  516. * - rtiNOTIFICATION_COMPARE0: RTI compare 0 notification
  517. * - rtiNOTIFICATION_COMPARE1: RTI compare 1 notification
  518. * - rtiNOTIFICATION_COMPARE2: RTI compare 2 notification
  519. * - rtiNOTIFICATION_COMPARE3: RTI compare 3 notification
  520. * - rtiNOTIFICATION_TIMEBASE: RTI Timebase notification
  521. * - rtiNOTIFICATION_COUNTER0: RTI counter 0 overflow notification
  522. * - rtiNOTIFICATION_COUNTER1: RTI counter 1 overflow notification
  523. *
  524. * This function will enable the selected notification of a RTI module.
  525. * It is possible to enable multiple notifications masked.
  526. */
  527. /* USER CODE BEGIN (65) */
  528. /* USER CODE END */
  529. void rtiEnableNotification(uint32 notification)
  530. {
  531. /* USER CODE BEGIN (66) */
  532. /* USER CODE END */
  533. rtiREG1->INTFLAG = notification;
  534. rtiREG1->SETINT = notification;
  535. /** @note The function rtiInit has to be called before this function can be used.\n
  536. * This function has to be executed in privileged mode.
  537. */
  538. /* USER CODE BEGIN (67) */
  539. /* USER CODE END */
  540. }
  541. /* USER CODE BEGIN (68) */
  542. /* USER CODE END */
  543. /** @fn void rtiDisableNotification(uint32 notification)
  544. * @brief Disable notification of RTI module
  545. * @param[in] notification Select notification of RTI module:
  546. * - rtiNOTIFICATION_COMPARE0: RTI compare 0 notification
  547. * - rtiNOTIFICATION_COMPARE1: RTI compare 1 notification
  548. * - rtiNOTIFICATION_COMPARE2: RTI compare 2 notification
  549. * - rtiNOTIFICATION_COMPARE3: RTI compare 3 notification
  550. * - rtiNOTIFICATION_TIMEBASE: RTI Timebase notification
  551. * - rtiNOTIFICATION_COUNTER0: RTI counter 0 overflow notification
  552. * - rtiNOTIFICATION_COUNTER1: RTI counter 1 overflow notification
  553. *
  554. * This function will disable the selected notification of a RTI module.
  555. * It is possible to disable multiple notifications masked.
  556. */
  557. /* USER CODE BEGIN (69) */
  558. /* USER CODE END */
  559. void rtiDisableNotification(uint32 notification)
  560. {
  561. /* USER CODE BEGIN (70) */
  562. /* USER CODE END */
  563. rtiREG1->CLEARINT = notification;
  564. /** @note The function rtiInit has to be called before this function can be used.\n
  565. * This function has to be executed in privileged mode.
  566. */
  567. /* USER CODE BEGIN (71) */
  568. /* USER CODE END */
  569. }
  570. /* USER CODE BEGIN (72) */
  571. /* USER CODE END */
  572. /** @fn void rtiGetConfigValue(rti_config_reg_t *config_reg, config_value_type_t type)
  573. * @brief Get the initial or current values of the configuration registers
  574. *
  575. * @param[in] *config_reg: pointer to the struct to which the initial or current value of the configuration registers need to be stored
  576. * @param[in] type: whether initial or current value of the configuration registers need to be stored
  577. * - InitialValue: initial value of the configuration registers will be stored in the struct pointed by config_reg
  578. * - CurrentValue: initial value of the configuration registers will be stored in the struct pointed by config_reg
  579. *
  580. * This function will copy the initial or current value (depending on the parameter 'type') of the configuration registers to the struct pointed by config_reg
  581. *
  582. */
  583. void rtiGetConfigValue(rti_config_reg_t *config_reg, config_value_type_t type)
  584. {
  585. if (type == InitialValue)
  586. {
  587. config_reg->CONFIG_GCTRL = RTI_GCTRL_CONFIGVALUE;
  588. config_reg->CONFIG_TBCTRL = RTI_TBCTRL_CONFIGVALUE;
  589. config_reg->CONFIG_CAPCTRL = RTI_CAPCTRL_CONFIGVALUE;
  590. config_reg->CONFIG_COMPCTRL = RTI_COMPCTRL_CONFIGVALUE;
  591. config_reg->CONFIG_UDCP0 = RTI_UDCP0_CONFIGVALUE;
  592. config_reg->CONFIG_UDCP1 = RTI_UDCP1_CONFIGVALUE;
  593. config_reg->CONFIG_UDCP2 = RTI_UDCP2_CONFIGVALUE;
  594. config_reg->CONFIG_UDCP3 = RTI_UDCP3_CONFIGVALUE;
  595. config_reg->CONFIG_TBLCOMP = RTI_TBLCOMP_CONFIGVALUE;
  596. config_reg->CONFIG_TBHCOMP = RTI_TBHCOMP_CONFIGVALUE;
  597. config_reg->CONFIG_SETINT = RTI_SETINT_CONFIGVALUE;
  598. config_reg->CONFIG_DWDCTRL = RTI_DWDCTRL_CONFIGVALUE;
  599. config_reg->CONFIG_DWDPRLD = RTI_DWDPRLD_CONFIGVALUE;
  600. config_reg->CONFIG_WWDRXNCTRL = RTI_WWDRXNCTRL_CONFIGVALUE;
  601. config_reg->CONFIG_WWDSIZECTRL = RTI_WWDSIZECTRL_CONFIGVALUE;
  602. }
  603. else
  604. {
  605. config_reg->CONFIG_GCTRL = rtiREG1->GCTRL;
  606. config_reg->CONFIG_TBCTRL = rtiREG1->TBCTRL;
  607. config_reg->CONFIG_CAPCTRL = rtiREG1->CAPCTRL;
  608. config_reg->CONFIG_COMPCTRL = rtiREG1->COMPCTRL;
  609. config_reg->CONFIG_UDCP0 = rtiREG1->CMP[0U].UDCPx;
  610. config_reg->CONFIG_UDCP1 = rtiREG1->CMP[1U].UDCPx;
  611. config_reg->CONFIG_UDCP2 = rtiREG1->CMP[2U].UDCPx;
  612. config_reg->CONFIG_UDCP3 = rtiREG1->CMP[3U].UDCPx;
  613. config_reg->CONFIG_TBLCOMP = rtiREG1->TBLCOMP;
  614. config_reg->CONFIG_TBHCOMP = rtiREG1->TBHCOMP;
  615. config_reg->CONFIG_SETINT = rtiREG1->SETINT;
  616. config_reg->CONFIG_DWDCTRL = rtiREG1->DWDCTRL;
  617. config_reg->CONFIG_DWDPRLD = rtiREG1->DWDPRLD;
  618. config_reg->CONFIG_WWDRXNCTRL = rtiREG1->WWDRXNCTRL;
  619. config_reg->CONFIG_WWDSIZECTRL = rtiREG1->WWDSIZECTRL;
  620. }
  621. }