Ethernetwebsoc

Dependencies:   C12832_lcd LM75B WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
GordonSin
Date:
Fri May 31 04:09:54 2013 +0000
Revision:
0:0ed2a7c7190c
31/5/2013;

Who changed what in which revision?

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