Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of gr-peach-opencv-project by
mbed-rtos/rtos/rtos_idle.c@170:54ff26da7eb6, 2017-07-04 (annotated)
- Committer:
- thedo
- Date:
- Tue Jul 04 06:23:13 2017 +0000
- Revision:
- 170:54ff26da7eb6
- Parent:
- 166:3a9487d57a5c
project opencv 3.1 on GR PEACH board, no use SD card.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thedo | 166:3a9487d57a5c | 1 | /* mbed Microcontroller Library |
thedo | 166:3a9487d57a5c | 2 | * Copyright (c) 2006-2012 ARM Limited |
thedo | 166:3a9487d57a5c | 3 | * |
thedo | 166:3a9487d57a5c | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
thedo | 166:3a9487d57a5c | 5 | * of this software and associated documentation files (the "Software"), to deal |
thedo | 166:3a9487d57a5c | 6 | * in the Software without restriction, including without limitation the rights |
thedo | 166:3a9487d57a5c | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
thedo | 166:3a9487d57a5c | 8 | * copies of the Software, and to permit persons to whom the Software is |
thedo | 166:3a9487d57a5c | 9 | * furnished to do so, subject to the following conditions: |
thedo | 166:3a9487d57a5c | 10 | * |
thedo | 166:3a9487d57a5c | 11 | * The above copyright notice and this permission notice shall be included in |
thedo | 166:3a9487d57a5c | 12 | * all copies or substantial portions of the Software. |
thedo | 166:3a9487d57a5c | 13 | * |
thedo | 166:3a9487d57a5c | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
thedo | 166:3a9487d57a5c | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
thedo | 166:3a9487d57a5c | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
thedo | 166:3a9487d57a5c | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
thedo | 166:3a9487d57a5c | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
thedo | 166:3a9487d57a5c | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
thedo | 166:3a9487d57a5c | 20 | * SOFTWARE. |
thedo | 166:3a9487d57a5c | 21 | */ |
thedo | 166:3a9487d57a5c | 22 | |
thedo | 166:3a9487d57a5c | 23 | #include "rtos/rtos_idle.h" |
thedo | 166:3a9487d57a5c | 24 | |
thedo | 166:3a9487d57a5c | 25 | static void default_idle_hook(void) |
thedo | 166:3a9487d57a5c | 26 | { |
thedo | 166:3a9487d57a5c | 27 | /* Sleep: ideally, we should put the chip to sleep. |
thedo | 166:3a9487d57a5c | 28 | Unfortunately, this usually requires disconnecting the interface chip (debugger). |
thedo | 166:3a9487d57a5c | 29 | This can be done, but it would break the local file system. |
thedo | 166:3a9487d57a5c | 30 | */ |
thedo | 166:3a9487d57a5c | 31 | // sleep(); |
thedo | 166:3a9487d57a5c | 32 | } |
thedo | 166:3a9487d57a5c | 33 | static void (*idle_hook_fptr)(void) = &default_idle_hook; |
thedo | 166:3a9487d57a5c | 34 | |
thedo | 166:3a9487d57a5c | 35 | void rtos_attach_idle_hook(void (*fptr)(void)) |
thedo | 166:3a9487d57a5c | 36 | { |
thedo | 166:3a9487d57a5c | 37 | //Attach the specified idle hook, or the default idle hook in case of a NULL pointer |
thedo | 166:3a9487d57a5c | 38 | if (fptr != NULL) { |
thedo | 166:3a9487d57a5c | 39 | idle_hook_fptr = fptr; |
thedo | 166:3a9487d57a5c | 40 | } else { |
thedo | 166:3a9487d57a5c | 41 | idle_hook_fptr = default_idle_hook; |
thedo | 166:3a9487d57a5c | 42 | } |
thedo | 166:3a9487d57a5c | 43 | } |
thedo | 166:3a9487d57a5c | 44 | |
thedo | 166:3a9487d57a5c | 45 | void rtos_idle_loop(void) |
thedo | 166:3a9487d57a5c | 46 | { |
thedo | 166:3a9487d57a5c | 47 | //Continuously call the idle hook function pointer |
thedo | 166:3a9487d57a5c | 48 | while (1) { |
thedo | 166:3a9487d57a5c | 49 | idle_hook_fptr(); |
thedo | 166:3a9487d57a5c | 50 | } |
thedo | 166:3a9487d57a5c | 51 | } |