private void WriteToI2CDevice() { /* * Initialize the FDC1004 capacitance sensor: * * For this device, we create 3-byte write buffers: ==> this device uses * The first byte is the register address we want to write to. * The second byte is the contents of the MSB that we want to write to the register. * The third byte is the contents of the LSB that we want to write to the register. */ byte[] WriteBuf_MeasurementOneFormat = new byte[] { MEAS_ONE_CONTROL, 0x1c, 0x00 }; // configs measurement 1 byte[] WriteBuf_MeasurementTwoFormat = new byte[] { MEAS_TWO_CONTROL, 0x3c, 0x00 }; // configs measurement 2 byte[] WriteBuf_MeasurementThreeFormat = new byte[] { MEAS_THREE_CONTROL, 0x5c, 0x00 }; // configs measurement 3 byte[] WriteBuf_Cin1 = new byte[] { CIN1_CONTROL, 0x30, 0x00 }; // Set Offset for Cin1 to "6"pF based on datsheet calculations byte[] WriteBuf_FDC_Config = new byte[] { FDC_CONF_CONTROL, 0x0D, 0xE0 }; //set to read at 400S/s with repeat and read at measurement #1,#2,#3 I2CSensor.Write(WriteBuf_MeasurementOneFormat); I2CSensor.Write(WriteBuf_MeasurementTwoFormat); I2CSensor.Write(WriteBuf_MeasurementThreeFormat); I2CSensor.Write(WriteBuf_Cin1); I2CSensor.Write(WriteBuf_FDC_Config); }
/// <summary> /// Resets the I2C port /// </summary> public void Reset() { byte[] WriteBuf_FDC_Config = new byte[] { FDC_CONF_CONTROL, 0x8C, 0x00 }; I2CSensor.Write(WriteBuf_FDC_Config); WriteToI2CDevice(); }