0

To make an ADS1115 ADC module running on my Raspi 3B, I am trying to use the driver supplied by Elektor Labs. The driver requires the user to develop the low-level part (I²C commands) himself and then to attach it to the backend API of the driver, which consists of these procedures:

// I2C stubs, implementations to be provided by the user.
extern uint8_t ADS1x1x_i2c_start_write(uint8_t i2c_address);
extern uint8_t ADS1x1x_i2c_write(uint8_t x);
extern uint8_t ADS1x1x_i2c_start_read(uint8_t i2c_address, uint16_t bytes_to_read);
extern uint8_t ADS1x1x_i2c_read(void);
extern uint8_t ADS1x1x_i2c_stop(void);

I am using the I²C API of pigpiod. Now, here is my question: Which pigpiod function(s) are necessary to implement the ADS1x1x_i2c_start_read () function?

2 Answers 2

2

There is not a 1 to 1 mapping.

You need to get a handle to the I2C device at the start of your program using i2c_open.

At the end of your program release the handle with i2c_close.

To write one or more bytes use i2c_write_device.

To read one or more bytes use i2c_read_device.

3
  • Not i2c_write_byte resp. i2c_read_byte?
    – Neppomuk
    Dec 19, 2020 at 22:23
  • @Neppomuk You can use those if you want to read/write just one byte. Whatever works for your situation.
    – joan
    Dec 19, 2020 at 22:29
  • As the function signatures prescribe uint8_t as return value, I strongly suppose that they shall work one byte only with every call.
    – Neppomuk
    Dec 19, 2020 at 22:47
0

After trying out, I found out that there is no analogon at all between the pigpiod routines, and the low-level procedures required by the ADS1115 driver: ADS1x1x_i2c_start_write (), for instance, is expected to send a start bit and a write bit to the ADC and nothing more. On the other hand, ADS1x1x_i2c_stop () shall send a stop bit and nothing else.

Unfortunately, this is not documented in the source code, nor in the readme file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.