<?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: Official Wire &#38; I2C Libraries</title>
		<link>http://forums.leaflabs.com/topic.php?id=1255</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:20:20 +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=1255" rel="self" type="application/rss+xml" />

		<item>
			<title>crenn on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255&amp;page=2#post-10764</link>
			<pubDate>Sun, 20 May 2012 03:24:12 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">10764@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi gke,&#60;/p&#62;
&#60;p&#62;I've been working on the new Wire library lately and I'm wondering if I can pull some of your changes into the software side of the library, mainly to speed up the library (and fix some issues). Not sure if you're still around the forums, but I'll see if I can't grab your attention via youtube as well.&#60;/p&#62;
&#60;p&#62;Regards,&#60;br /&#62;
crenn.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gke on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255&amp;page=2#post-7601</link>
			<pubDate>Thu, 12 Jan 2012 19:18:20 +0000</pubDate>
			<dc:creator>gke</dc:creator>
			<guid isPermaLink="false">7601@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks. I will probably step back a bit from the Wire stuff to get board maps and STM32F4 stuff done. I will update (10 minutes) the Wire.zip file which now uses PIN_MAP rather than the explicit pin numbers. Still ugly but better than it was. The i2c routines probably should be in their own class but ....&#60;/p&#62;
&#60;p&#62;Greg
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255&amp;page=2#post-7587</link>
			<pubDate>Thu, 12 Jan 2012 06:52:37 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">7587@http://forums.leaflabs.com/</guid>
			<description>&#60;blockquote&#62;&#60;p&#62;Unfortunately, the I2C on STM32F1xx is a bit weird. If you glance at the Revision History at the back of the RM0008 manual for the STM32F1xx, pretty much every one of the 14 document revisions contain changes and clarification on the I2C peripheral. I think Crenn is very likely the most knowledgeable I2C contributor, ahead of the official library.&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;Perry is possibly the best one to talk to about I2C as he did the low level I2C implementation I do believe which is what I'm using. I don't fully understand the limitations of the I2C peripheral as I haven't read through the the errata sheet fully.&#60;/p&#62;
&#60;p&#62;I also haven't been around as moving out is taking longer than I thought and now that I'm mostly moved out (there is a bit more coming this weekend which signals the end of the 'big move'), I'll be getting around to trying to rewrite the Wire implementation, although I'll probably be referring back to this thread when the Software Wire implementation is completed.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gke on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255&amp;page=2#post-7581</link>
			<pubDate>Wed, 11 Jan 2012 23:11:09 +0000</pubDate>
			<dc:creator>gke</dc:creator>
			<guid isPermaLink="false">7581@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;&#60;a href=&#34;http://www.eganfamily.id.au/Family/Misc/Wire.zip&#34; rel=&#34;nofollow&#34;&#62;http://www.eganfamily.id.au/Family/Misc/Wire.zip&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;The pulse timing probably needs some checking but later ...
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gke on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255&amp;page=2#post-7580</link>
			<pubDate>Wed, 11 Jan 2012 21:17:32 +0000</pubDate>
			<dc:creator>gke</dc:creator>
			<guid isPermaLink="false">7580@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks poslathian. Still tunneling into the libraries etc but I was trying to stay up in the IDE layer otherwise I may as well just drop all the way down to the STM libraries.&#60;/p&#62;
&#60;p&#62;@gbulmer. Yes it was the software I2C/Wire I was interested in. The revised Wire.{cpp,h} are running at 400KHz with gpio calls and at about 280KHz with digital read/writes.  Not interested in the I2C hardware as my app has nothing else to do while reading sensors etc.&#60;/p&#62;
&#60;p&#62;Hopefully another iteration today. Other duties are distracting me :).&#60;/p&#62;
&#60;p&#62;Greg
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255&amp;page=2#post-7558</link>
			<pubDate>Wed, 11 Jan 2012 12:01:24 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">7558@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;gke - regarding you post about good old makefiles - we could not agree more. The IDE and the maple &#34;toolchain&#34; are pretty decoupled, and you can use Maple just as effectively using make + your favorite editor. Check out &#60;a href=&#34;http://leaflabs.com/docs/unix-toolchain.html&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/unix-toolchain.html&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Regarding the overhead associated with this or that call (like digitalWrite). We went as far as we thought reasonable in stripping out random overhead. For example, on some platforms calls to digitalWrite check the pinMode and other crap every time. But at the end of the day, the wirish library, which is the high level Arduino stuff, is designed for usability. The lightweight, powerful stuff is underneath in a library called libmaple, which you are more than welcome to use! &#60;/p&#62;
