![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Final 350 project
Dependencies: uzair Camera_LS_Y201 F7_Ethernet LCD_DISCO_F746NG NetworkAPI SDFileSystem mbed
mbed-rtos/rtos/rtos_idle.c@0:791a779d6220, 2017-07-31 (annotated)
- Committer:
- shoaib_ahmed
- Date:
- Mon Jul 31 09:16:35 2017 +0000
- Revision:
- 0:791a779d6220
final project;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shoaib_ahmed | 0:791a779d6220 | 1 | /* mbed Microcontroller Library |
shoaib_ahmed | 0:791a779d6220 | 2 | * Copyright (c) 2006-2012 ARM Limited |
shoaib_ahmed | 0:791a779d6220 | 3 | * |
shoaib_ahmed | 0:791a779d6220 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
shoaib_ahmed | 0:791a779d6220 | 5 | * of this software and associated documentation files (the "Software"), to deal |
shoaib_ahmed | 0:791a779d6220 | 6 | * in the Software without restriction, including without limitation the rights |
shoaib_ahmed | 0:791a779d6220 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
shoaib_ahmed | 0:791a779d6220 | 8 | * copies of the Software, and to permit persons to whom the Software is |
shoaib_ahmed | 0:791a779d6220 | 9 | * furnished to do so, subject to the following conditions: |
shoaib_ahmed | 0:791a779d6220 | 10 | * |
shoaib_ahmed | 0:791a779d6220 | 11 | * The above copyright notice and this permission notice shall be included in |
shoaib_ahmed | 0:791a779d6220 | 12 | * all copies or substantial portions of the Software. |
shoaib_ahmed | 0:791a779d6220 | 13 | * |
shoaib_ahmed | 0:791a779d6220 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
shoaib_ahmed | 0:791a779d6220 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
shoaib_ahmed | 0:791a779d6220 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
shoaib_ahmed | 0:791a779d6220 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
shoaib_ahmed | 0:791a779d6220 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
shoaib_ahmed | 0:791a779d6220 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
shoaib_ahmed | 0:791a779d6220 | 20 | * SOFTWARE. |
shoaib_ahmed | 0:791a779d6220 | 21 | */ |
shoaib_ahmed | 0:791a779d6220 | 22 | |
shoaib_ahmed | 0:791a779d6220 | 23 | #include "rtos_idle.h" |
shoaib_ahmed | 0:791a779d6220 | 24 | |
shoaib_ahmed | 0:791a779d6220 | 25 | static void default_idle_hook(void) |
shoaib_ahmed | 0:791a779d6220 | 26 | { |
shoaib_ahmed | 0:791a779d6220 | 27 | /* Sleep: ideally, we should put the chip to sleep. |
shoaib_ahmed | 0:791a779d6220 | 28 | Unfortunately, this usually requires disconnecting the interface chip (debugger). |
shoaib_ahmed | 0:791a779d6220 | 29 | This can be done, but it would break the local file system. |
shoaib_ahmed | 0:791a779d6220 | 30 | */ |
shoaib_ahmed | 0:791a779d6220 | 31 | // sleep(); |
shoaib_ahmed | 0:791a779d6220 | 32 | } |
shoaib_ahmed | 0:791a779d6220 | 33 | static void (*idle_hook_fptr)(void) = &default_idle_hook; |
shoaib_ahmed | 0:791a779d6220 | 34 | |
shoaib_ahmed | 0:791a779d6220 | 35 | void rtos_attach_idle_hook(void (*fptr)(void)) |
shoaib_ahmed | 0:791a779d6220 | 36 | { |
shoaib_ahmed | 0:791a779d6220 | 37 | //Attach the specified idle hook, or the default idle hook in case of a NULL pointer |
shoaib_ahmed | 0:791a779d6220 | 38 | if (fptr != NULL) { |
shoaib_ahmed | 0:791a779d6220 | 39 | idle_hook_fptr = fptr; |
shoaib_ahmed | 0:791a779d6220 | 40 | } else { |
shoaib_ahmed | 0:791a779d6220 | 41 | idle_hook_fptr = default_idle_hook; |
shoaib_ahmed | 0:791a779d6220 | 42 | } |
shoaib_ahmed | 0:791a779d6220 | 43 | } |
shoaib_ahmed | 0:791a779d6220 | 44 | |
shoaib_ahmed | 0:791a779d6220 | 45 | void rtos_idle_loop(void) |
shoaib_ahmed | 0:791a779d6220 | 46 | { |
shoaib_ahmed | 0:791a779d6220 | 47 | //Continuously call the idle hook function pointer |
shoaib_ahmed | 0:791a779d6220 | 48 | while (1) { |
shoaib_ahmed | 0:791a779d6220 | 49 | idle_hook_fptr(); |
shoaib_ahmed | 0:791a779d6220 | 50 | } |
shoaib_ahmed | 0:791a779d6220 | 51 | } |