1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
32 33 34 35
36
37 package ti.sysbios.family.arp32;
38
39 import xdc.rov.ViewInfo;
40
41 import xdc.runtime.Types;
42 import xdc.runtime.Error;
43
44 import ti.sysbios.interfaces.ITimer;
45 import ti.sysbios.family.arp32.Hwi;
46
47 /*!
48 * ======== Timer ========
49 * Timer Peripherals Manager.
50 *
51 * The timers used are the two CTM timers (0 and 1)
52 * that support interrupts.
53 *
54 * @p(html)
55 * <h3> Calling Context </h3>
56 * <table border="1" cellpadding="3">
57 * <colgroup span="1"></colgroup> <colgroup span="5" align="center"></colgroup>
58 *
59 * <tr><th> Function </th><th> Hwi </th><th> Swi </th><th> Task </th><th> Main </th><th> Startup </th></tr>
60 * <!-- -->
61 * <tr><td> {@link #getNumTimers} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
62 * <tr><td> {@link #getStatus} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
63 * <tr><td> {@link #Params_init} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
64 * <tr><td> {@link #construct} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
65 * <tr><td> {@link #create} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
66 * <tr><td> {@link #delete} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
67 * <tr><td> {@link #destruct} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
68 * <tr><td> {@link #getCount} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
69 * <tr><td> {@link #getFreq} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
70 * <tr><td> {@link #getPeriod} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
71 * <tr><td> {@link #reconfig} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
72 * <tr><td> {@link #setPeriod} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
73 * <tr><td> {@link #setPeriodMicroSecs} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
74 * <tr><td> {@link #start} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
75 * <tr><td> {@link #stop} </td><td> - </td><td> - </td><td> - </td><td> - </td><td> - </td></tr>
76 * <tr><td colspan="6"> Definitions: <br />
77 * <ul>
78 * <li> <b>Hwi</b>: API is callable from a Hwi thread. </li>
79 * <li> <b>Swi</b>: API is callable from a Swi thread. </li>
80 * <li> <b>Task</b>: API is callable from a Task thread. </li>
81 * <li> <b>Main</b>: API is callable during any of these phases: </li>
82 * <ul>
83 * <li> In your module startup after this module is started (e.g. Cache_Module_startupDone() returns TRUE). </li>
84 * <li> During xdc.runtime.Startup.lastFxns. </li>
85 * <li> During main().</li>
86 * <li> During BIOS.startupFxns.</li>
87 * </ul>
88 * <li> <b>Startup</b>: API is callable during any of these phases:</li>
89 * <ul>
90 * <li> During xdc.runtime.Startup.firstFxns.</li>
91 * <li> In your module startup before this module is started (e.g. Cache_Module_startupDone() returns FALSE).</li>
92 * </ul>
93 * </ul>
94 * </td></tr>
95 *
96 * </table>
97 * @p
98 */
99 @InstanceFinalize
100 @InstanceInitError
101 @ModuleStartup
102
103 module Timer inherits ti.sysbios.interfaces.ITimer
104 {
105 /*! Max value of Timer period for PeriodType_COUNTS*/
106 const UInt MAX_PERIOD = 0xffffffff;
107
108 /*!
109 * Number of timer peripherals on chip
110 *
111 * Only 2 are available to each core.
112 */
113 const Int NUM_TIMER_DEVICES = 2;
114
115 /*! Timer clock divider wrt cpu clock */
116 const Int TIMER_CLOCK_DIVIDER = 1;
117
118 /*! @_nodoc
119 * Min instructions to use in trigger().
120 */
121 const Int MIN_SWEEP_PERIOD = 1;
122
123 /*! @_nodoc */
124 @XmlDtd
125 metaonly struct BasicView {
126 Ptr halTimerHandle;
127 String label;
128 UInt id;
129 String device;
130 String startMode;
131 String runMode;
132 UInt period;
133 String periodType;
134 UInt intNum;
135 String tickFxn[];
136 UArg arg;
137 String extFreq;
138 String hwiHandle;
139 };
140
141
142 /*! @_nodoc */
143 metaonly struct ModuleView {
144 String availMask;
145 }
146
147 /*! @_nodoc */
148 metaonly struct DeviceView {
149 UInt id;
150 String device;
151 String devAddr;
152 UInt intNum;
153 String runMode;
154 UInt period;
155 UInt currCount;
156 UInt remainingCount;
157 };
158
159 /*! @_nodoc */
160 @Facet
161 metaonly config ViewInfo.Instance rovViewInfo =
162 ViewInfo.create({
163 viewMap: [
164 [
165 'Basic',
166 {
167 type: ViewInfo.INSTANCE,
168 viewInitFxn: 'viewInitBasic',
169 structName: 'BasicView'
170 }
171 ],
172 [
173 'Device',
174 {
175 type: ViewInfo.INSTANCE,
176 viewInitFxn: 'viewInitDevice',
177 structName: 'DeviceView'
178 }
179 ],
180 [
181 'Module',
182 {
183 type: ViewInfo.MODULE,
184 viewInitFxn: 'viewInitModule',
185 structName: 'ModuleView'
186 }
187 ],
188 ]
189 });
190
191 /*!
192 * Error raised when timer id specified is not supported.
193 */
194 config Error.Id E_invalidTimer = {msg: "E_invalidTimer: Invalid Timer Id %d"};
195
196 /*!
197 * Error raised when timer requested is in use
198 */
199 config Error.Id E_notAvailable =
200 {msg: "E_notAvailable: Timer not available %d"};
201
202 /*!
203 * Error raised when period requested is not supported
204 */
205 config Error.Id E_cannotSupport =
206 {msg: "E_cannotSupport: Timer cannot support requested period %d"};
207
208 /*!
209 * ======== anyMask ========
210 * Available mask to be used when select = Timer_ANY
211 */
212 config UInt anyMask = 0x3;
213
214 /*!
215 * ======== getHandle ========
216 * Get Handle associated with a timer id.
217 *
218 * @param(id) timer Id.
219 * @b(returns) timer Handle
220 */
221 @DirectCall
222 Handle getHandle(UInt id);
223
224 instance:
225
226 /*! Hwi Params for Hwi Object. Default is null. */
227 config Hwi.Params *hwiParams = null;
228
229 /*!
230 * ======== reconfig ========
231 * Used to modify static timer instances at runtime.
232 *
233 * @param(timerParams) timer Params
234 * @param(tickFxn) function that runs when timer expires
235 */
236 @DirectCall
237 Void reconfig(FuncPtr tickFxn, const Params *timerParams, Error.Block *eb);
238
239
240 internal:
241
242 /*!
243 * ======== noStartupNeeded ========
244 * Flag used to prevent misc code from being brought in
245 * un-necessarily
246 */
247 config UInt startupNeeded = false;
248
249 struct Instance_State {
250 Bool staticInst;
251 Int id;
252 Int ctmid;
253 RunMode runMode;
254 StartMode startMode;
255 UInt period;
256 PeriodType periodType;
257 UInt intNum;
258 UArg arg;
259 Hwi.FuncPtr tickFxn;
260 Types.FreqHz extFreq;
261 Hwi.Handle hwi;
262 }
263
264 struct Module_State {
265 UInt availMask;
266 UInt *baseAddr;
267 Handle handles[NUM_TIMER_DEVICES];
268 }
269 }
270 271 272 273
274