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.
crypto-aes
Damien George 7 years ago
parent 77e37ff98b
commit 0455755296

@ -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();

@ -69,6 +69,7 @@
#include "updater.h"
#include "moduos.h"
#include "antenna.h"
#include "task.h"
/******************************************************************************
DECLARE PRIVATE CONSTANTS
@ -277,15 +278,12 @@ STATIC void mptask_pre_init (void) {
//CRYPTOHASH_Init();
#ifdef DEBUG
ASSERT (OSI_OK == osi_TaskCreate(TASK_Servers,
(const signed char *)"Servers",
SERVERS_STACK_SIZE, NULL, SERVERS_PRIORITY, &svTaskHandle));
#else
ASSERT (OSI_OK == osi_TaskCreate(TASK_Servers,
(const signed char *)"Servers",
SERVERS_STACK_SIZE, NULL, SERVERS_PRIORITY, NULL));
#ifndef DEBUG
OsiTaskHandle svTaskHandle;
#endif
svTaskHandle = xTaskCreateStatic(TASK_Servers, "Servers",
SERVERS_STACK_LEN, NULL, SERVERS_PRIORITY, svTaskStack, &svTaskTCB);
ASSERT(svTaskHandle != NULL);
}
STATIC void mptask_init_sflash_filesystem (void) {

@ -31,7 +31,13 @@
DEFINE CONSTANTS
******************************************************************************/
#define MICROPY_TASK_PRIORITY (2)
#define MICROPY_TASK_STACK_SIZE ((6 * 1024) + 512)
#define MICROPY_TASK_STACK_SIZE ((6 * 1024) + 512) // in bytes
#define MICROPY_TASK_STACK_LEN (MICROPY_TASK_STACK_SIZE / sizeof(StackType_t))
/******************************************************************************
EXPORTED DATA
******************************************************************************/
extern StackType_t mpTaskStack[];
/******************************************************************************
DECLARE PUBLIC FUNCTIONS

@ -67,6 +67,8 @@ static volatile bool sleep_sockets = false;
/******************************************************************************
DECLARE PUBLIC DATA
******************************************************************************/
StaticTask_t svTaskTCB;
StackType_t svTaskStack[SERVERS_STACK_LEN] __attribute__((aligned (8)));
char servers_user[SERVERS_USER_PASS_LEN_MAX + 1];
char servers_pass[SERVERS_USER_PASS_LEN_MAX + 1];

@ -31,7 +31,8 @@
DEFINE CONSTANTS
******************************************************************************/
#define SERVERS_PRIORITY 2
#define SERVERS_STACK_SIZE 1024
#define SERVERS_STACK_SIZE 1024 // in bytes
#define SERVERS_STACK_LEN (SERVERS_STACK_SIZE / sizeof(StackType_t))
#define SERVERS_SSID_LEN_MAX 16
#define SERVERS_KEY_LEN_MAX 16
@ -52,6 +53,8 @@
/******************************************************************************
EXPORTED DATA
******************************************************************************/
extern StaticTask_t svTaskTCB;
extern StackType_t svTaskStack[];
extern char servers_user[];
extern char servers_pass[];

Loading…
Cancel
Save