LAN(Wi-Fi) air controller through the Internet. Also you can use TANK. See:http://wizard.nestegg.jp/lanir.html
Dependencies: EthernetNetIf mbed HTTPServer
Diff: Semaphore.h
- Revision:
- 0:6f9648f5eaab
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Semaphore.h Mon Aug 01 19:21:55 2011 +0000 @@ -0,0 +1,34 @@ +// Copyright (C) 2010 Robert M. Bouwens + +#ifndef _SEMAPHORE_H_ +#define _SEMAPHORE_H_ + +/* + * http://mbed.org/forum/mbed/topic/181/#comment-799 + */ + +class Semaphore { +public: + Semaphore(): s(SemFree) {}; + + bool try_enter() { + int oldval = __ldrex(&s); + if (oldval == SemTaken) { + __clrex(); + return false; + } + s = SemTaken; + __clrex(); + return SemTaken == s; + }; + + void release() { + s = SemFree; + }; + +private: + enum { SemFree = 1, SemTaken = 2 }; + volatile int s; +}; + +#endif \ No newline at end of file