<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: Is there any sample code for hardware i2c implementation in libmaple ?</title>
		<link>http://forums.leaflabs.com/topic.php?id=1195</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:06:21 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=1195" rel="self" type="application/rss+xml" />

		<item>
			<title>poslathian on "Is there any sample code for hardware i2c implementation in libmaple ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1195#post-7738</link>
			<pubDate>Tue, 17 Jan 2012 17:08:04 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">7738@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Make sure that if you are using a hardware i2c implementation, such as Crenn's hardware i2c or the built in i2c.h inside of libmaple that you are using hardware i2c pins (see the silkscreen or pinmap) Hardware i2c will not work on any two pins!&#60;/p&#62;
&#60;p&#62;If you have a shield and the i2c pins just have to be some random non-i2c pins you will have to use a bit banged implementation. There is a fairly simplistic one provided in Wire.h in the IDE, which you can use if you select it from the drop down. that simplistic lib does not support clock stretching.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Is there any sample code for hardware i2c implementation in libmaple ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1195#post-7728</link>
			<pubDate>Tue, 17 Jan 2012 16:26:29 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">7728@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Has anyone tried ST's I2C firmware?&#60;br /&#62;
&#60;a href=&#34;http://www.st.com/stonline/stappl/resourceSelector/app?page=resourceSelector&#38;amp;doctype=FIRMWARE&#38;amp;SubClassID=1169&#34; rel=&#34;nofollow&#34;&#62;http://www.st.com/stonline/stappl/resourceSelector/app?page=resourceSelector&#38;amp;doctype=FIRMWARE&#38;amp;SubClassID=1169&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;There appears to be entire sets of test programs as well as implementations of slave and master libraries.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mikep on "Is there any sample code for hardware i2c implementation in libmaple ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1195#post-7715</link>
			<pubDate>Tue, 17 Jan 2012 09:53:13 +0000</pubDate>
			<dc:creator>mikep</dc:creator>
			<guid isPermaLink="false">7715@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello Greg, is this the code you are referring to?&#60;br /&#62;
&#60;a href=&#34;http://www.eganfamily.id.au/Family/Misc/DemoWire_gke.zip&#34; rel=&#34;nofollow&#34;&#62;http://www.eganfamily.id.au/Family/Misc/DemoWire_gke.zip&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I have not tried it yet, I just wanted to make sure I have the right location.&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Mike
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gke on "Is there any sample code for hardware i2c implementation in libmaple ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1195#post-7714</link>
			<pubDate>Tue, 17 Jan 2012 06:47:05 +0000</pubDate>
			<dc:creator>gke</dc:creator>
			<guid isPermaLink="false">7714@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;My code assumes pullups as the pins are configured open drain to allow the signalling to be turned around from input to output etc without changing the pin mode which takes time. &#60;/p&#62;
&#60;p&#62;It runs at 400KHz on the &#34;Maple&#34; board. The pulse timings are not tuned but it has been tested on several devices on an IMU board and seems to work fine.  The wait clock timeout may be too short for devices using clock stretching. Change the timeout define to be something very large.&#60;/p&#62;
&#60;p&#62;Changing the pin numbers as you have done should work assuming you grabbed the latest version as that uses the pin_map to get to the actual pins. To go fast you need to define DIRECT_PIN_IO from memory. You will see the relevant ifdef in Wire.cpp.&#60;/p&#62;
&#60;p&#62;Greg
&#60;/p&#62;</description>
		</item>
		<item>
			<title>rosendo on "Is there any sample code for hardware i2c implementation in libmaple ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1195#post-7676</link>
			<pubDate>Mon, 16 Jan 2012 00:28:53 +0000</pubDate>
			<dc:creator>rosendo</dc:creator>
			<guid isPermaLink="false">7676@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Obrigado, bubulindo!&#60;/p&#62;
&#60;p&#62;Take your time! I am just a newbie on this area trying to learn how to blink a few more lights (there is no rush!). If, in the future, you could spend some of your spare time making a simple I/O expander control for I2C I would appreciate it.&#60;/p&#62;
&#60;p&#62;Best regards,
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bubulindo on "Is there any sample code for hardware i2c implementation in libmaple ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1195#post-7675</link>
			<pubDate>Mon, 16 Jan 2012 00:16:53 +0000</pubDate>
			<dc:creator>bubulindo</dc:creator>
			<guid isPermaLink="false">7675@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Maybe... I also don't have a mini. &#60;/p&#62;
