@@ -41,16 +41,12 @@ typedef enum LedState {
4141 LED_ON
4242} LedState ;
4343
44- // Memory containers for sync primitives (static allocation)
44+ // Pointers to synchronization primitives
4545#if STK_EXAMPLE_USE_PIPE
46- static stk_pipe_mem_t g_PipeMem ;
4746static stk_pipe_t * g_CtrlSignalPipe ;
4847#else
49- static stk_event_mem_t g_EvRdyMem , g_EvOnMem , g_EvOffMem ;
5048static stk_event_t * g_EventReady , * g_EventSwitchOn , * g_EventSwitchOff ;
5149#endif
52-
53- static stk_mutex_mem_t g_HwMtxMem ;
5450static stk_mutex_t * g_HwMutex ;
5551
5652// ─────────────────────────────────────────────────────────────────────────────
@@ -65,10 +61,8 @@ static void LedTask_Run(void *arg)
6561 while (true)
6662 {
6763 #if STK_EXAMPLE_USE_PIPE
68- size_t pipe_val ;
69- if (!stk_pipe_read (g_CtrlSignalPipe , & pipe_val , 100 ))
64+ if (!stk_pipe_read (g_CtrlSignalPipe , & task_id , 100 ))
7065 continue ;
71- task_id = (LedState )pipe_val ;
7266 #else
7367 switch (task_id )
7468 {
@@ -121,7 +115,8 @@ static void CtrlTask_Run(void *arg)
121115 task_start = stk_time_now_ms ();
122116
123117 #if STK_EXAMPLE_USE_PIPE
124- stk_pipe_write (g_CtrlSignalPipe , led_sw ? LED_ON : LED_OFF , STK_WAIT_INFINITE );
118+ LedState new_state = led_sw ? LED_ON : LED_OFF ;
119+ stk_pipe_write (g_CtrlSignalPipe , & new_state , STK_WAIT_INFINITE );
125120 #else
126121 if (led_sw )
127122 stk_event_set (g_EventSwitchOn );
@@ -142,11 +137,21 @@ static void InitLeds()
142137
143138static void InitSync ()
144139{
145- // init Mutex
140+ // Memory containers for sync primitives (static allocation)
141+ static stk_mutex_mem_t g_HwMtxMem ;
142+ #if STK_EXAMPLE_USE_PIPE
143+ static stk_pipe_mem_t g_PipeMem ;
144+ static LedState s_PipeBuf [16 ] __stk_c_aligned ;
145+ #else
146+ static stk_event_mem_t g_EvRdyMem , g_EvOnMem , g_EvOffMem ;
147+ #endif
148+
146149 g_HwMutex = stk_mutex_create (& g_HwMtxMem , sizeof (g_HwMtxMem ));
147150
148151#if STK_EXAMPLE_USE_PIPE
149- g_CtrlSignalPipe = stk_pipe_create (& g_PipeMem , sizeof (g_PipeMem ));
152+ g_CtrlSignalPipe = stk_pipe_create (& g_PipeMem , sizeof (g_PipeMem ),
153+ s_PipeBuf , sizeof (s_PipeBuf ),
154+ 16 , sizeof (LedState ));
150155#else
151156 g_EventReady = stk_event_create (& g_EvRdyMem , sizeof (g_EvRdyMem ), false);
152157 g_EventSwitchOn = stk_event_create (& g_EvOnMem , sizeof (g_EvOnMem ), false);
@@ -156,11 +161,11 @@ static void InitSync()
156161
157162#if STK_EXAMPLE_DUALCORE
158163
159- static size_t g_StackCore0_T1 [TASK_STACK_SIZE ] __stk_c_stack_attr ;
164+ static size_t g_StackCore0_T1 [TASK_STACK_SIZE ] __stk_c_stack ;
160165#if !STK_EXAMPLE_USE_PIPE
161- static size_t g_StackCore0_T2 [TASK_STACK_SIZE ] __stk_c_stack_attr ;
166+ static size_t g_StackCore0_T2 [TASK_STACK_SIZE ] __stk_c_stack ;
162167#endif
163- static size_t g_StackCore1_T1 [TASK_STACK_SIZE ] __stk_c_stack_attr ;
168+ static size_t g_StackCore1_T1 [TASK_STACK_SIZE ] __stk_c_stack ;
164169
165170void StartCore0 ()
166171{
0 commit comments