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