PB00005 DFRobot_I2C_protocol_V1.0 - jimaobian/DFRobotWiki GitHub Wiki
Introduction
Define DFRobot's application protocol basing on I2C bus. There is a Arduino library to implement the protocol.
Identifier Definition
- Master: the master device on the I2C bus
- Slave: the slave device on the I2C bus
Arduino Library
Library link:DFRobot_I2C library and samples,the I2C subdirectory.
Use Library
- Initial define
unsigned char Buf[15]; //define buffer which used by URM07 object
DFI2CV10 URM07(Buf,sizeof(Buf)); //define URM07 object
- Set parameter to Slave
SSA = ?; //slave address
RegAddr = ?; //the first register address, you can write multiple continuous registers once
Number = N; //the byte number of register space
Buf[0] = ?; //set the value what you will write to the Register to the Buffer.
...
Buf[N-1] = ?;
URM07.Write(SSA,RegAddr,Number); //Write to Slave
- Get data from Slave
SSA = ?; //slave address
RegAddr = ?; //the first register address, you can read multiple continuous registers once
Number = N; //the byte number of register space
URM07.Read(SSA,RegAddr,Number); //Read from Slave
Data1 = Buf[0]; //Get data from Buffer
...
DataN = Buf[N-1];