Jump to content
I2Cdevlib Forums

Wire vs Wire1


Recommended Posts

If I want to use i2cdevlib for Wire1 for Arduino 1.5.2 for Arduino Due, what should I do?     Since Due supports TWO I2C interfaces, and Wire1 is the one next AREF.

 

Also, I notice that as part of Fabio's library, someone enhanced the I2Cdevlib to include SPI as well which is sort of nice.    Would you consider including that as part of the trunk?

 

Thanks for the excellent work on this.    Makes my life so much easier.

Link to comment
Share on other sites

Hi RYIP,

 

The library as-is was built for a platform with a single I2C channel, so there isn't a very simple fix to allow use of Wire1. Both the I2Cdev class code and the device code (which calls I2Cdev::methods statically) would need to be aware that there are multiple channels available. The most portable solution would probably be to change the main class and device classes so that multiple channels are supported, but there is a constructor which takes a single argument (device address) that defaults to "channel 1" even if there is only one channel--and then another constructor that takes a slave address as well as a channel number as well as a slave address. This is not a tiny change though.

 

I've thought about SPI as well, though I'm pedantically torn because it is called "I2Cdevlib" after all. :-) I'd have to make it IOdevlib or something. Or I could I wasn't aware that anyone had built SPI into a forked version though. Nobody submitted a pull request. I would definitely be willing to check it out.

 

I'm glad to know that it's a helpful library for you! Thanks for the kind words.

Link to comment
Share on other sites

http://www.varesano.net/files/FreeIMU-20121122_1126.zip

 

FreeIMU uses your i2cdevlib.   However, he introduces a bit for SPI.    I agree with your point about this is called "i2cdevlib" after all.     So, I think the approach taken in freeIMU is not elegant.     On the other hand, I think each of the devices, e.g. ADXL will need to take a bit during the instantiation to specify whether it is sitting on SPI or I2C.      And to be truly flexible, which SPI (if the corresponding CS) and which I2C (e.g. Wire vs Wire1).     But as you pointed out, it is not a trivial change.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...