Skip to content

Commit 026c168

Browse files
wiseconnect: Use static allocation for threads
Allocate stack memory and control blocks statically instead of dynamically for bus_thread and event_thread. Signed-off-by: Arunmani Alagarsamy <arunmani.a@silabs.com>
1 parent 9d32354 commit 026c168

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

wiseconnect/components/device/silabs/si91x/wireless/inc/sl_rsi_utility.h

+10
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@
6161
#ifndef SL_SI91X_EVENT_HANDLER_STACK_SIZE
6262
#define SL_SI91X_EVENT_HANDLER_STACK_SIZE 1536
6363
#endif
64+
65+
/**
66+
* Stack size of the bus thread.
67+
* Override by defining SL_SI91X_BUS_THREAD_STACK_SIZE in your project
68+
* or add -DSL_SI91X_BUS_THREAD_STACK_SIZE=<new value> to compiler options.
69+
*/
70+
#ifndef SL_SI91X_BUS_THREAD_STACK_SIZE
71+
#define SL_SI91X_BUS_THREAD_STACK_SIZE 1636
72+
#endif
73+
6474
typedef bool (*sli_si91x_wifi_buffer_comparator)(const sl_wifi_buffer_t *buffer, const void *userdata);
6575

6676
typedef struct {

wiseconnect/components/device/silabs/si91x/wireless/src/sl_rsi_utility.c

+14-7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "sl_wifi_types.h"
3838
#include "sl_rsi_utility.h"
3939
#include "cmsis_os2.h" // CMSIS RTOS2
40+
#include "cmsis_types.h"
4041
#include "sl_si91x_types.h"
4142
#include "sl_si91x_core_utilities.h"
4243
#ifdef SLI_SI91X_OFFLOAD_NETWORK_STACK
@@ -90,6 +91,12 @@
9091
/// Task register ID to save firmware status
9192
#define SLI_FW_STATUS_STORAGE_INVALID_INDEX 0xFF // Invalid index for firmware status storage
9293

94+
static uint8_t __aligned(8) bus_thread_stack[SL_SI91X_BUS_THREAD_STACK_SIZE];
95+
static uint8_t __aligned(8) event_handler_stack[SL_SI91X_EVENT_HANDLER_STACK_SIZE];
96+
97+
static struct cmsis_rtos_thread_cb bus_thread_cb;
98+
static struct cmsis_rtos_thread_cb event_thread_cb;
99+
93100
/******************************************************
94101
* Local Type Declarations
95102
******************************************************/
@@ -1055,10 +1062,10 @@ sl_status_t sl_si91x_platform_init(void)
10551062

10561063
.name = "si91x_bus",
10571064
.priority = osPriorityRealtime,
1058-
.stack_mem = 0,
1059-
.stack_size = 1636,
1060-
.cb_mem = 0,
1061-
.cb_size = 0,
1065+
.stack_mem = bus_thread_stack,
1066+
.stack_size = SL_SI91X_BUS_THREAD_STACK_SIZE,
1067+
.cb_mem = &bus_thread_cb,
1068+
.cb_size = sizeof(bus_thread_cb),
10621069
.attr_bits = 0u,
10631070
.tz_module = 0u,
10641071
};
@@ -1070,10 +1077,10 @@ sl_status_t sl_si91x_platform_init(void)
10701077
const osThreadAttr_t attr = {
10711078
.name = "si91x_event",
10721079
.priority = osPriorityRealtime1,
1073-
.stack_mem = 0,
1080+
.stack_mem = event_handler_stack,
10741081
.stack_size = SL_SI91X_EVENT_HANDLER_STACK_SIZE,
1075-
.cb_mem = 0,
1076-
.cb_size = 0,
1082+
.cb_mem = &event_thread_cb,
1083+
.cb_size = sizeof(event_thread_cb),
10771084
.attr_bits = 0u,
10781085
.tz_module = 0u,
10791086
};

0 commit comments

Comments
 (0)