<?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>[nRF5340 TWI ] Access two sensors separetly on same TWI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96221/nrf5340-twi-access-two-sensors-separetly-on-same-twi</link><description>Hello, 
 I am using the gpio_pca95cc.c driver on the zephyr for a nRF5340. I am a beginner at using zephyr OS 
 I am able to use one GPIO expander but when I add the second one, I can’t figure a way to access a specific device 
 In the myboard.dts file</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 01 Feb 2023 18:38:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96221/nrf5340-twi-access-two-sensors-separetly-on-same-twi" /><item><title>RE: [nRF5340 TWI ] Access two sensors separetly on same TWI</title><link>https://devzone.nordicsemi.com/thread/407640?ContentTypeID=1</link><pubDate>Wed, 01 Feb 2023 18:38:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00aed336-6679-4c52-854d-cbe78ce7c8fc</guid><dc:creator>Augustin Bricout</dc:creator><description>&lt;p&gt;Alright it works,&lt;/p&gt;
&lt;p&gt;Thank you very much&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [nRF5340 TWI ] Access two sensors separetly on same TWI</title><link>https://devzone.nordicsemi.com/thread/407616?ContentTypeID=1</link><pubDate>Wed, 01 Feb 2023 16:01:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76abea82-2260-43a1-ac0c-428e919b5e8d</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hi Augustin,&lt;/p&gt;
&lt;p&gt;You can use something similar as below:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void main(void)
{
	int err = 0;

	const struct device *const gpio_pcaA = DEVICE_DT_GET(DT_NODELABEL(pcaalpha));
	const struct device *const gpio_pcaB = DEVICE_DT_GET(DT_NODELABEL(pcabravo));

	if (!gpio_pcaA) {
		printk(&amp;quot;\nError initialization Alpha PCA&amp;quot;); return;
	}
	
	if (!gpio_pcaB) {
		printk(&amp;quot;\nError initialization Bravo PCA&amp;quot;); return;
	}

	printk(&amp;quot;%s PCA initialized on ! %s\n&amp;quot;, gpio_pcaA-&amp;gt;name, CONFIG_BOARD);
	printk(&amp;quot;%s PCA initialized on ! %s\n&amp;quot;, gpio_pcaB-&amp;gt;name, CONFIG_BOARD);

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Please note that I have changed the sub-node names in the device overlay as (also some minor modifications):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;i2c0 {
    compatible = &amp;quot;nordic,nrf-twim&amp;quot;;
    status = &amp;quot;okay&amp;quot;;
    pinctrl-0 = &amp;lt;&amp;amp;i2c0_default&amp;gt;;
    pinctrl-1 = &amp;lt;&amp;amp;i2c0_sleep&amp;gt;;
    pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
    pcaAlpha: pcaAlpha@20 {
        compatible = &amp;quot;nxp,pca95xx&amp;quot;;
        #gpio-cells = &amp;lt;2&amp;gt;;
        gpio-controller;
        reg = &amp;lt;0x20 &amp;gt;;
        ngpios = &amp;lt; 16 &amp;gt;;
        interrupt-gpios = &amp;lt;&amp;amp;gpio0 9 (GPIO_ACTIVE_LOW)&amp;gt;;
        label = &amp;quot;pcaAlpha&amp;quot;;
    };
    pcaBravo: pcaBravo@21 {
        compatible = &amp;quot;nxp,pca95xx&amp;quot;;
        #gpio-cells = &amp;lt;2&amp;gt;;
        gpio-controller;
        reg = &amp;lt;0x21 &amp;gt;;
        ngpios = &amp;lt; 16 &amp;gt;;
        interrupt-gpios = &amp;lt;&amp;amp;gpio0 9 (GPIO_ACTIVE_LOW)&amp;gt;;        
        label = &amp;quot;pcaBravo&amp;quot;;
    };
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Tested it on 52840&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1675267245897v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Hope it helps,&lt;/p&gt;
&lt;p&gt;Naeem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>