RTOS lib used for Eurobot 2012

Dependents:   09_BC2_encoder

Committer:
eembed
Date:
Thu Aug 01 07:49:38 2019 +0000
Revision:
1:b270f864114f
Parent:
0:e477ba491a3b
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
narshu 0:e477ba491a3b 1 /* Copyright (c) 2012 mbed.org */
narshu 0:e477ba491a3b 2 #ifndef SEMAPHORE_H
narshu 0:e477ba491a3b 3 #define SEMAPHORE_H
narshu 0:e477ba491a3b 4
narshu 0:e477ba491a3b 5 #include <stdint.h>
narshu 0:e477ba491a3b 6 #include "cmsis_os.h"
narshu 0:e477ba491a3b 7
narshu 0:e477ba491a3b 8 namespace rtos {
narshu 0:e477ba491a3b 9
narshu 0:e477ba491a3b 10 /*! The Semaphore class is used to manage and protect access to a set of shared resources. */
narshu 0:e477ba491a3b 11 class Semaphore {
narshu 0:e477ba491a3b 12 public:
narshu 0:e477ba491a3b 13 /*! Create and Initialize a Semaphore object used for managing resources.
narshu 0:e477ba491a3b 14 \param number of available resources; maximum index value is (count-1).
narshu 0:e477ba491a3b 15 */
narshu 0:e477ba491a3b 16 Semaphore(int32_t count);
narshu 0:e477ba491a3b 17
narshu 0:e477ba491a3b 18 /*! Wait until a Semaphore resource becomes available.
narshu 0:e477ba491a3b 19 \param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
narshu 0:e477ba491a3b 20 \return number of available tokens, or -1 in case of incorrect parameters
narshu 0:e477ba491a3b 21 */
narshu 0:e477ba491a3b 22 int32_t wait(uint32_t millisec=osWaitForever);
narshu 0:e477ba491a3b 23
narshu 0:e477ba491a3b 24 /*! Release a Semaphore resource that was obtain with Semaphore::wait.
narshu 0:e477ba491a3b 25 \return status code that indicates the execution status of the function.
narshu 0:e477ba491a3b 26 */
narshu 0:e477ba491a3b 27 osStatus release(void);
narshu 0:e477ba491a3b 28
narshu 0:e477ba491a3b 29 private:
narshu 0:e477ba491a3b 30 osSemaphoreId _osSemaphoreId;
narshu 0:e477ba491a3b 31 osSemaphoreDef_t _osSemaphoreDef;
narshu 0:e477ba491a3b 32 #ifdef CMSIS_OS_RTX
narshu 0:e477ba491a3b 33 uint32_t _semaphore_data[2];
narshu 0:e477ba491a3b 34 #endif
narshu 0:e477ba491a3b 35 };
narshu 0:e477ba491a3b 36
narshu 0:e477ba491a3b 37 }
narshu 0:e477ba491a3b 38 #endif