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 SDFilesystem by
I2cBusDevice.h
00001 #ifndef MBED_I2cBusDevice 00002 #define MBED_I2cBusDevice 00003 00004 #include "mbed.h" 00005 00006 class I2cBusDevice { 00007 public: 00008 00009 I2cBusDevice( I2C *i2c, char dev_address ) { 00010 bus = i2c; 00011 device = dev_address; 00012 } 00013 00014 ~I2cBusDevice() { 00015 } 00016 00017 int write( char *data, int length ) { 00018 return ( bus->write( device, data, length) ); 00019 } 00020 00021 int read( char *data, int length ) { 00022 return ( bus->read( device, data, length) ); 00023 } 00024 00025 int read( char reg_ptr, char *data, int length ) { 00026 if ( bus->write( device, ®_ptr, 1 ) ) 00027 return ( 1 ); 00028 00029 if ( bus->read( device, data, length ) ) 00030 return ( 1 ); 00031 00032 return ( 0 ); 00033 } 00034 00035 protected: 00036 I2C *bus; 00037 char device; 00038 00039 private: 00040 static char i2c_error; 00041 } 00042 ; 00043 00044 #endif
Generated on Fri Jul 15 2022 08:06:17 by
1.7.2
