File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -157,19 +157,16 @@ void mp_thread_finish(void) {
157157}
158158
159159void mp_thread_mutex_init (mp_thread_mutex_t * mutex ) {
160- * mutex = xSemaphoreCreateMutex ();
161- if (* mutex == NULL ) {
162- // error!
163- }
160+ mutex -> handle = xSemaphoreCreateMutexStatic (& mutex -> buffer );
164161}
165162
166163int mp_thread_mutex_lock (mp_thread_mutex_t * mutex , int wait ) {
167- int ret = xSemaphoreTake (* mutex , wait ? portMAX_DELAY : 0 );
164+ int ret = xSemaphoreTake (mutex -> handle , wait ? portMAX_DELAY : 0 );
168165 return ret == pdTRUE ;
169166}
170167
171168void mp_thread_mutex_unlock (mp_thread_mutex_t * mutex ) {
172- xSemaphoreGive (* mutex );
169+ xSemaphoreGive (mutex -> handle );
173170 // TODO check return value
174171}
175172
Original file line number Diff line number Diff line change 2828
2929#include "FreeRTOS.h"
3030
31- typedef SemaphoreHandle_t mp_thread_mutex_t ;
31+ typedef struct _mp_thread_mutex_t {
32+ SemaphoreHandle_t handle ;
33+ StaticSemaphore_t buffer ;
34+ } mp_thread_mutex_t ;
3235
3336void mp_thread_init (void );
3437void mp_thread_gc_others (void );
You can’t perform that action at this time.
0 commit comments