&#60;p&#62;I'm trying to finish up on a Real Time Clock library, but once I get that going I can have a look and maybe create some code that uses the onboard hardware for i2c. :S &#60;/p&#62;
&#60;p&#62;Actually these are already created and you should access them by including i2c.h. &#60;/p&#62;
&#60;p&#62;I'd have to look into them to see how to use them though.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>rosendo on "Is there any sample code for hardware i2c implementation in libmaple ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1195#post-7674</link>
			<pubDate>Sun, 15 Jan 2012 23:06:41 +0000</pubDate>
			<dc:creator>rosendo</dc:creator>
			<guid isPermaLink="false">7674@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Sorry, I don't have an oscilloscope. I tried the same program, putting a delay(20) between each of the functions and still it blinks once and stops.&#60;/p&#62;
&#60;p&#62;Any of you guys have a working I2C program (anything where you begin, send data and then end) successfully written to Maple Mini? My scheme is exactly like that homepage says, the only difference is that instead of an Arduino there is a Maple mini using pins 15 and 16, then ground and 3.3. (I tried arduino with 3.3 instead of 5V, and it worked too).&#60;/p&#62;
&#60;p&#62;bubulindo, thanks for your replies! Maybe there is some issue with the pins nomenclature inside the library.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bubulindo on "Is there any sample code for hardware i2c implementation in libmaple ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1195#post-7672</link>
			<pubDate>Sun, 15 Jan 2012 21:54:30 +0000</pubDate>
			<dc:creator>bubulindo</dc:creator>
			<guid isPermaLink="false">7672@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hmmm, I just noticed that the pins are written to HIGH, so you shouldn't need the pull ups.&#60;/p&#62;
&#60;p&#62;You can start the I2C with: &#60;/p&#62;
&#60;p&#62;void TwoWire::begin(uint8 sda, uint8 scl) {&#60;/p&#62;
&#60;p&#62;and define the pins. These are however, bitbang implementations. :\ is it the same with Arduino? &#60;/p&#62;
&#60;p&#62;Is your configuration of the MCP correct? &#60;/p&#62;
&#60;p&#62;The other only thing that I see that could influence this is the speed of the bus. &#60;/p&#62;
&#60;p&#62;Have you put an oscilloscope on the lines to see the clock frequency? Maybe the Maple is running too fast for the MCP to catch it? The Arduino is running much slower for sure, so that could be your issue. Also, with high frequencies you run into signal degradation, which could also be the problem here.&#60;br /&#62;
Can you check the waves for us?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>rosendo on "Is there any sample code for hardware i2c implementation in libmaple ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1195#post-7671</link>
			<pubDate>Sun, 15 Jan 2012 20:13:30 +0000</pubDate>
			<dc:creator>rosendo</dc:creator>
			<guid isPermaLink="false">7671@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks for the reply bubulindo,&#60;/p&#62;
&#60;p&#62;I have the same I2C code on both boards (arduino and maple). For reference, this I2C control code is in &#60;a href=&#34;http://tronixstuff.wordpress.com/2011/08/26/tutorial-maximising-your-arduinos-io-ports/&#34; rel=&#34;nofollow&#34;&#62;http://tronixstuff.wordpress.com/2011/08/26/tutorial-maximising-your-arduinos-io-ports/&#60;/a&#62; :&#60;/p&#62;
&#60;p&#62;/*&#60;br /&#62;
 Example 41.1 - Microchip MCP23017 with Arduino&#60;br /&#62;
 &#60;a href=&#34;http://tronixstuff.wordpress.com/tutorials&#34; rel=&#34;nofollow&#34;&#62;http://tronixstuff.wordpress.com/tutorials&#60;/a&#62; &#38;gt; chapter 41&#60;br /&#62;
 John Boxall &#124; CC by-sa-nc&#60;br /&#62;
