I am working on a RPi 5 running Bookworm with C.
Adding the line dtparam i2c_arm=on to the config.txt enables I2C on GP Pins 2/3 accessed through /dev/i2c_1. Reboot to activate. This works fine on Chip 4 lines 2/3.
However: if libgpiod functions are used to control the pins, then any I2C attempt will fail thereafter, unless the BCM function flags are reset to ALT0(?), or the system is rebooted. Not unreasonable - but it seems fragile.
Using gpioinfo does not report the I2C setting for the pins, even if the I2C connection is active.
Am I missing something? Is there another function I can use to ensure that gpioinfo will report correctly? And ideally lock out the other libgpiod functions and protect I2C?
To be sure of what is going on, I have a digital analyzer connected to the pins. It shows that lines 2/3 are working with I2C but tend to adopt the last gpioset value in a way that blocks I2C.