RTOS lib used for Eurobot 2012
Dependents: Eurobot2012_Secondary Team_Sprint2 Team_Sprint2 Rafi_Final ... more
Semaphore.h
00001 /* Copyright (c) 2012 mbed.org */ 00002 #ifndef SEMAPHORE_H 00003 #define SEMAPHORE_H 00004 00005 #include <stdint.h> 00006 #include "cmsis_os.h" 00007 00008 namespace rtos { 00009 00010 /*! The Semaphore class is used to manage and protect access to a set of shared resources. */ 00011 class Semaphore { 00012 public: 00013 /*! Create and Initialize a Semaphore object used for managing resources. 00014 \param number of available resources; maximum index value is (count-1). 00015 */ 00016 Semaphore (int32_t count); 00017 00018 /*! Wait until a Semaphore resource becomes available. 00019 \param millisec timeout value or 0 in case of no time-out. (default: osWaitForever). 00020 \return number of available tokens, or -1 in case of incorrect parameters 00021 */ 00022 int32_t wait (uint32_t millisec=osWaitForever); 00023 00024 /*! Release a Semaphore resource that was obtain with Semaphore::wait. 00025 \return status code that indicates the execution status of the function. 00026 */ 00027 osStatus release (void); 00028 00029 private: 00030 osSemaphoreId _osSemaphoreId; 00031 osSemaphoreDef_t _osSemaphoreDef; 00032 #ifdef CMSIS_OS_RTX 00033 uint32_t _semaphore_data[2]; 00034 #endif 00035 }; 00036 00037 } 00038 #endif
Generated on Wed Jul 13 2022 19:50:35 by 1.7.2