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.knl;
37
38 import xdc.rov.ViewInfo;
39
40 /*!
41 * ======== Idle ========
42 * Idle Thread Manager.
43 *
44 * The Idle module is used to specify a list of functions to be called
45 * when no other tasks are running in the system.
46 *
47 * If tasking is enabled (ie {@link ti.sysbios.BIOS#taskEnabled
48 * BIOS.taskEnabled} = true), then the Task module will create an "Idle task"
49 * with the lowest possible priority. When no other tasks are running, this
50 * idle task runs in an infinite loop, calling the list of functions
51 * specified by the Idle module.
52 *
53 * If tasking is disabled (ie {@link ti.sysbios.BIOS#taskEnabled
54 * BIOS.taskEnabled} = false), then the idle functions are called in an
55 * infinite loop within the {@link ti.sysbios.BIOS#start BIOS_start}
56 * function called within main().
57 *
58 * The list of idle functions is only statically configurable; it cannot be
59 * modified at runtime.
60 *
61 */
62
63 module Idle
64 {
65 /*! Idle function type definition. */
66 typedef Void (*FuncPtr)();
67
68 metaonly struct ModuleView {
69 UInt index;
70 String fxn;
71 }
72
73 /*! @_nodoc */
74 @Facet
75 metaonly config ViewInfo.Instance rovViewInfo =
76 xdc.rov.ViewInfo.create({
77 viewMap: [
78 ['Idle.funcList',
79 {
80 type: ViewInfo.MODULE_DATA,
81 viewInitFxn: 'viewInitModule',
82 structName: 'ModuleView'
83 }
84 ]
85 ]
86 });
87
88 /*!
89 * ======== funcList ========
90 * @_nodoc
91 * The array of functions to be called when no other Tasks are running.
92 */
93 config FuncPtr funcList[length] = [];
94
95 /*!
96 * ======== idleFxns ========
97 * Functions to be called when no other Tasks are running
98 *
99 * Functions added to the Idle.idleFxns[] array, as well as those
100 * added via the Idle.addFunc() API will be run by the Idle loop.
101 *
102 * @a(NOTE)
103 * This array is intended for use by the GUI config tool.
104 *
105 * Config script authors are encourged to use the
106 * {@link #addFunc Idle.addFunc()} API to add idle functions
107 * to their applications.
108 */
109 metaonly config FuncPtr idleFxns[length] = [
110 null, null, null, null,
111 null, null, null, null
112 ];
113
114 /*!
115 * ======== addFunc ========
116 * Statically add a function to the Idle function list.
117 *
118 * Functions added to the Idle function list are
119 * called repeatedly by the Idle task function.
120 *
121 * @see Idle#run
122 *
123 * Usage example:
124 *
125 * @p(code)
126 * var Idle = xdc.useModule('ti.sysbios.knl.Idle');
127 * Idle.addFunc('&myIdleFunc'); // add myIdleFunc()
128 * @p
129 *
130 * @a(NOTE)
131 * Idle functions have the following signature:
132 * @p(code)
133 * Void func(Void);
134 * @p
135 */
136 metaonly Void addFunc(FuncPtr func);
137
138 /*!
139 * ======== loop ========
140 * @_nodoc
141 * Idle loop which calls the idle functions in an infinite loop.
142 *
143 * This function is called internally and is not normally intended
144 * to be called by the client.
145 *
146 * When tasking is enabled, the Task module creates an Idle task which
147 * simply calls this function. If tasking is disabled, then this function
148 * is called after main and any module startup functions.
149 *
150 * The body of this function is an infinite loop that calls the "run"
151 * function.
152 */
153 @DirectCall
154 Void loop(UArg arg1, UArg arg2);
155
156 /*!
157 * ======== run ========
158 * Make one pass through idle functions
159 *
160 * This function is called repeatedly by the Idle task when
161 * the Idle task has been enabled in the Task module
162 * (see {@link Task#enableIdleTask}).
163 *
164 * This function makes one pass through an internal static array
165 * of functions made up of functions added using the
166 * {@link #addFunc Idle.addFunc()} API as well as any functions
167 * defined in the GUI tool's {@link #idleFxns Idle.idleFxns[]} array.
168 *
169 * This function returns after all functions have been executed one
170 * time.
171 *
172 * @see Idle#addFunc
173 * @see Task#enableIdleTask
174 * @see Task#allBlockedFunc
175 */
176 @DirectCall
177 Void run();
178
179 }
180 181 182 183
184