This question comes up from time to time. If you search for "I2C programming" using the search box at the bottom left of this web page, you will find a number of threads on the topic. Here a posting with some source code. Maybe this will help you.
---Tom