<?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: found some bugs in the libraries</title>
		<link>http://forums.leaflabs.com/topic.php?id=756</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:09:51 +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=756" rel="self" type="application/rss+xml" />

		<item>
			<title>mbolivar on "found some bugs in the libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=756&amp;page=2#post-4486</link>
			<pubDate>Wed, 04 May 2011 15:53:52 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">4486@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;ala42,&#60;/p&#62;
&#60;p&#62;Thanks for the reports!  I'll respond to your points individually.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;
micros() is not counter underrun safe:
&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;Fixed, thank you:&#60;br /&#62;
&#60;a href=&#34;https://github.com/leaflabs/libmaple/commit/bc745cd913006dae7b54074b5ed25323fca05e40&#34; rel=&#34;nofollow&#34;&#62;https://github.com/leaflabs/libmaple/commit/bc745cd913006dae7b54074b5ed25323fca05e40&#60;/a&#62;&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;
The Print class has a bug in the function printing binary values, which uses fillBinary:
&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;The Print class was rewritten (in refactor); fillBinary() no longer exists:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://github.com/leaflabs/libmaple/commit/f72d2948a8daec00b4090fb8b80e8cfe6377100d&#34; rel=&#34;nofollow&#34;&#62;https://github.com/leaflabs/libmaple/commit/f72d2948a8daec00b4090fb8b80e8cfe6377100d&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I'm working on merging refactor into master tonight, in order to release a beta for libmaple 0.0.10.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;
The Wire I2C code has some problems.
&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;Yes, we wrote that code in a hurry to get something mostly working out.  As anton said, the new hardware I2C implementation in the refactor branch seems to work well.  We'll be redoing Wire in terms of libmaple/i2c.h for 0.1.0; I've just added an issue so you can track our progress:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://code.google.com/p/leaflabs/issues/detail?id=65&#34; rel=&#34;nofollow&#34;&#62;http://code.google.com/p/leaflabs/issues/detail?id=65&#60;/a&#62;&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;
The compiler options in libmaple\Makefile are bad. GLOBAL_CFLAGS misses -Wall, so you do not see the potential compiling problems of the library.
&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;I tried using -Wall a while ago, but got sick of seeing warnings due to the ST firmware library code in libmaple/usb/.  We have a ticket to rewrite the USB stack for release 0.1.0:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://code.google.com/p/leaflabs/issues/detail?id=10#c7&#34; rel=&#34;nofollow&#34;&#62;http://code.google.com/p/leaflabs/issues/detail?id=10#c7&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I'm planning to add -Wall at that time.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>anton on "found some bugs in the libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=756&amp;page=2#post-4481</link>
			<pubDate>Tue, 03 May 2011 21:56:39 +0000</pubDate>
			<dc:creator>anton</dc:creator>
			<guid isPermaLink="false">4481@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;redfox74, if your code is too fast to read acc on every loop you can use something like this:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;setup()
{
    AskForAccData();
    .....
}

