NRF: receive, ntp, Data to Sd-card working
Dependencies: F7_Ethernet mbed BSP_DISCO_F746NG Test_Mainboard SDFileSystem RF24
Mutex.h@4:5ecb71f149bf, 2021-06-20 (annotated)
- Committer:
- lowlowry
- Date:
- Sun Jun 20 13:48:06 2021 +0000
- Revision:
- 4:5ecb71f149bf
- Parent:
- 0:d984976f1f1c
NRF: receive, ntp, Data to Sd-card working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
leo44 | 0:d984976f1f1c | 1 | /* mbed Microcontroller Library |
leo44 | 0:d984976f1f1c | 2 | * Copyright (c) 2006-2012 ARM Limited |
leo44 | 0:d984976f1f1c | 3 | * |
leo44 | 0:d984976f1f1c | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
leo44 | 0:d984976f1f1c | 5 | * of this software and associated documentation files (the "Software"), to deal |
leo44 | 0:d984976f1f1c | 6 | * in the Software without restriction, including without limitation the rights |
leo44 | 0:d984976f1f1c | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
leo44 | 0:d984976f1f1c | 8 | * copies of the Software, and to permit persons to whom the Software is |
leo44 | 0:d984976f1f1c | 9 | * furnished to do so, subject to the following conditions: |
leo44 | 0:d984976f1f1c | 10 | * |
leo44 | 0:d984976f1f1c | 11 | * The above copyright notice and this permission notice shall be included in |
leo44 | 0:d984976f1f1c | 12 | * all copies or substantial portions of the Software. |
leo44 | 0:d984976f1f1c | 13 | * |
leo44 | 0:d984976f1f1c | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
leo44 | 0:d984976f1f1c | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
leo44 | 0:d984976f1f1c | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
leo44 | 0:d984976f1f1c | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
leo44 | 0:d984976f1f1c | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
leo44 | 0:d984976f1f1c | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
leo44 | 0:d984976f1f1c | 20 | * SOFTWARE. |
leo44 | 0:d984976f1f1c | 21 | */ |
leo44 | 0:d984976f1f1c | 22 | #ifndef MUTEX_H |
leo44 | 0:d984976f1f1c | 23 | #define MUTEX_H |
leo44 | 0:d984976f1f1c | 24 | |
leo44 | 0:d984976f1f1c | 25 | #include <stdint.h> |
leo44 | 0:d984976f1f1c | 26 | #include "cmsis_os.h" |
leo44 | 0:d984976f1f1c | 27 | |
leo44 | 0:d984976f1f1c | 28 | namespace rtos { |
leo44 | 0:d984976f1f1c | 29 | |
leo44 | 0:d984976f1f1c | 30 | /** The Mutex class is used to synchronise the execution of threads. |
leo44 | 0:d984976f1f1c | 31 | This is for example used to protect access to a shared resource. |
leo44 | 0:d984976f1f1c | 32 | */ |
leo44 | 0:d984976f1f1c | 33 | class Mutex { |
leo44 | 0:d984976f1f1c | 34 | public: |
leo44 | 0:d984976f1f1c | 35 | /** Create and Initialize a Mutex object */ |
leo44 | 0:d984976f1f1c | 36 | Mutex(); |
leo44 | 0:d984976f1f1c | 37 | |
leo44 | 0:d984976f1f1c | 38 | /** Wait until a Mutex becomes available. |
leo44 | 0:d984976f1f1c | 39 | @param millisec timeout value or 0 in case of no time-out. (default: osWaitForever) |
leo44 | 0:d984976f1f1c | 40 | @return status code that indicates the execution status of the function. |
leo44 | 0:d984976f1f1c | 41 | */ |
leo44 | 0:d984976f1f1c | 42 | osStatus lock(uint32_t millisec=osWaitForever); |
leo44 | 0:d984976f1f1c | 43 | |
leo44 | 0:d984976f1f1c | 44 | /** Try to lock the mutex, and return immediately |
leo44 | 0:d984976f1f1c | 45 | @return true if the mutex was acquired, false otherwise. |
leo44 | 0:d984976f1f1c | 46 | */ |
leo44 | 0:d984976f1f1c | 47 | bool trylock(); |
leo44 | 0:d984976f1f1c | 48 | |
leo44 | 0:d984976f1f1c | 49 | /** Unlock the mutex that has previously been locked by the same thread |
leo44 | 0:d984976f1f1c | 50 | @return status code that indicates the execution status of the function. |
leo44 | 0:d984976f1f1c | 51 | */ |
leo44 | 0:d984976f1f1c | 52 | osStatus unlock(); |
leo44 | 0:d984976f1f1c | 53 | |
leo44 | 0:d984976f1f1c | 54 | ~Mutex(); |
leo44 | 0:d984976f1f1c | 55 | |
leo44 | 0:d984976f1f1c | 56 | private: |
leo44 | 0:d984976f1f1c | 57 | osMutexId _osMutexId; |
leo44 | 0:d984976f1f1c | 58 | osMutexDef_t _osMutexDef; |
leo44 | 0:d984976f1f1c | 59 | #ifdef CMSIS_OS_RTX |
leo44 | 0:d984976f1f1c | 60 | #if defined(__MBED_CMSIS_RTOS_CA9) || defined(__MBED_CMSIS_RTOS_CM) |
leo44 | 0:d984976f1f1c | 61 | int32_t _mutex_data[4]; |
leo44 | 0:d984976f1f1c | 62 | #else |
leo44 | 0:d984976f1f1c | 63 | int32_t _mutex_data[3]; |
leo44 | 0:d984976f1f1c | 64 | #endif |
leo44 | 0:d984976f1f1c | 65 | #endif |
leo44 | 0:d984976f1f1c | 66 | }; |
leo44 | 0:d984976f1f1c | 67 | |
leo44 | 0:d984976f1f1c | 68 | } |
leo44 | 0:d984976f1f1c | 69 | #endif |