
Technology For Tomorrow
I2C(2/2)
列舉裝置
m_nUsbDeviceCount = m_hidToI2c.enumDevices(m_nDeviceVid);
開啟裝置且設定頻率
nRes = m_hidToI2c.openDeviceByIndex(0);
nRes = m_hidToI2c.setI2cFrequency(index, (byte) m_nClockDivider);
設定DeviceAddress
nRes = m_hidToI2c.setI2cDeviceAddress(index, byDeviceAddr);
進行讀寫並確認I2C狀態
(需Follow I2C Protocol WaveForm發送I2C讀寫命令)
nRes = m_hidToI2c.i2cWrite(index,I2cSetting.TransferType.I2C_START_STOP, byTemp, nHidWritePacketSize,
100);
nStatus = m_hidToI2c.getI2cStatus(index);
nRes = m_hidToI2c.i2cRead(index, I2cSetting.TransferType.I2C_START_STOP, byTempData, nRecvLength,
100);
關閉裝置
m_hidToI2c.closeDevice(index);