title: Experience writing C-code for PCF8575 I/O-Expander on Raspberry Pi
body: <p>Has anyone attempted to write a C/C++ routine to expand the I/O on a Raspberry PI using the PCF8575 I/O-Expander from SparkFun?</p>
  
  <p>I can find a lot of Python samples, which don't help me a lot since I need to develop in C.</p>
  
  <p>I have everything configured right, and I know that my I2C device responds. For example I can do this from the command line:</p>
  
  <pre><code>i2cset -y 1 0x20 0xff 0xff
  i2cset -y 1 0x20 0x00 0x00
  </code></pre>
  
  <p>and all 16 Outputs (in this case) will turn on/off</p>
  
  <p>I also know I could simply do the system(); function from within my C-code,
  but that is not the way I want to go about this, as I'd like to be able to address single Bits in that word and later do toggle modes, etc etc.</p>
  
  <p>I took a look at the Arduino implementation and their sample code, which is (of course) all based on the Atmel processors and modifying all the libraries and files to be compliant with the ARM processor might bring me way beyond the deadline of my project. (It is a simple project to show the difference between populating regular I/O on the Pi, vs using I/O expander via I2C to save I/Os) I'm also writing on a tutorial for my personal reference and for anyone who is interested. But I'm stuck at this point.</p>
  
  <p>Please help</p>