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