&#60;p&#62;Feel free to browse all the code here: &#60;a href=&#34;http://github.com/leaflabs/libmaple/&#34; rel=&#34;nofollow&#34;&#62;http://github.com/leaflabs/libmaple/&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255#post-7539</link>
			<pubDate>Mon, 09 Jan 2012 20:09:58 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">7539@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;gke - maybe I have misunderstood the issue. I thought you were having problems getting the soft I2C interface to run fast enough.&#60;/p&#62;
&#60;p&#62;It looks the speed of DemoWire_gke, i.e the speed of the soft I2C interface, is dominated by the speed of &#60;code&#62;Wire.endTransmission()&#60;/code&#62; which actually does the work to shift the bits.&#60;/p&#62;
&#60;p&#62;&#60;code&#62;Wire.endTransmission()&#60;/code&#62; appears to be dominated by i2c_shift_out and its sibling functions (e.g. i2c_get_ack)&#60;/p&#62;
&#60;p&#62;They use digitalWrite, so they are the ones that need improving.&#60;br /&#62;
None of the changes I can see in the zip file &#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; change those functions, so (applying Amdahl's Law) nothing else will cause much of a change.&#60;br /&#62;
What have I missed?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gke on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255#post-7535</link>
			<pubDate>Mon, 09 Jan 2012 16:12:00 +0000</pubDate>
			<dc:creator>gke</dc:creator>
			<guid isPermaLink="false">7535@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi ala2,&#60;/p&#62;
&#60;p&#62;My edit was a little off. It is now working with your suggestion and up to 360KHz so we are getting closer to 400KHz :).&#60;/p&#62;
&#60;p&#62;Thanks&#60;br /&#62;
Greg&#60;/p&#62;
&#60;p&#62;#define I2CSDALow {gpio_write_bit(&#38;amp;gpioc, 5, 0);SCLLowPadT;}&#60;br /&#62;
#define I2CSDAFloat {gpio_write_bit(&#38;amp;gpioc, 5, 1);SCLLowPadT;}&#60;br /&#62;
#define I2CSCLLow {gpio_write_bit(&#38;amp;gpioc, 13, 0);}&#60;br /&#62;
#define I2CSCLFloat {gpio_write_bit(&#38;amp;gpioc, 13, 1);SCLHighT;}
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255#post-7534</link>
			<pubDate>Mon, 09 Jan 2012 12:27:18 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">7534@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;gke - Is this really not getting over 200KHz?&#60;br /&#62;
Is it correct to assume most of the problems are in the actual bit bashing like i2c_shift_out, i2c_shift_in, etc?&#60;/p&#62;
&#60;p&#62;If those are the problem areas, it looks like you're going to need faster versions of:&#60;br /&#62;
- digitalWrite&#60;br /&#62;
- digitalRead&#60;br /&#62;
- pinMode&#60;/p&#62;
&#60;p&#62;You might be able to save a bit of work by 'global edit and replace' those into the base functions like &#60;code&#62;i2c_shift_out&#60;/code&#62;, maybe use some macro-bashing:&#60;br /&#62;
e.g.&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;#define SDAPIN (20)
#define SCLPIN (21)
#define SDAPINFAST ... // bit band address
#define SCLPINFAST ... //bit band address
#define SDAPIN_DDIR ... // data direction stuff
...
#define myDigitalWrite(pin, val) if (pin==SDAPIN) {fastDigitalWrite(SDAPINFAST, val);} \
            else if (pin==SCLPIN) {fastDigitalWrite(SCLPINFAST, val);} else digitalWrite(pin, val);
... // etc&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;(I'm avoiding thinking about the state of education today, :-(
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gke on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255#post-7533</link>
			<pubDate>Sun, 08 Jan 2012 23:04:11 +0000</pubDate>
			<dc:creator>gke</dc:creator>
			<guid isPermaLink="false">7533@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks ala42.  I did try what you suggested but the lines need to be flipped from input to output mode it seems just as on the original PIC processor. If you do a read port on one that is set to output you get the output register value not the input.&#60;/p&#62;
