This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OPT3101: SDK question

Part Number: OPT3101

I understand that I have to implement the I2C functions in the hostController file of the SDK based on the hardware I'm using. I have two questions:

1. What is the uint32_t parameter that I am supposed to read or write? How do I interpret that? I know each OPT3101 register contains a 24 bit value, but how does that correspond to a uint32_t?

2. It seems like whoever wrote this SDK did not take into account opening a I2C port, and support for several OPT3101's at the same time. The hostController object is declared in the global scope, and the i2cWrite/read functions are members of each deviceRegister object (and only take in regsiter address and value parameters), so in order to do an i2c operation, the device address/port file descriptor must be passed into each deviceRegister. Is this the recommended way to do this? It seems like I am having to reverse engineer this SDK a lot more than I should to get this working.

  • Hi Andrew,

    1) You'll see that the uint32_t variable is formatted to a %06x, which is 24-bits. So uint32_t data is the register value in decimal and the value passed should be limited to 24-bits in length. I also provide some more info on the EVM specific implementation of host controller below.

    2) I2C needs to be re-implemented in hostController.cpp if you are not using an EVM. The EVM hostController is provided as an example, but since every system is different this could not be provided out of the box. Regarding opening I2C ports, the EVM board contains an OPT3101 connected to an MSP430. The MSP430 connects to a PC over USB where the SDK is running. The SDK opens a serial connection to the MSP on the EVM. The MSP will convert the string commands sent over serial to I2C reads and writes. This is why a serial port is opened rather than an I2C connection in the example controller. If you are running the SDK on a microcontroller and connecting directly over I2C you will need to re-implement the controller for your system.

    You are correct, the code was not architected to allow multiple devices and this is good feedback for us. If you need this modifying should not be too much work. I would suggest as below,

    In hostController.h extern serial::Serial OPT3101commandPort will need to move inside the hostController class and extern hostController host will need to move inside the deviceRegister class in register.h. In the case of the EVM example you will then need to pass a COM port (or in your case perhaps an I2C address) in the OPT3101::device constructor and pass this COM port down to the hostController. This way you can instantiate two OPT3101::device with different COM ports/I2C addresses.

    Best,

    Alex

  • Thanks a bunch for the explanation, makes a lot more sense now!