Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed PowerControl SDFileSystem
Fork of HeptaBattery_SDFilesystem_Q by
Diff: hepta_sat/I2cBusDevice.h
- Revision:
- 0:9eb94b338772
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hepta_sat/I2cBusDevice.h Fri Dec 09 04:53:49 2016 +0000
@@ -0,0 +1,44 @@
+#ifndef MBED_I2cBusDevice
+#define MBED_I2cBusDevice
+
+#include "mbed.h"
+
+class I2cBusDevice {
+public:
+
+ I2cBusDevice( I2C *i2c, char dev_address ) {
+ bus = i2c;
+ device = dev_address;
+ }
+
+ ~I2cBusDevice() {
+ }
+
+ int write( char *data, int length ) {
+ return ( bus->write( device, data, length) );
+ }
+
+ int read( char *data, int length ) {
+ return ( bus->read( device, data, length) );
+ }
+
+ int read( char reg_ptr, char *data, int length ) {
+ if ( bus->write( device, ®_ptr, 1 ) )
+ return ( 1 );
+
+ if ( bus->read( device, data, length ) )
+ return ( 1 );
+
+ return ( 0 );
+ }
+
+protected:
+ I2C *bus;
+ char device;
+
+private:
+ static char i2c_error;
+}
+;
+
+#endif
