IC Eurobot 2012 Program published from Shuto's account

Dependents:   Eurobot2012_Primary

Committer:
narshu
Date:
Tue Aug 07 10:25:51 2012 +0000
Revision:
0:62626fd22b30
[mbed] converted /Eurobot_2012_Primary/rtos

Who changed what in which revision?

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