mbed-os5 only for TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Revision:
1:9db0e321a9f4
Parent:
0:5b88d5760320
--- a/rtos/Mutex.h	Tue Dec 17 23:23:45 2019 +0000
+++ b/rtos/Mutex.h	Tue Dec 31 06:02:27 2019 +0000
@@ -1,5 +1,5 @@
 /* mbed Microcontroller Library
- * Copyright (c) 2006-2012 ARM Limited
+ * Copyright (c) 2006-2019 ARM Limited
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -23,16 +23,16 @@
 #define MUTEX_H
 
 #include <stdint.h>
-#include "cmsis_os2.h"
-#include "mbed_rtos1_types.h"
-#include "mbed_rtos_storage.h"
+#include "rtos/mbed_rtos_types.h"
+#include "rtos/mbed_rtos1_types.h"
+#include "rtos/mbed_rtos_storage.h"
 
 #include "platform/NonCopyable.h"
 #include "platform/ScopedLock.h"
 #include "platform/mbed_toolchain.h"
 
 namespace rtos {
-/** \addtogroup rtos */
+/** \addtogroup rtos-public-api */
 /** @{*/
 
 class Mutex;
@@ -56,6 +56,8 @@
 /** The Mutex class is used to synchronize the execution of threads.
  This is, for example, used to protect access to a shared resource.
 
+ In bare-metal builds, the Mutex class is a dummy, so lock() and unlock() are no-ops.
+
  @note You cannot use member functions of this class in ISR context. If you require Mutex functionality within
  ISR handler, consider using @a Semaphore.
 
@@ -88,7 +90,11 @@
       @note This function treats RTOS errors as fatal system errors, so it can only return osOK.
             Use of the return value is deprecated, as the return is expected to become void in the future.
      */
-    osStatus lock(void);
+#if MBED_CONF_RTOS_PRESENT
+    osStatus lock();
+#else
+    void lock(); // Value return backwards compatibility not required for non-RTOS
+#endif
 
     /**
       Wait until a Mutex becomes available.
@@ -150,14 +156,18 @@
       @note This function treats RTOS errors as fatal system errors, so it can only return osOK.
             Use of the return value is deprecated, as the return is expected to become void in the future.
      */
+#if MBED_CONF_RTOS_PRESENT
     osStatus unlock();
+#else
+    void unlock(); // Value return backwards compatibility not required for non-RTOS
+#endif
 
     /** Get the owner the this mutex
       @return  the current owner of this mutex.
 
       @note You cannot call this function from ISR context.
      */
-    osThreadId get_owner();
+    osThreadId_t get_owner();
 
     /** Mutex destructor
      *
@@ -166,16 +176,54 @@
     ~Mutex();
 
 private:
-    void constructor(const char *name = NULL);
+#if MBED_CONF_RTOS_PRESENT
+    void constructor(const char *name = nullptr);
     friend class ConditionVariable;
 
     osMutexId_t               _id;
     mbed_rtos_storage_mutex_t _obj_mem;
     uint32_t                  _count;
+#endif
 };
+
+#if !MBED_CONF_RTOS_PRESENT
+inline Mutex::Mutex()
+{
+}
+
+inline Mutex::Mutex(const char *)
+{
+}
+
+inline Mutex::~Mutex()
+{
+}
+
+inline void Mutex::lock()
+{
+}
+
+inline bool Mutex::trylock()
+{
+    return true;
+}
+
+inline bool Mutex::trylock_for(uint32_t)
+{
+    return true;
+}
+
+inline bool Mutex::trylock_until(uint64_t)
+{
+    return true;
+}
+
+inline void Mutex::unlock()
+{
+}
+#endif
+
 /** @}*/
 /** @}*/
 }
 #endif
-
-