智也 大野 / Mbed 2 deprecated SDFilesystem

Dependencies:   mbed PowerControl SDFileSystem

Fork of SDFilesystem by 智也 大野

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers I2cBusDevice.h Source File

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, &reg_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