For Cortex-M3,Cortex-M0, Multitask scheduler library. Arduino due compatible
Dependents: scheduler-demo-cq-lpc11u35 scheduler-demo scheduler-demo-cq-lpc11u35 mbed-scli-test
Scheduler.h
00001 /* 00002 * Copyright (C) 2012-2013 audin 00003 * This program is licensed under the Apache License, Version 2.0. 00004 * 2013/08: Modify for mbed for LPC1114FN28 00005 * Modified 2012/11: v02: 00006 * Added external definition of stack size and task number. 00007 * Modified 2012/10: v01: 00008 * For working on Cortex-M0 and M3. 00009 * Defined static tcb option for the cpu that has quite a less SRAM < 8kbyte. 00010 * 00011 * Original file is arduino-1.5\hardware\arduino\sam\libraries\Scheduler 00012 */ 00013 00014 /* 00015 * Copyright (C) 2012 The Android Open Source Project 00016 * 00017 * Licensed under the Apache License, Version 2.0 (the "License"); 00018 * you may not use this file except in compliance with the License. 00019 * You may obtain a copy of the License at 00020 * 00021 * http://www.apache.org/licenses/LICENSE-2.0 00022 * 00023 * Unless required by applicable law or agreed to in writing, software 00024 * distributed under the License is distributed on an "AS IS" BASIS, 00025 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00026 * See the License for the specific language governing permissions and 00027 * limitations under the License. 00028 */ 00029 00030 #ifndef _SCHEDULDER_H_ 00031 #define _SCHEDULDER_H_ 00032 00033 /* 00034 * If you explicitly specify stack size, activate below, 00035 * or used "Default settings" 00036 */ 00037 //#define SCHEDULER_TASK_NUM_MAX 4 00038 //#define SCHEDULER_TASK_STACK_SIZE_EACH 200 00039 00040 /* 00041 * Otherwise you can add compile option CFLAGS like this, 00042 -DSCHEDULER_TASK_NUM_MAX=4 00043 -DSCHEDULER_TASK_STACK_SIZE_EACH=200 00044 */ 00045 00046 /* Default settings */ 00047 /******************************************************************************************/ 00048 #ifndef SCHEDULER_TASK_NUM_MAX 00049 #define COOP_TASK_NUM_MAX 4 /* Define max task number( include main loop ) */ 00050 #else 00051 #define COOP_TASK_NUM_MAX (SCHEDULER_TASK_NUM_MAX) 00052 #endif 00053 00054 #ifndef SCHEDULER_TASK_STACK_SIZE_EACH 00055 #define MIN_STACK_SIZE (200) /* Minimum stack size per task, exclude main loop */ 00056 #else 00057 #define MIN_STACK_SIZE (SCHEDULER_TASK_STACK_SIZE_EACH) 00058 #endif 00059 /* Thanks Ms.HI */ 00060 /******************************************************************************************/ 00061 00062 #include <stdint.h> 00063 #ifdef __cplusplus 00064 extern "C" { 00065 #endif 00066 typedef void (*SchedulerTask)(void); 00067 typedef void (*SchedulerParametricTask)(void *); 00068 00069 void scheduler_init( void ); 00070 void scheduler_startLoop( SchedulerTask task ); 00071 void scheduler_start( SchedulerTask task ); 00072 #ifdef MBED_H 00073 void taskWait(uint32_t ms); 00074 #else 00075 void wait(uint32_t ms); 00076 #endif 00077 void yield(); 00078 #ifdef __cplusplus 00079 } 00080 #endif 00081 00082 00083 #if __cplusplus 00084 class SchedulerClass { 00085 public: 00086 SchedulerClass(); 00087 static void startLoop(SchedulerTask task, uint32_t stackSize = MIN_STACK_SIZE); 00088 static void start(SchedulerTask task, uint32_t stackSize = MIN_STACK_SIZE); 00089 static void start(SchedulerParametricTask task, void *data, uint32_t stackSize = MIN_STACK_SIZE); 00090 00091 #ifdef MBED_H 00092 static void taskWait(uint32_t ms); 00093 #else 00094 static void wait(uint32_t ms) { ::wait(ms); }; 00095 #endif 00096 static void yield() { ::yield(); }; 00097 }; 00098 00099 extern SchedulerClass Scheduler; 00100 00101 #endif 00102 00103 #endif /* _SCHEDULDER_H_ */ 00104
Generated on Fri Jul 15 2022 11:49:31 by 1.7.2