<?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: Maple  I2C readregister</title>
		<link>http://forums.leaflabs.com/topic.php?id=1146</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:25:45 +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=1146" rel="self" type="application/rss+xml" />

		<item>
			<title>Farid on "Maple  I2C readregister"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1146#post-7061</link>
			<pubDate>Tue, 01 Nov 2011 03:38:10 +0000</pubDate>
			<dc:creator>Farid</dc:creator>
			<guid isPermaLink="false">7061@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Is the delay time is right?&#60;br /&#62;
#define I2C_DELAY do{for(int i=0;i&#38;lt;50;i++) {asm volatile(&#34;nop&#34;);}}while(0)&#60;br /&#62;
If we use this delay time ,what's the clock fre?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Farid on "Maple  I2C readregister"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1146#post-7060</link>
			<pubDate>Mon, 31 Oct 2011 20:37:40 +0000</pubDate>
			<dc:creator>Farid</dc:creator>
			<guid isPermaLink="false">7060@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I want to use the I2C to communicate,This is my code:&#60;br /&#62;
uint8 TwoWire::readregister(uint8 slave_addr,uint8 reg_addr, uint8 *value) {&#60;br /&#62;
	 uint8 ret = SUCCESS;&#60;br /&#62;
	 if(0 == i2c_init_flag){&#60;br /&#62;
		Wire.begin();&#60;br /&#62;
		i2c_init_flag = 1;&#60;br /&#62;
	}&#60;/p&#62;
&#60;p&#62;	i2c_start(port);&#60;br /&#62;
	 i2c_shift_out(port, (slave_addr &#38;lt;&#38;lt; 1) &#124; I2C_WRITE);&#60;br /&#62;
	 if (!i2c_get_ack(port)) return ENACKADDR;&#60;br /&#62;
	 ret = writeOneByte(reg_addr);&#60;br /&#62;
	 if (ret) return ret;    // SUCCESS is 0&#60;br /&#62;
	 ret= readOneByte(slave_addr, value);&#60;/p&#62;
&#60;p&#62;	 return(ret);&#60;/p&#62;
&#60;p&#62;}&#60;/p&#62;
&#60;p&#62;But when I use this fucntion like this to test the I2C:&#60;/p&#62;
&#60;p&#62;#define DEV_I2C_ADDR 0x18 //0 0 1 1 0 0 X&#60;/p&#62;
&#60;p&#62;void test_I2C()&#60;br /&#62;
{&#60;br /&#62;
	   uint8 value = 0xff;&#60;br /&#62;
	   if(SUCCESS == Wire.readregister(DEV_I2C_ADDR, 0x0C, &#38;amp;value)){&#60;br /&#62;
	       SerialUSB.print(&#34;I2CVALUE=0x&#34;);&#60;br /&#62;
	       SerialUSB.println(value,HEX);&#60;br /&#62;
	       SerialUSB.print(&#34;\r\n&#34;);&#60;br /&#62;
	   }else {&#60;br /&#62;
	       SerialUSB.print(&#34;Read error....&#34;);&#60;br /&#62;
	       SerialUSB.print(&#34;\r\n&#34;);&#60;br /&#62;
	   }&#60;/p&#62;
&#60;p&#62;	   Omni.delayMS(1000);&#60;/p&#62;
&#60;p&#62;}&#60;br /&#62;
The SerialUSB just ouput:I2CVALUE=0x0&#60;br /&#62;
So, anyone can tell me why the result is 0x0?Is my function write correct？&#60;/p&#62;
&#60;p&#62;Many thanks！
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
