I2C interface for our mbed.
Fork of I2Cinterfaces by
Diff: MBEDI2CInterface.h
- Revision:
- 0:c65947f64a8b
- Child:
- 1:80ebfbf95667
diff -r 000000000000 -r c65947f64a8b MBEDI2CInterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MBEDI2CInterface.h Tue Jan 12 15:04:03 2016 +0000 @@ -0,0 +1,39 @@ +#ifndef __MBEDI2CINTERFACE_H +#define __MBEDI2CINTERFACE_H + +#define VERSION_MBEDI2CInterface_HDR "1.00" + + +class MBEDI2CInterface :public I2CInterface { + + I2C i2cdev; + public : + + MBEDI2CInterface(PinName sda, PinName scl): i2cdev(sda,scl), + getVersion( VERSION_MBEDI2CInterface_HDR,VERSION_MBEDI2CInterface_HDR, __TIME__, __DATE__){ + // no init code yet + } ; + // next could perhaps more efficient but not yet investigated +virtual void frequency (int hz){return i2cdev.frequency(hz) ;}; +virtual int read (int address, char *data, int length, bool repeated=false){ + return i2cdev.read ( address, data, length, repeated);}; + virtual int read (int ack){return i2cdev.read ( ack);};// Read a single byte from the I2C bus. + virtual int write (int address, const char *data, int length, bool repeated=false){ + return i2cdev.write ( address, data, length, repeated); + } +virtual int write (int data){return i2cdev.write (data);};// Write single byte out on the I2C bus. +virtual void start (void){i2cdev.start ();};// Creates a start condition on the I2C bus. +virtual void stop (void){i2cdev.stop();};// Creates a stop condition on the I2C bus. +virtual int transfer (int address, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, void* callbackfunction, bool repeated=false){ + return -1; // seems transfer not supported in mbed or not correctly called below + // return i2cdev.transfer (address, tx_buffer, tx_length, rx_buffer, rx_length, callback, event, repeated); + }; + + + } ; + + + + + +#endif \ No newline at end of file