?? sch51.lst
字號:
159 2 // Task list is full
160 2 //
161 2 // Set the global error variable
162 2 Error_code_G = ERROR_SCH_TOO_MANY_TASKS;
163 2
164 2 // Also return an error code
165 2 return SCH_MAX_TASKS;
166 2 }
167 1
168 1 // If we're here, there is a space in the task array
169 1 SCH_tasks_G[Index].pTask = pFunction;
170 1
171 1 SCH_tasks_G[Index].Delay = DELAY;
172 1 SCH_tasks_G[Index].Period = PERIOD;
173 1
174 1 SCH_tasks_G[Index].RunMe = 0;
175 1
176 1 return Index; // return position of task (to allow later deletion)
177 1 }
C51 COMPILER V8.01 SCH51 07/13/2008 18:02:06 PAGE 4
178
179 /*------------------------------------------------------------------*-
180
181 SCH_Delete_Task()
182
183 Removes a task from the scheduler. Note that this does
184 *not* delete the associated function from memory:
185 it simply means that it is no longer called by the scheduler.
186
187 TASK_INDEX - The task index. Provided by SCH_Add_Task().
188
189 RETURN VALUE: RETURN_ERROR or RETURN_NORMAL
190
191 -*------------------------------------------------------------------*/
192 bit SCH_Delete_Task(const tByte TASK_INDEX)
193 {
194 1 bit Return_code;
195 1
196 1 if (SCH_tasks_G[TASK_INDEX].pTask == 0)
197 1 {
198 2 // No task at this location...
199 2 //
200 2 // Set the global error variable
201 2 Error_code_G = ERROR_SCH_CANNOT_DELETE_TASK;
202 2
203 2 // ...also return an error code
204 2 Return_code = RETURN_ERROR;
205 2 }
206 1 else
207 1 {
208 2 Return_code = RETURN_NORMAL;
209 2 }
210 1
211 1 SCH_tasks_G[TASK_INDEX].pTask = 0x0000;
212 1 SCH_tasks_G[TASK_INDEX].Delay = 0;
213 1 SCH_tasks_G[TASK_INDEX].Period = 0;
214 1
215 1 SCH_tasks_G[TASK_INDEX].RunMe = 0;
216 1
217 1 return Return_code; // return status
218 1 }
219
220
221 /*------------------------------------------------------------------*-
222
223 SCH_Report_Status()
224
225 Simple function to display error codes.
226
227 This version displays code on a port with attached LEDs:
228 adapt, if required, to report errors over serial link, etc.
229
230 Errors are only displayed for a limited period
231 (60000 ticks = 1 minute at 1ms tick interval).
232 After this the the error code is reset to 0.
233
234 This code may be easily adapted to display the last
235 error 'for ever': this may be appropriate in your
236 application.
237
238 See Chapter 10 for further information.
239
C51 COMPILER V8.01 SCH51 07/13/2008 18:02:06 PAGE 5
240 -*------------------------------------------------------------------*/
241 void SCH_Report_Status(void)
242 {
243 1 #ifdef SCH_REPORT_ERRORS
244 1 // ONLY APPLIES IF WE ARE REPORTING ERRORS
245 1 // Check for a new error code
246 1 if (Error_code_G != Last_error_code_G)
247 1 {
248 2 // Negative logic on LEDs assumed
249 2 Error_port = 255 - Error_code_G;
250 2
251 2 Last_error_code_G = Error_code_G;
252 2
253 2 if (Error_code_G != 0)
254 2 {
255 3 Error_tick_count_G = 60000;
256 3 }
257 2 else
258 2 {
259 3 Error_tick_count_G = 0;
260 3 }
261 2 }
262 1 else
263 1 {
264 2 if (Error_tick_count_G != 0)
265 2 {
266 3 if (--Error_tick_count_G == 0)
267 3 {
268 4 Error_code_G = 0; // Reset error code
269 4 }
270 3 }
271 2 }
272 1 #endif
273 1 }
274
275
276 /*------------------------------------------------------------------*-
277
278 SCH_Go_To_Sleep()
279
280 This scheduler enters 'idle mode' between clock ticks
281 to save power. The next clock tick will return the processor
282 to the normal operating state.
283
284 Note: a slight performance improvement is possible if this
285 function is implemented as a macro, or if the code here is simply
286 pasted into the 'dispatch' function.
287
288 However, by making this a function call, it becomes easier
289 - during development - to assess the performance of the
290 scheduler, using the 'performance analyser' in the Keil
291 hardware simulator. See Chapter 14 for examples for this.
292
293 *** May wish to disable this if using a watchdog ***
294
295 *** ADAPT AS REQUIRED FOR YOUR HARDWARE ***
296
297 -*------------------------------------------------------------------*/
298 void SCH_Go_To_Sleep()
299 {
300 1 PCON |= 0x01; // Enter idle mode (generic 8051 version)
301 1
C51 COMPILER V8.01 SCH51 07/13/2008 18:02:06 PAGE 6
302 1 // Entering idle mode requires TWO consecutive instructions
303 1 // on 80c515 / 80c505 - to avoid accidental triggering
304 1 //PCON |= 0x01; // Enter idle mode (#1)
305 1 //PCON |= 0x20; // Enter idle mode (#2)
306 1 }
307
308 /*------------------------------------------------------------------*-
309 ---- END OF FILE -------------------------------------------------
310 -*------------------------------------------------------------------*/
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 311 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 11 5
IDATA SIZE = ---- ----
BIT SIZE = ---- 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -