test

Dependencies:   F7_Ethernet mbed BSP_DISCO_F746NG SDFileSystem RF24

Committer:
lowlowry
Date:
Tue Jun 08 16:21:16 2021 +0000
Revision:
3:1c6da30ca347
Parent:
0:d984976f1f1c
test final

Who changed what in which revision?

UserRevisionLine numberNew 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 SEMAPHORE_H
leo44 0:d984976f1f1c 23 #define SEMAPHORE_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 Semaphore class is used to manage and protect access to a set of shared resources. */
leo44 0:d984976f1f1c 31 class Semaphore {
leo44 0:d984976f1f1c 32 public:
leo44 0:d984976f1f1c 33 /** Create and Initialize a Semaphore object used for managing resources.
leo44 0:d984976f1f1c 34 @param number of available resources; maximum index value is (count-1).
leo44 0:d984976f1f1c 35 */
leo44 0:d984976f1f1c 36 Semaphore(int32_t count);
leo44 0:d984976f1f1c 37
leo44 0:d984976f1f1c 38 /** Wait until a Semaphore resource 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 number of available tokens, or -1 in case of incorrect parameters
leo44 0:d984976f1f1c 41 */
leo44 0:d984976f1f1c 42 int32_t wait(uint32_t millisec=osWaitForever);
leo44 0:d984976f1f1c 43
leo44 0:d984976f1f1c 44 /** Release a Semaphore resource that was obtain with Semaphore::wait.
leo44 0:d984976f1f1c 45 @return status code that indicates the execution status of the function.
leo44 0:d984976f1f1c 46 */
leo44 0:d984976f1f1c 47 osStatus release(void);
leo44 0:d984976f1f1c 48
leo44 0:d984976f1f1c 49 ~Semaphore();
leo44 0:d984976f1f1c 50
leo44 0:d984976f1f1c 51 private:
leo44 0:d984976f1f1c 52 osSemaphoreId _osSemaphoreId;
leo44 0:d984976f1f1c 53 osSemaphoreDef_t _osSemaphoreDef;
leo44 0:d984976f1f1c 54 #ifdef CMSIS_OS_RTX
leo44 0:d984976f1f1c 55 uint32_t _semaphore_data[2];
leo44 0:d984976f1f1c 56 #endif
leo44 0:d984976f1f1c 57 };
leo44 0:d984976f1f1c 58
leo44 0:d984976f1f1c 59 }
leo44 0:d984976f1f1c 60 #endif