<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nRF Connect SDK implement i2c mux</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/109166/nrf-connect-sdk-implement-i2c-mux</link><description>I&amp;#39;m going to build an project with 2 AS5600 sensors, and also using I2C mux(TCA9548A) to communicate with 2 sensors. 
 I have some problem with devicetree. There are two errors in &amp;amp; i2c1 node, how could I fix this? 
 Also, when I try to build the project</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 25 Jun 2024 00:33:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/109166/nrf-connect-sdk-implement-i2c-mux" /><item><title>RE: nRF Connect SDK implement i2c mux</title><link>https://devzone.nordicsemi.com/thread/490438?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2024 00:33:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2469fd15-dc62-40c6-926b-d945f36293b6</guid><dc:creator>ekidsalan123</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;What devices you are using after TCA9548A? As I know, if you correctly build your devicetree, you can interface with the device after I2C Mux directly.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s part of my devicetree&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;i2c1 {
	status = &amp;quot;okay&amp;quot;;
    pinctrl-0 = &amp;lt;&amp;amp;i2c1_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;i2c1_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
	label = &amp;quot;I2C_1&amp;quot;;
	mux: tca9548a@70 {
		compatible = &amp;quot;ti,tca9548a&amp;quot;;
		reg = &amp;lt;0x70&amp;gt;;
		status = &amp;quot;okay&amp;quot;;
		#address-cells = &amp;lt;1&amp;gt;;
		#size-cells = &amp;lt;0&amp;gt;;

        ch0: mux_i2c@0 {
            compatible = &amp;quot;ti,tca9548a-channel&amp;quot;;
            label = &amp;quot;i2c1_mux_0&amp;quot;;
            reg = &amp;lt;0x0&amp;gt;;
            status = &amp;quot;okay&amp;quot;;
            #address-cells = &amp;lt;0x1&amp;gt;;
            #size-cells = &amp;lt;0x0&amp;gt;;

            as5600_0: as5600@36 {
                compatible = &amp;quot;ams,as5600&amp;quot;;
                reg = &amp;lt;0x36 &amp;gt;;
                label = &amp;quot;AS5600_0&amp;quot;;
                status = &amp;quot;okay&amp;quot;;
            };
        };

        ch1: mux_i2c@1 {
            compatible = &amp;quot;ti,tca9548a-channel&amp;quot;;
            label = &amp;quot;i2c1_mux_1&amp;quot;;
            reg = &amp;lt;0x1&amp;gt;;
            status = &amp;quot;okay&amp;quot;;
            #address-cells = &amp;lt;0x1&amp;gt;;
            #size-cells = &amp;lt;0x0&amp;gt;;

            as5600_1: as5600@36 {
                compatible = &amp;quot;ams,as5600&amp;quot;;
                reg = &amp;lt;0x36 &amp;gt;;
                label = &amp;quot;AS5600_1&amp;quot;;
                status = &amp;quot;okay&amp;quot;;
            };
        };
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And I could access my AS5600 sensor with following code&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;K_SEM_DEFINE(as5600_init_ok, 0, 1);

#define AS5600_NODE_0 DT_NODELABEL(as5600_0)

static const struct i2c_dt_spec dev_as5600_0 = I2C_DT_SPEC_GET(AS5600_NODE_0);

uint8_t as5600_0_interface_iic_init(void)
{
    if (!device_is_ready(dev_as5600_0.bus))
    {
        printk(&amp;quot;I2C bus %s is not ready!\n\r&amp;quot;, dev_as5600_0.bus-&amp;gt;name);
        return 1;
    }

    return 0;
}

uint8_t as5600_0_interface_iic_deinit(void)
{

    return 0;
}

uint8_t as5600_0_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
{
    int ret;
    ret = i2c_burst_read_dt(&amp;amp;dev_as5600_0, reg, buf, len);
    if (ret != 0)
    {
        printk(&amp;quot;Failed to read to I2C device address 0x%c at Reg. 0x%c\n&amp;quot;, dev_as5600_0.addr, reg);
        return 1;
    }
    return 0;
}

uint8_t as5600_0_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
{
    int ret;
    char buff1[] = {reg, buf};
    ret = i2c_write_dt(&amp;amp;dev_as5600_0, buff1, sizeof(buff1));
    if (ret != 0)
    {
        printk(&amp;quot;Failed to write to I2C device address 0x%c at Reg. 0x%c\n&amp;quot;, dev_as5600_0.addr, reg);
        return 1;
    }
    return 0;
}

void as5600_interface_delay_ms(uint32_t ms)
{
    k_msleep(ms);
}

void as5600_interface_debug_print(const char *const fmt, ...)
{
    va_list args;
    va_start(args, fmt);
    vprintk(fmt, args);
    va_end(args);
}

static as5600_handle_t gs_handle_ch0; /**&amp;lt; as5600 handle */

uint8_t as5600_ch0_init(void)
{
    uint8_t res;

    /* link interface function */
    DRIVER_AS5600_LINK_INIT(&amp;amp;gs_handle_ch0, as5600_handle_t);
    DRIVER_AS5600_LINK_IIC_INIT(&amp;amp;gs_handle_ch0, as5600_0_interface_iic_init);
    DRIVER_AS5600_LINK_IIC_DEINIT(&amp;amp;gs_handle_ch0, as5600_0_interface_iic_deinit);
    DRIVER_AS5600_LINK_IIC_READ(&amp;amp;gs_handle_ch0, as5600_0_interface_iic_read);
    DRIVER_AS5600_LINK_IIC_WRITE(&amp;amp;gs_handle_ch0, as5600_0_interface_iic_write);
    DRIVER_AS5600_LINK_DELAY_MS(&amp;amp;gs_handle_ch0, as5600_interface_delay_ms);
    DRIVER_AS5600_LINK_DEBUG_PRINT(&amp;amp;gs_handle_ch0, as5600_interface_debug_print);

    /* as5600 init */
    res = as5600_init(&amp;amp;gs_handle_ch0);
    if (res != 0)
    {
        as5600_interface_debug_print(&amp;quot;as5600_ch0: init failed.\n&amp;quot;);

        return 1;
    }

    return 0;
}

uint8_t as5600_ch0_read(float *angle)
{
    uint8_t res;
    uint16_t angle_raw;

    /* read data */
    res = as5600_read(&amp;amp;gs_handle_ch0, &amp;amp;angle_raw, angle);
    if (res != 0)
    {
        as5600_interface_debug_print(&amp;quot;as5600_ch0: read failed.\n&amp;quot;);

        return 1;
    }

    return 0;
}

uint8_t as5600_ch0_deinit(void)
{
    /* close as5600 */
    if (as5600_deinit(&amp;amp;gs_handle_ch0) != 0)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please have a look if this could help you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Connect SDK implement i2c mux</title><link>https://devzone.nordicsemi.com/thread/490354?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2024 14:23:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f342bdb-1a8d-4cbf-858f-84fca98042c7</guid><dc:creator>Nyameaama</dc:creator><description>&lt;p&gt;&lt;span&gt;Hello, yes I had the same exact problems with the devicetree where the child node of the TCA9548A was throwing unrecognized errors and I could not interface my sensors. I still couldn&amp;#39;t figure out the device tree no matter what I tried so I disregarded it entirely and I interfaced the TCA9548A the programmatic way by writing my own driver for it, and referenced the mux i2c0 bus directly. I used i2c_write_read() instead of i2c_write_read_dt() so the implementation is more akin to hardware definitions in other SDKs. Thanks for your reply!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Connect SDK implement i2c mux</title><link>https://devzone.nordicsemi.com/thread/490130?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2024 01:13:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd75791a-012f-4899-8c7f-7aa11745c61c</guid><dc:creator>ekidsalan123</dc:creator><description>&lt;p&gt;Hello, I was away over the weekend. Did you encounter the same error message? Please upload your screenshot or related files, and I&amp;#39;ll try to assist you with your issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Connect SDK implement i2c mux</title><link>https://devzone.nordicsemi.com/thread/489814?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2024 18:22:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9a5e33b-0922-48f5-9700-a02892830fc7</guid><dc:creator>Nyameaama</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you say how you figured it out? Im currently having the same problem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Connect SDK implement i2c mux</title><link>https://devzone.nordicsemi.com/thread/474003?ContentTypeID=1</link><pubDate>Fri, 15 Mar 2024 04:10:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4ae3f67-32ba-45da-9b40-2b59535de5e6</guid><dc:creator>ekidsalan123</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&lt;span&gt;J&amp;oslash;rgen,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Sorry for the late reply, I didn&amp;#39;t notice there&amp;#39;s a test code in SDK.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;By following the sample, I figure it out and get my code work now, thank you.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Connect SDK implement i2c mux</title><link>https://devzone.nordicsemi.com/thread/473493?ContentTypeID=1</link><pubDate>Tue, 12 Mar 2024 15:28:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18751286-65dd-4b20-83e5-0f48c6440314</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Which version of the nRF Connect SDK are you using? Your devicetree looks quite similar to the &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.4.99-ncs1-2/tests/drivers/i2c/i2c_tca954x/boards/nrf52840dk_nrf52840.overlay"&gt;test case overlay file&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Can you provide a full sample that can be used to reproduce/debug this?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>