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 package ti.sysbios.family.arm.cc26xx;
37
38 import xdc.rov.ViewInfo;
39 import ti.sysbios.knl.Clock;
40
41 /*!
42 * ======== Alarm ========
43 * CC26xx Alarm Manager
44 *
45 * This module manages Alarms objects. Alarm objects internally create
46 * and schedule Clock objects, to expire at specified 64-bit RTC count values.
47 *
48 * @p(html)
49 * <h3> Calling Context </h3>
50 * <table border="1" cellpadding="3">
51 * <colgroup span="1"></colgroup> <colgroup span="5" align="center">
52 * </colgroup>
53 *
54 * <tr><th> Function </th><th> Hwi </th><th> Swi </th>
55 * <th> Task </th><th> Main </th><th> Startup </th></tr>
56 * <!-- -->
57 * <tr><td> {@link #getCount} </td><td> Y </td>
58 * <td> Y </td><td> Y </td><td> Y </td><td> N </td></tr>
59 * <tr><td> {@link #Params_init} </td><td> Y </td>
60 * <td> Y </td><td> Y </td><td> Y </td><td> Y </td></tr>
61 * <tr><td> {@link #construct} </td><td> N </td>
62 * <td> N </td><td> Y </td><td> Y </td><td> N </td></tr>
63 * <tr><td> {@link #create} </td><td> N </td>
64 * <td> N </td><td> Y </td><td> Y </td><td> N </td></tr>
65 * <tr><td> {@link #delete} </td><td> N </td>
66 * <td> N </td><td> Y </td><td> Y </td><td> N </td></tr>
67 * <tr><td> {@link #destruct} </td><td> N </td>
68 * <td> N </td><td> Y </td><td> Y </td><td> N </td></tr>
69 * <tr><td> {@link #set} </td><td> Y </td>
70 * <td> Y </td><td> Y </td><td> Y </td><td> N </td></tr>
71 * <tr><td> {@link #setFunc} </td><td> Y </td>
72 * <td> Y </td><td> Y </td><td> Y </td><td> N </td></tr>
73 * <tr><td> {@link #stop} </td><td> Y </td>
74 * <td> Y </td><td> Y </td><td> Y </td><td> N </td></tr>
75 * <tr><td colspan="6"> Definitions: <br />
76 * <ul>
77 * <li> <b>Hwi</b>: API is callable from a Hwi thread. </li>
78 * <li> <b>Swi</b>: API is callable from a Swi thread. </li>
79 * <li> <b>Task</b>: API is callable from a Task thread. </li>
80 * <li> <b>Main</b>: API is callable during any of these phases: </li>
81 * <ul>
82 * <li> During main().</li>
83 * <li> During BIOS.startupFxns.</li>
84 * </ul>
85 * <li> <b>Startup</b>: API is callable during xdc.runtime.Startup functions.</li>
86 * </ul>
87 * </td></tr>
88 *
89 * </table>
90 * @p
91 */
92
93 @DirectCall
94 @InstanceFinalize
95
96 module Alarm
97 {
98 /*!
99 * ======== BasicView ========
100 * @_nodoc
101 */
102 metaonly struct BasicView {
103 String label;
104 UInt32 timeout;
105 UInt64 rtcCount;
106 UInt64 rtcInterrupt;
107 Bool active;
108 }
109
110 /*!
111 * ======== rovViewInfo ========
112 * @_nodoc
113 */
114 @Facet
115 metaonly config ViewInfo.Instance rovViewInfo =
116 ViewInfo.create({
117 viewMap: [
118 [
119 'Basic',
120 {
121 type: ViewInfo.INSTANCE,
122 viewInitFxn: 'viewInitBasic',
123 structName: 'BasicView'
124 }
125 ],
126 ]
127 });
128
129 /*!
130 * ======== FuncPtr ========
131 * Instance function prototype
132 */
133 typedef Void (*FuncPtr)(UArg);
134
135 /*!
136 * ======== getCount ========
137 * Get the current RTC count
138 */
139 UInt64 getCount();
140
141 instance:
142
143 /*!
144 * ======== create ========
145 * Create an Alarm object
146 *
147 * @param(alarmFxn) alarm function, of type
148 * {@link #FuncPtr Alarm_FuncPtr}
149 * @param(arg) argument to the alarm function
150 */
151 create(FuncPtr alarmFxn, UArg arg);
152
153 /*!
154 * ======== set ========
155 * Set and start an alarm, to expire upon a specified RTC count value
156 *
157 * The RTC count will be converted to the closest
158 * {@link ti.sysbios.knl.Clock Clock} tick that expires before the
159 * specified RTC count.
160 *
161 * When the alarm expires, the alarm's function will be called, with the
162 * specified argument, from {@link ti.sysbios.knl.Swi Swi} context. The
163 * alarm function could complete its processing and return, or it might
164 * defer processing by signaling another thread.
165 *
166 * The alarm function can be unique to the application, or it might be
167 * a common kernel function. For example, to create an alarm that wakes
168 * a task that is pended upon a semaphore, the alarm function could be
169 * Semaphore_post(), and the argument the handle of a semaphore that
170 * the task is pended upon:
171 *
172 * @p(code)
173 * Void yourFunc() {
174 * ...
175 * sem = Semaphore_create(0, NULL, NULL);
176 * ...
177 * alm = Alarm_create((Alarm_FuncPtr)Semaphore_post, (UArg)sem, NULL,
178 * NULL);
179 * ...
180 * Alarm_set(alm, 0x200000000);
181 * ...
182 * }
183 * @p
184 *
185 * @param(countRTC) 64-bit target RTC count
186 *
187 * @b(returns) TRUE if alarm is set, FALSE if countRTC is in the past,
188 * or is too soon to trigger the corresponding Clock
189 * interrupt
190 */
191 Bool set(UInt64 countRTC);
192
193 /*!
194 * ======== setFunc ========
195 * Change an alarm's function and argument
196 *
197 * Replaces an alarm's function and argument, with a new function and
198 * argument.
199 *
200 * @param(fxn) alarm function, of type
201 * {@link #FuncPtr Alarm_FuncPtr}
202 * @param(arg) argument to the Alarm function
203 *
204 * @a(constraints)
205 * Cannot change the function and argument of Alarm that has already been
206 * started with {@link #set Alarm_set} or {@link #setTick Alarm_setTick}.
207 */
208 Void setFunc(FuncPtr fxn, UArg arg);
209
210 /*!
211 * ======== stop ========
212 * Stop an alarm that has been started with {@link #set Alarm_set} or
213 * {@link #setTick Alarm_setTick}
214 */
215 Void stop();
216
217 internal:
218
219
220 struct Instance_State {
221 Clock.Object clockObj;
222 UInt64 rtcCount;
223 };
224 }