Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 4 months ago.
How do I use the "I2CHelper"?
Hello how do I use the I2CHelper library?
Has anyone got an example?
I'm asking because I'm new to object oriented C.
BR Johan
Question relating to:
1 Answer
10 years, 3 months ago.
I2CHelper myHelper(sda, scl); // replace sda and scl with the pins to use main () { myHelper.setFrequency(500 * 1000); // set the frequency in Hz // personal preference here, I write 500 * 1000 rather than 500000 for 500kHz, it makes it more readable uint8_t dataByte myHelper.readByte( deviceAddress, registerAddress, &dataByte); }
You can use any of the functions listed as public in the header file in the same way. The names are fairly self explanatory. http://mbed.org/users/ethanharstad/code/I2CHelper/file/51de41e0e0c9/I2CHelper.h
The header (in theory) tells you all you need to talk to the library, you should only need to look at the .cpp file if you want to know how it does it.