<?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: Problems with the i2c api</title>
		<link>http://forums.leaflabs.com/topic.php?id=2601</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:18:15 +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=2601" rel="self" type="application/rss+xml" />

		<item>
			<title>crenn on "Problems with the i2c api"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2601#post-12980</link>
			<pubDate>Wed, 29 Aug 2012 06:52:37 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">12980@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Glad to hear it's working for you ^-^&#60;/p&#62;
&#60;p&#62;The docs reflect the situation with the IDE. v0.0.12 includes the bit banged implementation, however the new Wire library was completed earlier this year. The design of this library was to try to make it as neat and easy as possible to understand. At a later stage, I will be writing another SoftWire implementation which will access the hardware at a lower level, effectively speeding it up.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jonatan.olofsson on "Problems with the i2c api"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2601#post-12977</link>
			<pubDate>Wed, 29 Aug 2012 04:13:06 +0000</pubDate>
			<dc:creator>jonatan.olofsson</dc:creator>
			<guid isPermaLink="false">12977@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I got it working with the HardWire library. Thank you!&#60;/p&#62;
&#60;p&#62;In the docs it says only bitbang i2c is implemented (&#60;a href=&#34;http://leaflabs.com/docs/libraries.html#wire)&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/libraries.html#wire)&#60;/a&#62;, but I see in the code that it's pretty neat now with the WireBase interface.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "Problems with the i2c api"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2601#post-12961</link>
			<pubDate>Tue, 28 Aug 2012 21:19:43 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">12961@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;The problem stems from nack conditions when addressing the slave device, but the device doesn't respond. This behaviour is sort of normal (however it's something which should have a function to automatically either reset the flags it relies on (which could be a bad thing) or reset the peripheral) but annoying. If you're interested HardwareI2C working with minimal hassle (or want to see a 'generic' implementation), take a look at the new Wire library available from here:&#60;br /&#62;
&#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=1033&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=1033&#60;/a&#62;&#60;br /&#62;
or download from here if you're using the IDE:&#60;br /&#62;
&#60;a href=&#34;http://www.crennsmind.com/Code/Maple/Libraries/WireBase/Wire-120630.zip&#34; rel=&#34;nofollow&#34;&#62;http://www.crennsmind.com/Code/Maple/Libraries/WireBase/Wire-120630.zip&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Also, if you're wanting to use the same message, I'd reset xferred to 0 after the transfer.&#60;/p&#62;
&#60;p&#62;The pulsing you describe is when the device has been asserted, it will means the micro-controller has 'crashed'.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jonatan.olofsson on "Problems with the i2c api"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2601#post-12954</link>
			<pubDate>Tue, 28 Aug 2012 10:46:58 +0000</pubDate>
			<dc:creator>jonatan.olofsson</dc:creator>
			<guid isPermaLink="false">12954@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I'm trying to use the libmaple i2c implementation (hardware). The I2C device is currently disconnected, but the SDA and SCL pins are monitored on a logic analyzer.&#60;br /&#62;
I got the same results when the peripheral is connected, although I am not sure it received enough voltage to power up earlier (which is why I disconnected it in the first place).&#60;/p&#62;
&#60;p&#62;What happens is, the first i2c header is sent out correctly followed, of course, by a NAK (as posted on the first image upload service i found, &#60;a href=&#34;http://tinypic.com/view.php?pic=2m3jss9&#38;amp;s=6)&#34; rel=&#34;nofollow&#34;&#62;http://tinypic.com/view.php?pic=2m3jss9&#38;amp;s=6)&#60;/a&#62;. After the initial header of the message is sent, the maple mini enters some state where the LED is glowing with a steady pulse ~ 1-2 Hz.&#60;/p&#62;
&#60;p&#62;One of my thoughts is that I handle bus errors wrongly. I've tried i2c_bus_reset and i2c_master_enable inside the loop to re-enable the bus, but I obviously havn't gotten anything working yet.&#60;/p&#62;
&#60;p&#62;This is a minimal example i've extracted from libmaple/examples/i2c-mcp4725-dac.cpp (is that the only source for API usage doc on i2c?)&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;&#60;code&#62;#include &#38;lt;stdint.h&#38;gt;&#60;br /&#62;
#include &#38;lt;wirish/wirish.h&#38;gt;&#60;br /&#62;
#include &#38;lt;libmaple/i2c.h&#38;gt;&#60;br /&#62;
__attribute__((constructor)) void premain() {&#60;br /&#62;
    init();&#60;br /&#62;
}&#60;br /&#62;
i2c_msg write_msg;&#60;br /&#62;
static uint8 write_msg_data[3];&#60;br /&#62;
void setup() {&#60;br /&#62;
    pinMode(BOARD_LED_PIN, OUTPUT);&#60;br /&#62;
    write_msg.addr = 0x16;&#60;br /&#62;
    write_msg.flags = 0; // write, 7 bit address&#60;br /&#62;
    write_msg.length = sizeof(write_msg_data);&#60;br /&#62;
    write_msg.xferred = 0;&#60;br /&#62;
    write_msg.data = write_msg_data;&#60;br /&#62;
    i2c_master_enable(I2C1, I2C_FAST_MODE &#124; I2C_BUS_RESET);&#60;br /&#62;
}&#60;br /&#62;
void loop() {&#60;br /&#62;
    i2c_master_xfer(I2C1, &#38;amp;write_msg, 1, 100);&#60;br /&#62;
    delay(2000);&#60;br /&#62;
    //~ toggleLED();&#60;br /&#62;
}&#60;br /&#62;
int main(void) {&#60;br /&#62;
    setup();&#60;br /&#62;
    while (true) {&#60;br /&#62;
        loop();&#60;br /&#62;
    }&#60;br /&#62;
    return 0;&#60;br /&#62;
}&#60;/code&#62;&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;Best regards,&#60;br /&#62;
Jonatan
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