loop()
{
uint Nloop = 0;
   .....
    if(Nloop % 5 == 0) {
        UseAccData();
        AskForAccData();
    }
    ....
    Nloop++;
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>ridgebackred on "found some bugs in the libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=756&amp;page=2#post-4480</link>
			<pubDate>Tue, 03 May 2011 18:33:19 +0000</pubDate>
			<dc:creator>ridgebackred</dc:creator>
			<guid isPermaLink="false">4480@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;redfox74 - I had not planned to post DiscoveryFlyer005 with BMA180 until I had a few more hours of flight time (approx 4 hours flight time on this revision) and cleaned up the looks.&#60;br /&#62;
I have not timed the loop... I just fly to check performance. No freeze problems ever.&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://snipt.net/ridgebackred/discoveryflyer005&#34; rel=&#34;nofollow&#34;&#62;http://snipt.net/ridgebackred/discoveryflyer005&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>redfox74 on "found some bugs in the libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=756&amp;page=2#post-4479</link>
			<pubDate>Tue, 03 May 2011 17:24:39 +0000</pubDate>
			<dc:creator>redfox74</dc:creator>
			<guid isPermaLink="false">4479@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@ridgebackred&#60;br /&#62;
are you check how many micros need to read from i2c the acc ? in my code to solve the problem of freeze .. i add 1 millis delay .. but the main cicle is more slow respect of full speed ... Do you have an example of code ? What i2c lib using ? what revision can you post to me last update ? So i can check if the freeze problem solveed .&#60;br /&#62;
Best&#60;br /&#62;
Roberto
&#60;/p&#62;</description>
		</item>
		<item>
			<title>redfox74 on "found some bugs in the libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=756&amp;page=2#post-4478</link>
			<pubDate>Tue, 03 May 2011 17:22:12 +0000</pubDate>
			<dc:creator>redfox74</dc:creator>
			<guid isPermaLink="false">4478@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@Ala42,&#60;br /&#62;
where is the AQ code for Maple ? Are you post on AQ repo ?&#60;br /&#62;
What kind of approach for rc reciver ?&#60;br /&#62;
are you implemented also adxl345 acc on i2c ?&#60;br /&#62;
Best&#60;br /&#62;
Roberto
&#60;/p&#62;</description>
		</item>
		<item>
			<title>anton on "found some bugs in the libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=756#post-4476</link>
			<pubDate>Mon, 02 May 2011 22:38:35 +0000</pubDate>
			<dc:creator>anton</dc:creator>
			<guid isPermaLink="false">4476@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;ala42, here was patch for clock stretching&#60;br /&#62;
&#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=28&#38;amp;page=2#post-1301&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=28&#38;amp;page=2#post-1301&#60;/a&#62;&#60;br /&#62;
Can you give link to or post here your reciever class?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ridgebackred on "found some bugs in the libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=756#post-4467</link>
			<pubDate>Mon, 02 May 2011 07:55:05 +0000</pubDate>
			<dc:creator>ridgebackred</dc:creator>
			<guid isPermaLink="false">4467@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;ala42 - Big grin and tail wags!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ala42 on "found some bugs in the libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=756#post-4465</link>
			<pubDate>Mon, 02 May 2011 04:43:22 +0000</pubDate>
			<dc:creator>ala42</dc:creator>
			<guid isPermaLink="false">4465@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I have done a full port including a new timer capture based receiver class, but have not rebuild my quad, yet.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ridgebackred on "found some bugs in the libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=756#post-4463</link>
			<pubDate>Sun, 01 May 2011 23:27:27 +0000</pubDate>
			<dc:creator>ridgebackred</dc:creator>
			<guid isPermaLink="false">4463@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;ala42 - I've been using the i2c hardware based library in the refactor branch instead of the what I am assuming is bit banging code in the Wire library. I ported the BMA180 accelerometer initialization sequence from AeroQuad.com. It's been solid as a rock at 400khz for a couple of days now in less than laboratory settings... Are you doing a full port of AeroQuad into libmaple?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ala42 on "found some bugs in the libraries"</title>
			<link>http://forums.leaflabs.com/topic.php?id=756#post-4462</link>
			<pubDate>Sun, 01 May 2011 19:20:06 +0000</pubDate>
			<dc:creator>ala42</dc:creator>
			<guid isPermaLink="false">4462@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;while porting the Arduino based AeroQuad software to the Maple libraries I found some bugs and other problems:&#60;br /&#62;
micros() is not counter underrun safe:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;static inline uint32 micros(void) {
    uint32 ms;
    uint32 cycle_cnt;
    uint32 res;

    nvic_globalirq_disable();

    cycle_cnt = systick_get_count();
    ms = millis();

    nvic_globalirq_enable();

    /* SYSTICK_RELOAD_VAL is 1 less than the number of cycles it
       actually takes to complete a SysTick reload */
    res = (ms * US_PER_MS) +
        (SYSTICK_RELOAD_VAL + 1 - cycle_cnt)/CYCLES_PER_MICROSECOND;

    return res;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Nice try, but you can not prevent a hardware counter to count by blocking interrupts. When the counter reaches 0 while the interrupts are blocked, the value returned by millis() is not yet incremented, so the returned value is wrong by a millisecond. This code works:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;static inline uint32 micros(void) {
    uint32 ms;
    uint32 cycle_cnt;
    uint32 res;

    do {
      ms = millis();
      cycle_cnt = systick_get_count();
    } while(ms != millis());

    /* SYSTICK_RELOAD_VAL is 1 less than the number of cycles it
       actually takes to complete a SysTick reload */
    res = (ms * US_PER_MS) +
        (SYSTICK_RELOAD_VAL + 1 - cycle_cnt)/CYCLES_PER_MICROSECOND;

    return res;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;The Print class has a bug in the function printing binary values, which uses fillBinary:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;static void fillBinary(char *buf, int64 n, int start_bit) {
    int b = 0;                // position in buf
    int i = start_bit;        // position in n&#38;#39;s bits
    while(!(n &#38;amp; (1 &#38;lt;&#38;lt; i))) {
        i--;
    }
    for(; i &#38;gt;= 0; i--) {
        buf[b++] = &#38;#39;0&#38;#39; + ((n &#38;gt;&#38;gt; i) &#38;amp; 0x1);
    }
    buf[b] = &#38;#39;&#38;#39;;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;With n=0 the expression &#60;code&#62;!(n &#38;amp; (1 &#38;lt;&#38;lt; i))&#60;/code&#62; is always true, so the while loop loops forever. Use this instead:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;while(i&#38;gt;0 &#38;amp;&#38;amp; !(n &#38;amp; (1 &#38;lt;&#38;lt; i))) {&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;The Wire I2C code has some problems. It does not support clock stretching. It has a major problem when receiving multiple bytes, so it does not work with a ITG-3200 gyro. I will post the fixed code when tuning is done.&#60;/p&#62;
&#60;p&#62;The compiler options in libmaple\Makefile are bad. GLOBAL_CFLAGS misses -Wall, so you do not see the potential compiling problems of the library.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
