23 #if defined(TEENSYDUINO) 24 #undef ARDUINO_ARCH_AVR 25 #define TEENSY_ARCH_ARM 26 #if defined(__MK20DX256__) 27 #define RAMEND 0x20008000 28 #elif defined(__MK64FX512__) 29 #define RAMEND 0x20020000 30 #elif defined(__MK66FX1M0__) 31 #define RAMEND 0x20030000 34 #elif defined(ARDUINO_ARCH_AVR) 35 extern int __heap_start, *__brkval;
36 extern char* __malloc_heap_end;
37 extern size_t __malloc_margin;
39 #elif defined(ARDUINO_ARCH_SAM) 41 #define RAMEND 0x20088000 43 #elif defined(ARDUINO_ARCH_SAMD) 45 #define RAMEND 0x20008000 82 stackSize +=
sizeof(
task_t);
85 size_t frame = RAMEND - (size_t) &frame;
92 #if defined(ARDUINO_ARCH_AVR) 94 int HEAPEND = (__brkval == 0 ? (int) &__heap_start : (
int) __brkval);
95 int STACKSTART = ((int) stack) - stackSize;
96 HEAPEND += __malloc_margin;
97 if (STACKSTART < HEAPEND)
return (
false);
100 __malloc_heap_end = (
char*) STACKSTART;
103 if (
s_top + stackSize > STACK_MAX)
return (
false);
110 memset(stack - stackSize,
MAGIC, stackSize -
sizeof(
task_t));
113 init(taskSetup, taskLoop, stack - stackSize);
131 while (*sp++ ==
MAGIC) bytes++;
147 if (setup != NULL)
setup();
SchedulerClass::func_t task_t
static task_t * s_running
const uint8_t * stack
Task stack top.
static bool begin(size_t stackSize)
task_t * prev
Previous task.
static void init(func_t setup, func_t loop, const uint8_t *stack)
jmp_buf context
Task context.
static bool start(func_t taskSetup, func_t taskLoop, size_t stackSize=DEFAULT_STACK_SIZE)