public CommMgrClass() { this.HostAppClient.TxCurrentTransmissionType = CommonClass.TransmissionType.GP2; this.HostAppServer = new TCPIPServer(); this.HostAppServer.TxCurrentTransmissionType = CommonClass.TransmissionType.GP2; this.HostAppI2CSlave = new I2CSlave(); this.HostAppI2CSlave.TxCurrentTransmissionType = CommonClass.TransmissionType.GP2; }
/// <summary> /// Changes address of the I2C device /// </summary> /// <param name="newAddress">New 7bit address</param> public void ChangeI2CAddress(byte newAddress) { _slave.ChangeI2CAddress(SRF02Sonar.REG_COMMAND_REVISION, newAddress); _slave.Dispose(); // Wait a few miliseconds to make things "sattle", otherwise it will fail Thread.Sleep(50); // Create _slave with new address _slave = new I2CSlave(newAddress); }
/// <summary> /// Changes address of the I2C device. /// Works only for revision 14 and above /// </summary> /// <param name="newAddress">New 7bit address</param> public void ChangeI2CAddress(byte newAddress) { byte[] data = new byte[4] { I2CSlave.ADDRESS_CHANGE_1, I2CSlave.ADDRESS_CHANGE_2, I2CSlave.ADDRESS_CHANGE_3, (byte)(newAddress << 1), }; _slave.WriteRegister(CMPS03Compass.REG_UNLOCK_1, data); _slave.Dispose(); // Wait a few miliseconds to make things "sattle", otherwise it will fail Thread.Sleep(50); // Create _slave with new address _slave = new I2CSlave(newAddress); }