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