&#60;p&#62;@gbulmer I lived in Manchester UK for several years and our kids experienced primary in 1994 when we were there again on sabbatical. Yes it is a shambles and I find it depressing when I visit which to date has been often. The rapidly growing layer cake is now so widespread I believe it may be impossible to reverse. Why put down to conspiracy what can be explained by simple (or is that complex) incompetence.&#60;/p&#62;
&#60;p&#62;Cheers&#60;br /&#62;
Greg
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ala42 on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255#post-7527</link>
			<pubDate>Sun, 08 Jan 2012 15:11:06 +0000</pubDate>
			<dc:creator>ala42</dc:creator>
			<guid isPermaLink="false">7527@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Had a short look at your code:&#60;/p&#62;
&#60;p&#62;#define I2CSDALow {digitalWrite(this-&#38;gt;SDAPin, LOW);pinMode(this-&#38;gt;SDAPin, OUTPUT_OPEN_DRAIN);SCLLowPadT;}&#60;br /&#62;
#define I2CSDAFloat {pinMode(this-&#38;gt;SDAPin, INPUT);SCLLowPadT;}&#60;br /&#62;
#define I2CSCLLow {digitalWrite(this-&#38;gt;SCLPin, LOW);pinMode(this-&#38;gt;SCLPin, OUTPUT_OPEN_DRAIN);}&#60;br /&#62;
#define I2CSCLFloat {pinMode(this-&#38;gt;SCLPin, INPUT);SCLHighT;}&#60;/p&#62;
&#60;p&#62;Very bad idea to set the pin mode each time. Set both lines to OUTPUT_OPEN_DRAIN once and touch them never again.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255#post-7526</link>
			<pubDate>Sun, 08 Jan 2012 10:12:31 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">7526@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Greg -&#60;br /&#62;
&#60;blockquote&#62;... The number of people who know what is inside the various boxes on which we depend is falling. In Australia we have dropped to less than 50% choosing Science subjects in school prior to applying for a university place. The subjects are not weighted by difficulty in calculated their score so softer options are preferred.&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;&#60;em&#62;Start Rant:&#60;/em&#62;&#60;/p&#62;
&#60;p&#62;The UK school system is even more &#34;ingeniously&#34; damaging than that. What we do is rank schools on the exam marks achieved by the children, and give rewards to the school and staff based on improving that rank. Those ranks are published every year for all to see. So a Head Teacher must improve the numbers. AFAIK, if they don't, they get replaced.&#60;/p&#62;
&#60;p&#62;We have also gone away from the old exam marking system which deliberately assumed a 'normal' distribution on exam marks, and adjusted marks across subjects to align all subjects and across years. Instead we use the raw exam score. This allows the possibility that students can get higher marks every year (which has happened in the UK since the late '90's), and makes comparison across subjects harder. Hence it reduces the apparent need for rigourous comparison of performance across years (marks are improving!), makes it harder to do anyway, and allows governments to claim they have improved education standards. Genius!&#60;/p&#62;
&#60;p&#62;Because schools are ranked by these exam results, they have a pretty easy algorithm to improve rank; if one subject gives a higher average exam mark, the school encourages pupils to take that subject, and if another subject gets poorer averages, then that subject just gets dropped.  This has happened to Electronics A-Level in my area; there are no state schools teaching it, and the teacher I know has taken early retirement, so it is almost irrevocable.&#60;/p&#62;
&#60;p&#62;I often say to people, if you believed in conspiracies, and were to conceive of a very simple, low cost way, to cripple a country, what would you do? I think you'd tinker with its educational system in exactly the way we have. Over the long term it destroys its industrial base; either the science and technology subjects get very easy, to compete for students - bad - or the subjects get dropped - very bad.&#60;/p&#62;
&#60;p&#62;Of course, I am &#60;strong&#62;not&#60;/strong&#62; suggesting we have any conspiracy. When human incompetence and greed (money or power) are sufficient to explain something, then there is no need to suggest a conspiracy.&#60;/p&#62;
&#60;p&#62;&#60;em&#62;End Rant&#60;/em&#62;&#60;/p&#62;
&#60;p&#62;I'll try to have a look at your I2C, but I need to get something to eat :-)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gke on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255#post-7524</link>
			<pubDate>Sun, 08 Jan 2012 02:47:45 +0000</pubDate>
			<dc:creator>gke</dc:creator>
			<guid isPermaLink="false">7524@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Yes I agree that IDEs like Maple and Arduino are an easy entry point for newbie's and also for those a little older. The number of people who know what is inside the various boxes on which we depend is falling. In Australia we have dropped to less than 50% choosing Science subjects in school prior to applying for a university place. The subjects are not weighted by difficulty in calculated their score so softer options are preferred.&#60;/p&#62;
