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 Orefatoi

Committer:
wataloh
Date:
Tue May 16 08:58:26 2017 +0000
Revision:
14:b205267fa5f6
+ flow control; + 1 second interval between each transaction

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wataloh 14:b205267fa5f6 1 #ifndef _ULTRA_SIMPLE_POOL_
wataloh 14:b205267fa5f6 2 #define _ULTRA_SIMPLE_POOL_
wataloh 14:b205267fa5f6 3
wataloh 14:b205267fa5f6 4 template<typename T> class USPool
wataloh 14:b205267fa5f6 5 {
wataloh 14:b205267fa5f6 6 private: bool pool_usage[];
wataloh 14:b205267fa5f6 7 private: T pool[];
wataloh 14:b205267fa5f6 8 private: int len;
wataloh 14:b205267fa5f6 9 public: USPool(T init, int _size)
wataloh 14:b205267fa5f6 10 {
wataloh 14:b205267fa5f6 11 pool_usage = new bool[_size];
wataloh 14:b205267fa5f6 12 pool = new pool[_size];
wataloh 14:b205267fa5f6 13 len = _size;
wataloh 14:b205267fa5f6 14 for(int i=0; i<len; ++i)
wataloh 14:b205267fa5f6 15 {
wataloh 14:b205267fa5f6 16 pool_usage[i] = false;
wataloh 14:b205267fa5f6 17 pool[i] = init;
wataloh 14:b205267fa5f6 18 }
wataloh 14:b205267fa5f6 19 }
wataloh 14:b205267fa5f6 20 public: ~USPool()
wataloh 14:b205267fa5f6 21 {
wataloh 14:b205267fa5f6 22 delete[] pool;
wataloh 14:b205267fa5f6 23 pool = NULL;
wataloh 14:b205267fa5f6 24 delete[] pool_usage;
wataloh 14:b205267fa5f6 25 pool_usage = NULL;
wataloh 14:b205267fa5f6 26 }
wataloh 14:b205267fa5f6 27 public: T obtain(T unavail)
wataloh 14:b205267fa5f6 28 {
wataloh 14:b205267fa5f6 29 T ret = unavail;
wataloh 14:b205267fa5f6 30 for(int i=0; i<len; ++i)
wataloh 14:b205267fa5f6 31 {
wataloh 14:b205267fa5f6 32 if(pool_usage[i] == false)
wataloh 14:b205267fa5f6 33 {
wataloh 14:b205267fa5f6 34 pool_usage[i] = true;
wataloh 14:b205267fa5f6 35 ret = pool[i];
wataloh 14:b205267fa5f6 36 break;
wataloh 14:b205267fa5f6 37 }
wataloh 14:b205267fa5f6 38 }
wataloh 14:b205267fa5f6 39 return ret;
wataloh 14:b205267fa5f6 40 }
wataloh 14:b205267fa5f6 41 public: void release(T *released)
wataloh 14:b205267fa5f6 42 {
wataloh 14:b205267fa5f6 43 for(int i=0; i<len; ++i)
wataloh 14:b205267fa5f6 44 {
wataloh 14:b205267fa5f6 45 if(pool[i] == released)
wataloh 14:b205267fa5f6 46 {
wataloh 14:b205267fa5f6 47 pool_usage[i] = false;
wataloh 14:b205267fa5f6 48 }
wataloh 14:b205267fa5f6 49 }
wataloh 14:b205267fa5f6 50 }
wataloh 14:b205267fa5f6 51 };
wataloh 14:b205267fa5f6 52
wataloh 14:b205267fa5f6 53 #endif //_ULTRA_SIMPLE_POOL_