pwm period is now 200us instead of the default 20ms veml6040 config is now AF_BIT | TRIG_BIT
Dependencies: mbed MMA8451Q USBDevice WakeUp vt100
Fork of afero_node_suntory_2017_06_15 by
Diff: util/USPool.hpp
- Revision:
- 14:b205267fa5f6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/util/USPool.hpp Tue May 16 08:58:26 2017 +0000 @@ -0,0 +1,53 @@ +#ifndef _ULTRA_SIMPLE_POOL_ +#define _ULTRA_SIMPLE_POOL_ + +template<typename T> class USPool +{ + private: bool pool_usage[]; + private: T pool[]; + private: int len; + public: USPool(T init, int _size) + { + pool_usage = new bool[_size]; + pool = new pool[_size]; + len = _size; + for(int i=0; i<len; ++i) + { + pool_usage[i] = false; + pool[i] = init; + } + } + public: ~USPool() + { + delete[] pool; + pool = NULL; + delete[] pool_usage; + pool_usage = NULL; + } + public: T obtain(T unavail) + { + T ret = unavail; + for(int i=0; i<len; ++i) + { + if(pool_usage[i] == false) + { + pool_usage[i] = true; + ret = pool[i]; + break; + } + } + return ret; + } + public: void release(T *released) + { + for(int i=0; i<len; ++i) + { + if(pool[i] == released) + { + pool_usage[i] = false; + } + } + } +}; + +#endif //_ULTRA_SIMPLE_POOL_