MOD54415 I2C example code

Discussion to talk about software related topics only.
Post Reply
nicobari
Posts: 110
Joined: Mon Jan 30, 2012 12:15 pm

MOD54415 I2C example code

Post by nicobari »

Hi,
In the NetburnerRuntimeLibraries.pdf on page number 12 it says "Note:An example I2C application can be found in C:\Nburn\example\<HWPLatform>" but when I opened my C:\Nburn\example\MOD54415 folder I didn't see any I2C example. Where can I find an I2C example code?

Thanks,
TM
mbrown
Posts: 61
Joined: Tue Jan 29, 2013 7:12 pm

Re: MOD54415 I2C example code

Post by mbrown »

I've answered this question a few times in the past week or two and I'm going to add a few examples to our standard eclipse build to demonstrate for people. For the most part, our i2c drivers are cross-platform, so if you wrote it for one platform, it most likely works on another. I'm going to attach 3 programs to this post, each with different uses.

The first is our classic i2c2serial example that allows two Netburner devices to communicate over serial, or for you to control an i2c bus on a serial console. As usual, you'll note there is a choice of includes. i2cmaster will run only in master mode controlling any number of slave devices. i2cmulti will run in either run as a master or respond as a slave device to whatever address you give in the i2cinit call.

The second example I'm including here has a really simple function Paul wrote to find all i2cdevices attached to your hardware module. It basically sends out a call on the bus and waits for an ack, scanning each address in the address space. If a device responds, it reports that it's found a device at xx address. This one is really useful for figuring out what address you should give to the sendbuf and readbuf commands to talk to your i2c devices. This should be helpful in two ways, one it tells you that you have the hardware hooked up right and two it avoids confusing datasheets. (Anyone familiar with i2c datasheets will know their address are written 3 different ways and 2 of them are wrong depending on who you ask.)

The third example is the probably what 90% of i2c sensor calls will look like. I took some code from our cloud learn article: http://www.netburner.com/learn/sparkfun ... ner-device and distilled it just down to i2c calls using restarts. I've also adapted the code to use the multichanneli2c library I developed a while back for the mcf5441x processors. This will allow you to communicate on any i2c module on the MOD5441x and NANO, of which there are 6, with the ease of using the other libraries.

Hope this helps.
Attachments
i2cexamples.zip
(7.7 KiB) Downloaded 398 times
nicobari
Posts: 110
Joined: Mon Jan 30, 2012 12:15 pm

Re: MOD54415 I2C example code

Post by nicobari »

Thank you very much
Post Reply