Announcement

Collapse
No announcement yet.

Custom I2C Legacy Module Connection

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom I2C Legacy Module Connection

    So far, I have used this to write:
    Code:
    public void write(int memAddress, byte[] data){
        legacyModule.enableI2cWriteMode(port, i2cAddress, memAddress, data.length);
        while(legacyModule.isI2cPortActionFlagSet(port)){}
        legacyModule.copyBufferIntoWriteBuffer(port, data);
        legacyModule.setI2cPortActionFlag(port);
    }
    and this to read:
    Code:
    public byte[] read(int memAddress, int length){
        legacyModule.enableI2cReadMode(port, i2cAddress, memAddress, length);
        while(legacyModule.isI2cPortActionFlagSet(port)){}
        return legacyModule.getCopyOfReadBuffer(port);
    }
    This is what I have collected by the very confusing I2cController class, which is inherited by the LegacyModule class. I haven't got it working though. Did I miss something.

  • #2
    The I2C API is indeed very confusing. Were I coding this, among other things, I would query for isI2cPortInWriteMode and isI2cPortInReadMode rather than looking at the action flags, and your write logic doesn't actually ever push the 'write buffer' out to the controller.

    This might be of interest, and also this, the latter being an extensive example of the use of the former.

    Comment


    • #3
      Postscript: this is another, perhaps simpler, example.

      Comment


      • #4
        What would I use to push it? I thought that's what the flag does.

        Comment

        Working...
        X