OS2

Dependents:   GYRO_MPU6050 Bluetooth_Powered_Multimeter_Using_STM32F429_and_RTOS fyp

Committer:
guilhemMBED
Date:
Mon Feb 03 13:41:14 2020 +0000
Revision:
0:a7c449cd2d5a
previous version;

Who changed what in which revision?

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