<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[I2C主从机]]></title><description><![CDATA[<p>请问能否提供一个I2C主从机使用的demo，可以测试用的？</p>
]]></description><link>http://www.freqchip.net:4567/topic/630/i2c主从机</link><generator>RSS for Node</generator><lastBuildDate>Sun, 08 Mar 2026 16:34:13 GMT</lastBuildDate><atom:link href="http://www.freqchip.net:4567/topic/630.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 22 Nov 2022 06:35:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to I2C主从机 on Invalid Date]]></title><description><![CDATA[<p>请问能否提供一个I2C主从机使用的demo，可以测试用的？</p>
]]></description><link>http://www.freqchip.net:4567/post/1309</link><guid isPermaLink="true">http://www.freqchip.net:4567/post/1309</guid><dc:creator><![CDATA[hulyi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to I2C主从机 on Invalid Date]]></title><description><![CDATA[<p>examples\none_evm\ble_drivers_demo\proj 下#include &quot;driver_system.h&quot;<br />
#include &quot;driver_iomux.h&quot;</p>
<p>#include &quot;driver_iic.h&quot;<br />
static const uint8_t LSM6DS33_ADDR = (0x6B&lt;&lt;1);<br />
void demo_i2c(void)<br />
{<br />
uint8_t i2c_test_no = 0;<br />
uint8_t buff1[6];<br />
uint8_t buff2[6];<br />
co_printf(&quot;IIC demo\r\n&quot;);</p>
<pre><code>system_set_port_mux(GPIO_PORT_D, GPIO_BIT_6, PORTD6_FUNC_I2C1_CLK);//Pc6
system_set_port_mux(GPIO_PORT_D, GPIO_BIT_7, PORTD7_FUNC_I2C1_DAT);//Pc7
system_set_port_pull( (GPIO_PD6|GPIO_PD7), false);
</code></pre>
<p>//IIC1, 1M hz. slave addr: 0xd6<br />
iic_init(IIC_CHANNEL_1,1000,LSM6DS33_ADDR);<br />
iic_write_byte(IIC_CHANNEL_1,LSM6DS33_ADDR,0x15,0x00);<br />
iic_write_byte(IIC_CHANNEL_1,LSM6DS33_ADDR,0x16,0x00);<br />
iic_write_byte(IIC_CHANNEL_1,LSM6DS33_ADDR,0x10,0x80);<br />
iic_write_byte(IIC_CHANNEL_1,LSM6DS33_ADDR,0x11,0x80);<br />
iic_write_byte(IIC_CHANNEL_1,LSM6DS33_ADDR,0x12,0x04);</p>
<pre><code>while(1)
{
    for(uint8_t i=0; i&lt;6; i++)
    {
        iic_read_byte(IIC_CHANNEL_1,LSM6DS33_ADDR,0x28+i,&amp;buff1[i]);
        iic_read_byte(IIC_CHANNEL_1,LSM6DS33_ADDR,0x22+i,&amp;buff2[i]);
    }
    co_printf(&quot;X:%d |Y:%d |Z:%d\r\n&quot;,*(uint16_t *)buff1,*(uint16_t *)(buff1+2),*(uint16_t *)(buff1+4));
    co_printf(&quot;AccX:%d|Acc_Y:%d|Acc_Z:%d\r\n&quot;,*(uint16_t *)buff2,*(uint16_t *)(buff2+2),*(uint16_t *)(buff2+4));
    i2c_test_no++;
    if(i2c_test_no&gt;3)
        break;
}
</code></pre>
<p>}</p>
]]></description><link>http://www.freqchip.net:4567/post/1310</link><guid isPermaLink="true">http://www.freqchip.net:4567/post/1310</guid><dc:creator><![CDATA[刘流鎏]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>