aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George2016-05-31 17:28:53 +0100
committerDamien George2016-06-28 11:28:52 +0100
commit27241293c4f5ae26927f70fe03cdd86fa1819aa1 (patch)
treea7a679ceed0b45936151f41af34d071bfddb2982
parent0455755296b27440e68cad1ca43c342d9a452f88 (diff)
cc3200/mpthreadport: Make mutex statically allocated.
Reduced the need for the FreeRTOS heap to allocate the mutex.
-rw-r--r--cc3200/mpthreadport.c9
-rw-r--r--cc3200/mpthreadport.h5
2 files changed, 7 insertions, 7 deletions
diff --git a/cc3200/mpthreadport.c b/cc3200/mpthreadport.c
index 125b59666..5fe14a6ed 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 83995915e..299802a6f 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);