Raspberry Pi 2 Model B (以下RPi2)
Raspbian Jessie
gcc (Raspbian 4.9.2-10) 4.9.2
とあるI2Cセンサー
I2Cのslave deviceにおいてclock stretching機能を持つ製品がある。
clock stretchingにおいてはSCLがlowにholdされる状態になる。
masterであるRPi2でSCLがlowを認識出ればいいが、RPi2のbcmチップセットではバグにより認識できないとのこと。
http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html
対応方法としては「baudrateをlowestにする」こと。
参考1
You can slow down the whole I2C bus so that perhaps your attached device may be able to complete tasks within longer clock times.
/boot/config.txt
への設定例がある。
また、コマンドでのon the flyでの設定方法も紹介されている。
参考2
Generally use the lowest you can to mitigate the clock stretching bug, if your device supports clock stretching. (these eeproms dont)
懸念
clock stretchingの期間が12msecから150msecというようなslave deviceの場合、baudrateは3Hzなどになる。
ソフトウェアI2C実装で対応するなどの工夫が必要かもしれない。
参考3
In order to workaround this, I set data rate in I2C slave module higher. The communication rate is 400 kbps, but I set the data rate 1000 kbps. It worked for me.
baudrateを小さくするのでなく大きくすることで対処。