diff --git a/cc3200/mpthreadport.c b/cc3200/mpthreadport.c index 125b59666c..5fe14a6ed8 100644 --- a/cc3200/mpthreadport.c +++ b/cc3200/mpthreadport.c @@ -157,19 +157,16 @@ void mp_thread_finish(void) { } void mp_thread_mutex_init(mp_thread_mutex_t *mutex) { - *mutex = xSemaphoreCreateMutex(); - if (*mutex == NULL) { - // error! - } + mutex->handle = xSemaphoreCreateMutexStatic(&mutex->buffer); } int mp_thread_mutex_lock(mp_thread_mutex_t *mutex, int wait) { - int ret = xSemaphoreTake(*mutex, wait ? portMAX_DELAY : 0); + int ret = xSemaphoreTake(mutex->handle, wait ? portMAX_DELAY : 0); return ret == pdTRUE; } void mp_thread_mutex_unlock(mp_thread_mutex_t *mutex) { - xSemaphoreGive(*mutex); + xSemaphoreGive(mutex->handle); // TODO check return value } diff --git a/cc3200/mpthreadport.h b/cc3200/mpthreadport.h index 83995915eb..299802a6f3 100644 --- a/cc3200/mpthreadport.h +++ b/cc3200/mpthreadport.h @@ -28,7 +28,10 @@ #include "FreeRTOS.h" -typedef SemaphoreHandle_t mp_thread_mutex_t; +typedef struct _mp_thread_mutex_t { + SemaphoreHandle_t handle; + StaticSemaphore_t buffer; +} mp_thread_mutex_t; void mp_thread_init(void); void mp_thread_gc_others(void);