From e7b5254a33013447fbcff6369851cefe74a6cf37 Mon Sep 17 00:00:00 2001 From: cfif Date: Tue, 23 Sep 2025 13:35:15 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/SystemMutexCmsis.h | 17 +++++++++++++++++ modular.json | 22 ++++++++++++++++++++++ src/SystemMutexCmsis.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 inc/SystemMutexCmsis.h create mode 100644 modular.json create mode 100644 src/SystemMutexCmsis.c diff --git a/inc/SystemMutexCmsis.h b/inc/SystemMutexCmsis.h new file mode 100644 index 0000000..85b43c3 --- /dev/null +++ b/inc/SystemMutexCmsis.h @@ -0,0 +1,17 @@ +// +// Created by xemon on 26.09.23. +// + +#ifndef MOTOTERMINAL_MAIN_ONAT435_SYSTEMMUTEXCMSIS_H +#define MOTOTERMINAL_MAIN_ONAT435_SYSTEMMUTEXCMSIS_H + +#include "SystemMutexInterface.h" +#include "cmsis_os.h" + +typedef osMutexId_t SystemMutexCmsis; + +void SystemMutexCmsis_init(SystemMutexCmsis *env, const osMutexAttr_t *attr); + +tSystemMutexInterface SystemMutexCmsis_getInterface(SystemMutexCmsis *env); + +#endif //MOTOTERMINAL_MAIN_ONAT435_SYSTEMMUTEXCMSIS_H diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..afd5215 --- /dev/null +++ b/modular.json @@ -0,0 +1,22 @@ +{ + "dep": [ + { + "type": "git", + "provider": "HVAC_M7", + "repo": "CmsisRtosInterface" + }, + { + "type": "git", + "provider": "HVAC_M7", + "repo": "SystemSyncInterface" + } + ], + "cmake": { + "inc_dirs": [ + "./inc/" + ], + "srcs": [ + "./src/**.c" + ] + } +} \ No newline at end of file diff --git a/src/SystemMutexCmsis.c b/src/SystemMutexCmsis.c new file mode 100644 index 0000000..0c1a7b5 --- /dev/null +++ b/src/SystemMutexCmsis.c @@ -0,0 +1,30 @@ +// +// Created by xemon on 26.09.23. +// +#include +#include +#include "SystemMutexCmsis.h" + + +void SystemMutexCmsis_init(SystemMutexCmsis *env, const osMutexAttr_t *attr) { + *env = osMutexNew(attr); +} + +static bool SystemMutexCmsis_acquire(SystemMutexCmsis *env, int32_t timeout) { + return osMutexAcquire(*env, timeout) == osOK; +} + +static bool SystemMutexCmsis_release(SystemMutexCmsis *env, const osMutexAttr_t *attr) { + (void)(attr); + return osMutexRelease(*env) == osOK; +} + + +tSystemMutexInterface SystemMutexCmsis_getInterface(SystemMutexCmsis *env) { + return (tSystemMutexInterface) { + .env = env, + .acquire = (void *) SystemMutexCmsis_acquire, + .release = (void *) SystemMutexCmsis_release, + }; +} +