@@ -38,7 +38,6 @@ mbed_rtos_storage_thread_t _main_obj __attribute__((section(".bss.os.thread.cb")
38
38
39
39
osMutexId_t singleton_mutex_id ;
40
40
mbed_rtos_storage_mutex_t singleton_mutex_obj ;
41
- osMutexAttr_t singleton_mutex_attr ;
42
41
43
42
void mbed_rtos_init ()
44
43
{
@@ -47,11 +46,6 @@ void mbed_rtos_init()
47
46
48
47
MBED_NORETURN void mbed_rtos_start ()
49
48
{
50
- singleton_mutex_attr .name = "singleton_mutex" ;
51
- singleton_mutex_attr .attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust ;
52
- singleton_mutex_attr .cb_size = sizeof (singleton_mutex_obj );
53
- singleton_mutex_attr .cb_mem = & singleton_mutex_obj ;
54
-
55
49
_main_thread_attr .stack_mem = _main_stack ;
56
50
_main_thread_attr .stack_size = sizeof (_main_stack );
57
51
_main_thread_attr .cb_size = sizeof (_main_obj );
@@ -68,7 +62,6 @@ MBED_NORETURN void mbed_rtos_start()
68
62
tfm_ns_lock_init ();
69
63
#endif // defined(TARGET_TFM) && defined(COMPONENT_NSPE)
70
64
71
- singleton_mutex_id = osMutexNew (& singleton_mutex_attr );
72
65
osThreadId_t result = osThreadNew ((osThreadFunc_t )mbed_start , NULL , & _main_thread_attr );
73
66
if ((void * )result == NULL ) {
74
67
MBED_ERROR1 (MBED_MAKE_ERROR (MBED_MODULE_PLATFORM , MBED_ERROR_CODE_INITIALIZATION_FAILED ), "Pre main thread not created" , & _main_thread_attr );
@@ -77,3 +70,14 @@ MBED_NORETURN void mbed_rtos_start()
77
70
osKernelStart ();
78
71
MBED_ERROR (MBED_MAKE_ERROR (MBED_MODULE_PLATFORM , MBED_ERROR_CODE_INITIALIZATION_FAILED ), "Failed to start RTOS" );
79
72
}
73
+
74
+ void mbed_rtos_init_singleton_mutex (void )
75
+ {
76
+ const osMutexAttr_t singleton_mutex_attr = {
77
+ .name = "singleton_mutex" ,
78
+ .attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust ,
79
+ .cb_size = sizeof (singleton_mutex_obj ),
80
+ .cb_mem = & singleton_mutex_obj
81
+ };
82
+ singleton_mutex_id = osMutexNew (& singleton_mutex_attr );
83
+ }
0 commit comments