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.
i2cmaster.h
00001 #ifndef MBED_I2CMASTER_H 00002 #define MBED_I2CMASTER_H 00003 00004 #include "mbed.h" 00005 00006 #define SendData 0 00007 #define RequestData 1 00008 00009 class i2c : public I2C 00010 { 00011 public: 00012 i2c(PinName sda, PinName scl); 00013 /*{ 00014 frequency(400000); 00015 }*/ 00016 00017 void sendi2c(char addr, char registar, int data, int size = 0); 00018 /*{ 00019 if(size > 0) size = size; 00020 else if(data > 0xFFFFFF) size = 4; 00021 else if(data > 0xFFFF) size = 3; 00022 else if(data > 0xFF) size = 2; 00023 else size = 1; 00024 char DATA[4] = {data & 0xFF, (data>>8) & 0xFF, (data>>16) & 0xFF, (data>>24) & 0xFF}; 00025 char i2cData[3] = {size, registar, SendData}; 00026 write(addr, i2cData, 3); 00027 write(addr, DATA, size); 00028 }*/ 00029 00030 int getSlaveData(char addr, char registar, int size = 1); 00031 /*{ 00032 char i2cData[3] = {size, registar, RequestData}; 00033 char getData[12] = {}; 00034 write(addr, i2cData, 3); 00035 read(addr, getData, size); 00036 return getData[0] | (getData[1] << 8) | (getData[2] << 16) | (getData[3] << 24); 00037 }*/ 00038 }; 00039 00040 #endif
Generated on Wed Jul 13 2022 04:35:10 by
1.7.2