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