File tree Expand file tree Collapse file tree 3 files changed +12
-0
lines changed
features/nanostack/FEATURE_NANOSTACK/mbed-mesh-api Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ An example of the configuration file:
34
34
| Parameter name | Value | Description |
35
35
| --------------- | ------------- | ----------- |
36
36
| heap-size | number [ 0-0xfffe] | Nanostack's internal heap size |
37
+ | use-malloc-for-heap | ` false ` or ` true ` | Use ` malloc() ` for reserving the internal heap. Default: ` false ` |
37
38
38
39
### Thread related configuration parameters
39
40
Original file line number Diff line number Diff line change 2
2
"name" : " mbed-mesh-api" ,
3
3
"config" : {
4
4
"heap-size" : 32500 ,
5
+ "use-malloc-for-heap" : false ,
5
6
"6lowpan-nd-channel-mask" : " (1<<12)" ,
6
7
"6lowpan-nd-channel-page" : 0 ,
7
8
"6lowpan-nd-channel" : 12 ,
Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
17
+ #include <stdlib.h>
17
18
#include "eventOS_scheduler.h"
18
19
#include "eventOS_event.h"
19
20
#include "net_interface.h"
22
23
#include "platform/arm_hal_timer.h"
23
24
#include "ns_hal_init.h"
24
25
#include "include/mesh_system.h"
26
+ #include "mbed_assert.h"
25
27
// For tracing we need to define flag, have include and define group
26
28
#define HAVE_DEBUG 1
27
29
#include "ns_trace.h"
28
30
#define TRACE_GROUP "m6-mesh-system"
29
31
30
32
/* Heap for NanoStack */
33
+ #if !MBED_CONF_MBED_MESH_API_USE_MALLOC_FOR_HEAP
31
34
static uint8_t app_stack_heap [MBED_CONF_MBED_MESH_API_HEAP_SIZE + 1 ];
35
+ #else
36
+ static uint8_t * app_stack_heap ;
37
+ #endif
32
38
static bool mesh_initialized = false;
33
39
34
40
/*
@@ -55,6 +61,10 @@ static void mesh_system_heap_error_handler(heap_fail_t event)
55
61
void mesh_system_init (void )
56
62
{
57
63
if (mesh_initialized == false) {
64
+ #if MBED_CONF_MBED_MESH_API_USE_MALLOC_FOR_HEAP
65
+ app_stack_heap = malloc (MBED_CONF_MBED_MESH_API_HEAP_SIZE + 1 );
66
+ MBED_ASSERT (app_stack_heap );
67
+ #endif
58
68
ns_hal_init (app_stack_heap , MBED_CONF_MBED_MESH_API_HEAP_SIZE ,
59
69
mesh_system_heap_error_handler , NULL );
60
70
eventOS_scheduler_mutex_wait ();
You can’t perform that action at this time.
0 commit comments