*/&#60;/p&#62;
&#60;p&#62;// pins 15~17 to GND, I2C bus address is 0x20&#60;/p&#62;
&#60;p&#62;#include &#34;Wire.h&#34;&#60;/p&#62;
&#60;p&#62;void setup()&#60;br /&#62;
{&#60;br /&#62;
  Wire.begin(); // wake up I2C bus&#60;/p&#62;
&#60;p&#62;  // setup addressing style&#60;br /&#62;
  Wire.beginTransmission(0x20);&#60;br /&#62;
  Wire.send(0x12);&#60;br /&#62;
  Wire.send(0x20); // use table 1.4 addressing&#60;br /&#62;
  Wire.endTransmission();&#60;/p&#62;
&#60;p&#62;  // set I/O pins to outputs&#60;br /&#62;
  Wire.beginTransmission(0x20);&#60;br /&#62;
  Wire.send(0x00); // IODIRA register&#60;br /&#62;
  Wire.send(0x00); // set all of bank A to outputs&#60;br /&#62;
  Wire.send(0x00); // set all of bank B to outputs&#60;br /&#62;
  Wire.endTransmission();&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void binaryCount()&#60;br /&#62;
{&#60;br /&#62;
  for (byte a=0; a&#38;lt;256; a++)&#60;br /&#62;
  {&#60;br /&#62;
    Wire.beginTransmission(0x20);&#60;br /&#62;
    Wire.send(0x12); // GPIOA&#60;br /&#62;
    Wire.send(a);    // bank A&#60;br /&#62;
    Wire.send(a);    // bank B&#60;br /&#62;
    Wire.endTransmission();&#60;br /&#62;
    delay(100);&#60;br /&#62;
  }&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void loop()&#60;br /&#62;
{&#60;br /&#62;
  binaryCount();&#60;br /&#62;
  delay(500);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;How can I make it work on Maple Mini? As I said before, I already changed the SDA and SCL ports at the wire library. I set the address to ground from A0 to A2, and I am using the 4.7K resistor suggested by that homepage. Arduino works fine, but with maple it blinks once and then it stops.&#60;/p&#62;
&#60;p&#62;Would be amazing if anybody could help me... Best regards!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bubulindo on "Is there any sample code for hardware i2c implementation in libmaple ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1195#post-7633</link>
			<pubDate>Fri, 13 Jan 2012 22:42:39 +0000</pubDate>
			<dc:creator>bubulindo</dc:creator>
			<guid isPermaLink="false">7633@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;On my Maple IDE I have the Wire library. I haven't tested it yet though. &#60;/p&#62;
&#60;p&#62;From the looks of it you need to put some pull ups on the I2C interface since the begin function sets the outputs at open drain. I believe Arduino does this for you, but here I'm not exactly sure if you can do the same on the Maple.&#60;/p&#62;
&#60;p&#62;Give it a go with external pull ups and see if you get something different. &#60;/p&#62;
&#60;p&#62;Like I said, I haven't tested this yet. I do have that Microchip at my place, but I'll only be there in two weeks time. If you haven't fixed it by then I can give it a go.  &#60;/p&#62;
&#60;p&#62;I think SPI may have the same pull up issue. I can't see any other thing wrong without starting to troubleshoot. :(
&#60;/p&#62;</description>
		</item>
		<item>
			<title>rosendo on "Is there any sample code for hardware i2c implementation in libmaple ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1195#post-7632</link>
			<pubDate>Fri, 13 Jan 2012 20:23:28 +0000</pubDate>
			<dc:creator>rosendo</dc:creator>
			<guid isPermaLink="false">7632@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;It has been a month and no reply, so I think I will bump this one, adding:&#60;/p&#62;
&#60;p&#62;Recently I bought a maple mini and decided to expand the IO with I2C or SPI. Initially trying with SPI, I noticed that it would be more complicated than I thought because MCP23S17 requires some SPI address (which I set!), but due to my inferior skills I convince SPI to send an address. I'll put that on hold.&#60;/p&#62;
&#60;p&#62;However, what really surprised me was not being able to control MCP23017 (the I2C) version, so if anybody could help me (I can control this bad boy from Arduino) I just need to know 4 functions on Maple MINI:&#60;/p&#62;
&#60;p&#62;Wire.begin()                     &#38;lt;--- Or something that wakes up I2C&#60;br /&#62;
Wire.beginTransmission(address)  &#38;lt;--- Or something to start the transmission&#60;br /&#62;
Wire.send(data)                  &#38;lt;--- Or something to send data&#60;br /&#62;
Wire.endTransmission()           &#38;lt;--- Or something to end the transmission&#60;/p&#62;
&#60;p&#62;On Arduino I use these and I can write anything to the IO expander, but on Maple it doesn't work. I tried the original Wire library, Crenn's and Gke's library. Inside the library I tried changing SDA and SCL from 20-21 to 15-16, but nothing... Did I miss anything?&#60;/p&#62;
&#60;p&#62;Sorry for my lack of knowledge, but I already gave up on SPI... giving up on I2C will be too much!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>librae8226 on "Is there any sample code for hardware i2c implementation in libmaple ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1195#post-7263</link>
			<pubDate>Wed, 30 Nov 2011 07:01:54 +0000</pubDate>
			<dc:creator>librae8226</dc:creator>
			<guid isPermaLink="false">7263@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi Leaflabs guys,&#60;/p&#62;
&#60;p&#62;Recently I am trying to use i2c communication based on libmaple (C library), but I didn't find a proper way to use the i2c API.&#60;br /&#62;
my code is like:&#60;br /&#62;
    ------&#60;br /&#62;
    i2c_init(I2C1);&#60;br /&#62;
    i2c_master_enable(I2C1, I2C_FAST_MODE);&#60;br /&#62;
    i2c_master_xfer(I2C1, &#38;amp;msg, 1, 200);&#60;/p&#62;
&#60;p&#62;But it seems not working.&#60;/p&#62;
&#60;p&#62;By the way, doesn't libmaple implement i2c slave? I would like to make two maple boards communicating via i2c, but didn't find the APIs for slave :P&#60;/p&#62;
&#60;p&#62;Thanks.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
