(MBED) implementation of the I2C interface
Dependents: MCP23009tst AT30TSE752TST MCP4728setaddrProg mbedSerialInterface_talkback2 ... more
MBEDI2CInterface.h
- Committer:
- wbeaumont
- Date:
- 2016-01-12
- Revision:
- 1:80ebfbf95667
- Parent:
- 0:c65947f64a8b
- Child:
- 2:b7ebe53e8fac
File content as of revision 1:80ebfbf95667:
#ifndef __MBEDI2CINTERFACE_H #define __MBEDI2CINTERFACE_H #define VERSION_MBEDI2CInterface_HDR "1.00" class MBEDI2CInterface :public I2CInterface { I2C i2cdev; public : MBEDI2CInterface(PinName sda, PinName scl): getVersion( VERSION_MBEDI2CInterface_HDR,VERSION_MBEDI2CInterface_HDR, __TIME__, __DATE__),i2cdev(sda,scl){ // 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