Shuto Naruse
/
Eurobot2012_Secondary
Eurobot2012_Secondary
Fork of Eurobot_2012_Secondary by
Diff: TSH.h
- Revision:
- 1:cc2a9eb0bd55
- Parent:
- 0:fbfafa6bf5f9
--- a/TSH.h Fri Apr 20 21:32:24 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -#ifndef TSH_H -#define TSH_H - -#include "rtos.h" - -//Thread Safe Hardware - -class TSI2C : public I2C { -public: - - TSI2C( PinName sda, - PinName scl, - const char* name=NULL ) - : I2C(sda, scl, name) { } - - - int read( int address, - char* data, - int length, - bool repeated = false ) { - - rlock.lock(); - int retval = I2C::read(address, data, length, repeated); - rlock.unlock(); - - return retval; - } - - int read(int ack) { - rlock.lock(); - int retval = I2C::read(ack); - rlock.unlock(); - - return retval; - } - - int write( int address, - const char* data, - int length, - bool repeated = false ) { - - wlock.lock(); - int retval = I2C::write(address, data, length, repeated); - wlock.unlock(); - - return retval; - } - - int write(int data) { - wlock.lock(); - int retval = I2C::write(data); - wlock.unlock(); - - return retval; - } - -private: - Mutex rlock; - Mutex wlock; -}; - -#endif \ No newline at end of file