I have several modules that talk over an I2C bus (Accelerometer, Compass, ADC). The fun part is that the compass uses 100KHz and everything else is capable of 400KHz. I got all of these modules talking with the mbed with small test code and now I want to integrate them without it looking like a pile of nasty code (INS code will look bad enough without communication code mucking it up).
Sooo, I thought I would tinker with classes and include files for the first time. I'm hoping to split each module into a different class and header file. So the question is can I declare three I2C objects each using different frequencies but the same pins? In other words, I'm hoping that under the Compass class I can have
Compass.setup(p9,p10) which would have it's own i2c(p9,p10) and also call i2c.frequency(100000)
Then have an acceleromater class with the same thing but 400KHz.
Can I do this, or do I need to pass the I2C bus to the class then tinker with the frequency before each read/write?
I have several modules that talk over an I2C bus (Accelerometer, Compass, ADC). The fun part is that the compass uses 100KHz and everything else is capable of 400KHz. I got all of these modules talking with the mbed with small test code and now I want to integrate them without it looking like a pile of nasty code (INS code will look bad enough without communication code mucking it up).
Sooo, I thought I would tinker with classes and include files for the first time. I'm hoping to split each module into a different class and header file. So the question is can I declare three I2C objects each using different frequencies but the same pins? In other words, I'm hoping that under the Compass class I can have
Compass.setup(p9,p10) which would have it's own i2c(p9,p10) and also call i2c.frequency(100000)
Then have an acceleromater class with the same thing but 400KHz.
Can I do this, or do I need to pass the I2C bus to the class then tinker with the frequency before each read/write?