&#60;p&#62;As promised my VERY rough cut of the code with timings in comments are at:&#60;/p&#62;
&#60;p&#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 only just graduated to &#34;classes&#34; so bear with me. My favourite language was Pascal and my forced use of C was quite recent. I had avoided them to date as I was not comfortable with what the compiler may be doing to instantiate them. It is also entirely possible that I have missed something simple of course resulting in the low I2C clocking rates :).&#60;/p&#62;
&#60;p&#62;My app is using the STM32F4 so I do need to do a little work to knit those in.&#60;/p&#62;
&#60;p&#62;I will look at crenna's code again tonight.&#60;/p&#62;
&#60;p&#62;Cheers&#60;br /&#62;
Greg
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255#post-7518</link>
			<pubDate>Sat, 07 Jan 2012 13:44:23 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">7518@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Free IDEs are important to me because I spend time encouraging non-programmers to get into programming. I believe it is extremely important that people understand the underpinning technology of our modern world. I am a STEM ambassador in schools, but also run events for adults. It is also critical to me that people can continue beyond those experiences, and propagate their enthusiasm without cost or constraint.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;It would be good to know what Arduino are going to do for their Due Arm environment.&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;I assume, the Arduino IDE will remain largely the same, but the libraries and examples will be upgraded.&#60;br /&#62;
The underlying compiler and linker toolchain will be based on one of the Open Source packages built around GNU's gcc ARM variant, (probably CodeSourcery or YAGARTO?).&#60;/p&#62;
&#60;p&#62;IMHO LeafLabs do a pretty good job of bundling up a decent ARM toolchain within the Maple IDE. IIRC, several people have posted on these forums that they have used the toolchain under other IDEs.&#60;/p&#62;
&#60;p&#62;It is quite likely that the IDE and raw toolchain, except for the loader, will work with Maple, Mbed, Olimexuino, PSoC5, TI...&#60;br /&#62;
Of course, the peripheral libraries contain a lot of manufacturer and device specific work, and AFAIK, ARM's CMSIS hasn't been completed. IMHO CMSIS is a bid daunting for beginners, so it is less attractive than the Wiring/Maple libraries for my purposes.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gke on "Official Wire &#38; I2C Libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1255#post-7515</link>
			<pubDate>Sat, 07 Jan 2012 07:38:20 +0000</pubDate>
			<dc:creator>gke</dc:creator>
			<guid isPermaLink="false">7515@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I have spent the day off looking at other tool chains including those from companies charging upwards of $10K for what is just connecting up gcc and a few other tools. Underneath it is the good old Makefile hierarchy to glue it all together. 40th Anniversary of Unix just rolled over so ...&#60;/p&#62;
&#60;p&#62;Like you (GBulmer) the Arduino like IDEs are attractive and even more so because they are free and thus can be used by those to which source code can be distributed - in this case UAVX one of the zillion or so multicopter control codes out there. Nice fun hardish real-time control environment.&#60;/p&#62;
&#60;p&#62;Your observations are right on the money and it seems we have a similar background.   Mine was in the area of parallel processing (dataflow/datadriven architectures) back in the 70s way way when parallel architectures were not at all excepted. I am comfortable working from the &#34;electrons&#34; up to the compiler construction etc. As you say lots of eyes looking but not many of us who are happy floating up and down through the abstraction layers.&#60;/p&#62;
&#60;p&#62;It would be good to know what Arduino are going to do for their Due Arm environment.&#60;/p&#62;
&#60;p&#62;As for my quick I2C hack. I will post some fragments tomorrow  - late here and the code is on the only PC in the house upstairs. The delays that were in on the mbed are all commented out. Timing was done using a Salae analyser.&#60;/p&#62;
&#60;p&#62;Cheers&#60;br /&#62;
Greg
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
