diff --git a/include/uxr/client/profile/multithread/multithread.h b/include/uxr/client/profile/multithread/multithread.h index 189b4a7df..11a21a882 100644 --- a/include/uxr/client/profile/multithread/multithread.h +++ b/include/uxr/client/profile/multithread/multithread.h @@ -32,6 +32,8 @@ struct uxrSession; #elif defined(PLATFORM_NAME_FREERTOS) #include "FreeRTOS.h" #include "semphr.h" +#elif defined(PLATFORM_NAME_RPIPICO) +#include "pico/mutex.h" #elif defined(UCLIENT_PLATFORM_ZEPHYR) #elif defined(UCLIENT_PLATFORM_POSIX) #include @@ -45,6 +47,8 @@ typedef struct uxrMutex #elif defined(PLATFORM_NAME_FREERTOS) SemaphoreHandle_t impl; StaticSemaphore_t xMutexBuffer; +#elif defined(PLATFORM_NAME_RPIPICO) + recursive_mutex_t impl; #elif defined(UCLIENT_PLATFORM_ZEPHYR) struct k_mutex impl; #elif defined(UCLIENT_PLATFORM_POSIX) diff --git a/src/c/profile/multithread/multithread.c b/src/c/profile/multithread/multithread.c index 1a8b1d1c0..ffb4d7ae8 100644 --- a/src/c/profile/multithread/multithread.c +++ b/src/c/profile/multithread/multithread.c @@ -12,6 +12,8 @@ void uxr_init_lock( { #if defined(PLATFORM_NAME_FREERTOS) mutex->impl = xSemaphoreCreateRecursiveMutexStatic( &mutex->xMutexBuffer ); +#elif defined(PLATFORM_NAME_RPIPICO) + recursive_mutex_init(&mutex->impl); #elif defined(UCLIENT_PLATFORM_ZEPHYR) k_mutex_init(&mutex->impl); #elif defined(UCLIENT_PLATFORM_POSIX) @@ -29,6 +31,8 @@ void uxr_lock( { #if defined(PLATFORM_NAME_FREERTOS) xSemaphoreTakeRecursive(mutex->impl, portMAX_DELAY); +#elif defined(PLATFORM_NAME_RPIPICO) + recursive_mutex_enter_blocking(&mutex->impl); #elif defined(UCLIENT_PLATFORM_ZEPHYR) k_mutex_lock(&mutex->impl, K_FOREVER); #elif defined(UCLIENT_PLATFORM_POSIX) @@ -43,6 +47,8 @@ void uxr_unlock( { #if defined(PLATFORM_NAME_FREERTOS) xSemaphoreGiveRecursive(mutex->impl); +#elif defined(PLATFORM_NAME_RPIPICO) + recursive_mutex_exit(&mutex->impl); #elif defined(UCLIENT_PLATFORM_ZEPHYR) k_mutex_unlock(&mutex->impl); #elif defined(UCLIENT_PLATFORM_POSIX)