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