diff options
author | Damien George <damien.p.george@gmail.com> | 2016-05-31 17:27:21 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-06-28 11:28:52 +0100 |
commit | 0455755296b27440e68cad1ca43c342d9a452f88 (patch) | |
tree | aa8451960fc94ac3b3bf07ad636b00d97c3ca15a /cc3200/main.c | |
parent | 77e37ff98bec1ccf6af6edf3efcad26b54da0c47 (diff) | |
download | micropython-0455755296b27440e68cad1ca43c342d9a452f88.tar.gz micropython-0455755296b27440e68cad1ca43c342d9a452f88.zip |
cc3200: Use xTaskCreateStatic instead of osi_TaskCreate.
This allows to statically allocate the TCB (thread control block) and
thread stack in the BSS segment, reducing the need for dynamic memory
allocation.
Diffstat (limited to 'cc3200/main.c')
-rw-r--r-- | cc3200/main.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/cc3200/main.c b/cc3200/main.c index 2aed70f76b..da6c5211b2 100644 --- a/cc3200/main.c +++ b/cc3200/main.c @@ -36,6 +36,7 @@ #include "debug.h" #include "antenna.h" #include "mperror.h" +#include "task.h" /****************************************************************************** DECLARE PRIVATE CONSTANTS @@ -59,6 +60,10 @@ OsiTaskHandle mpTaskHandle; // This is the FreeRTOS heap, defined here so we can put it in a special segment uint8_t ucHeap[ configTOTAL_HEAP_SIZE ] __attribute__ ((section (".rtos_heap"))) __attribute__((aligned (8))); +// This is the static memory (TCB and stack) for the main MicroPython task +StaticTask_t mpTaskTCB; +StackType_t mpTaskStack[MICROPY_TASK_STACK_LEN] __attribute__((aligned (8))); + /****************************************************************************** DEFINE PUBLIC FUNCTIONS ******************************************************************************/ @@ -77,15 +82,12 @@ int main (void) { // Init the watchdog pybwdt_init0(); -#ifdef DEBUG - ASSERT (OSI_OK == osi_TaskCreate(TASK_Micropython, - (const signed char *)"MicroPy", - MICROPY_TASK_STACK_SIZE, NULL, MICROPY_TASK_PRIORITY, &mpTaskHandle)); -#else - ASSERT (OSI_OK == osi_TaskCreate(TASK_Micropython, - (const signed char *)"MicroPy", - MICROPY_TASK_STACK_SIZE, NULL, MICROPY_TASK_PRIORITY, NULL)); +#ifndef DEBUG + OsiTaskHandle mpTaskHandle; #endif + mpTaskHandle = xTaskCreateStatic(TASK_Micropython, "MicroPy", + MICROPY_TASK_STACK_LEN, NULL, MICROPY_TASK_PRIORITY, mpTaskStack, &mpTaskTCB); + ASSERT(mpTaskHandle != NULL); osi_start(); |