<?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>portexpander board definition</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/104089/portexpander-board-definition</link><description>Hello, 
 I have a MCP23017 portexpander connected to an nrf9160 board with I2C , can somebody please explain me , how to integrate the GPIOs of the portexpander in the devicetree ? 
 This is the subnode in the I2C node: 
 
 
 I am getting the different</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 27 Sep 2023 07:46:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/104089/portexpander-board-definition" /><item><title>RE: portexpander board definition</title><link>https://devzone.nordicsemi.com/thread/447869?ContentTypeID=1</link><pubDate>Wed, 27 Sep 2023 07:46:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4217e95-ec72-4fd9-87e3-345d9ac82c5a</guid><dc:creator>tomtomtom2401</dc:creator><description>&lt;p&gt;Yes... thank you very much for your support!&lt;/p&gt;
&lt;p&gt;BR Thomas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: portexpander board definition</title><link>https://devzone.nordicsemi.com/thread/447807?ContentTypeID=1</link><pubDate>Tue, 26 Sep 2023 17:41:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc6f2f98-b222-4cd2-9605-eefb7bae0a97</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;Try enabling I2C:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_I2C=y&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: portexpander board definition</title><link>https://devzone.nordicsemi.com/thread/447803?ContentTypeID=1</link><pubDate>Tue, 26 Sep 2023 16:53:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb636a87-ea91-4e29-95eb-9e5e33d0c9e8</guid><dc:creator>tomtomtom2401</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The key was to change it to gpio-leds. I have misunderstood the documentation with the bindings...&lt;/p&gt;
&lt;p&gt;The build works now, but when we try to use it in the main.c, the following error appears:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;c:/users/thoma/zephyr-sdk-0.15.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(main.c.obj): in function `main&amp;#39;:
C:/somepath/blinky/src/main.c:101: undefined reference to `__device_dts_ord_22&amp;#39;
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: &amp;#39;C:\Program Files\CMake\bin\cmake.EXE&amp;#39; --build &amp;#39;C:\Users\thoma\zephyrproject\build&amp;#39;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This error happens on this line:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;gpio_is_ready_dt(&amp;amp;out00)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve disabled the other lines where out00 is used to trace the error...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;main.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/drivers/gpio.h&amp;gt;

/* 1000 msec = 1 sec */
#define SLEEP_TIME_MS   1000

#define LED0_NODE DT_ALIAS(led0)
#define LED1_NODE DT_ALIAS(led1)
#define LED2_NODE DT_ALIAS(led2)
#define OUT0_NODE DT_ALIAS(out0)

static const struct gpio_dt_spec led00 = GPIO_DT_SPEC_GET(LED2_NODE, gpios);
static const struct gpio_dt_spec led01 = GPIO_DT_SPEC_GET(LED1_NODE, gpios);
static const struct gpio_dt_spec led02 = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
static const struct gpio_dt_spec out00 = GPIO_DT_SPEC_GET(OUT0_NODE, gpios);

void main(void)
{
	int ret;

	printk(&amp;quot;### Hello World ###&amp;quot;);

	if (!gpio_is_ready_dt(&amp;amp;led00)) {
		return;
	}
	printk(&amp;quot;device ready: led00&amp;quot;);

	if (!gpio_is_ready_dt(&amp;amp;out00)) {
		return;
	}
	printk(&amp;quot;device ready: out00&amp;quot;);

	ret = gpio_pin_configure_dt(&amp;amp;led00, GPIO_OUTPUT_ACTIVE);
	if (ret &amp;lt; 0) {
		return;
	}
	printk(&amp;quot;device config: led00&amp;quot;);

	//ret = gpio_pin_configure_dt(&amp;amp;out00, GPIO_OUTPUT_ACTIVE);
	if (ret &amp;lt; 0) {
		return;
	}
	printk(&amp;quot;device config: out00&amp;quot;);

	while (1) {
		printk(&amp;quot;BLINK\n&amp;quot;);
		ret = gpio_pin_toggle_dt(&amp;amp;led00);
		if (ret &amp;lt; 0) {
			return;
		}

		//ret = gpio_pin_toggle_dt(&amp;amp;out00);
		if (ret &amp;lt; 0) {
			return;
		}
		k_msleep(SLEEP_TIME_MS);
	}
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So it seems there is an error with the pointer to the devicetree object loaded in&amp;nbsp;GPIO_DT_SPEC_GET&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;
&lt;p&gt;BR Thomas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: portexpander board definition</title><link>https://devzone.nordicsemi.com/thread/447747?ContentTypeID=1</link><pubDate>Tue, 26 Sep 2023 13:40:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4260948-4805-4262-a4e2-c0923381a77c</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Do you have a bindings file for the gpio-out compatible? I changed it to gpio-leds for now, since that is what I would normally use for output GPIOs. There is nothing about gpio-leds that is strictly related to LEDs, it just provides a bindings file that helps the devicetree system make sense of the node properties.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s an overlay I want you to try with nrf9160dk_nrf9160:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/8640.nrf9160dk_5F00_nrf9160.overlay"&gt;devzone.nordicsemi.com/.../8640.nrf9160dk_5F00_nrf9160.overlay&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It probably needs some more, so let me know which build or runtime errors you are seeing with this overlay and I&amp;#39;ll see what I can do.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: portexpander board definition</title><link>https://devzone.nordicsemi.com/thread/447410?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 09:25:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cef9d502-a154-459c-92fd-7f897b3817aa</guid><dc:creator>tomtomtom2401</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve worked on the AT SAMD21 version of the board defintion file, but the error is the same on the nrf9160. Here is the blinky sample with the adapted code and the board defition.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/1588.blinky.zip"&gt;devzone.nordicsemi.com/.../1588.blinky.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: portexpander board definition</title><link>https://devzone.nordicsemi.com/thread/447400?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 09:13:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f46ccb5a-90be-4530-98a3-b57a424e3067</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you upload a zip of a simple project showing this?&lt;br /&gt;Then I will reproduce the issue and see if I can find a solution.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: portexpander board definition</title><link>https://devzone.nordicsemi.com/thread/447392?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 08:46:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aebc2829-ac17-48f7-8be7-9a2654181b0f</guid><dc:creator>tomtomtom2401</dc:creator><description>&lt;p&gt;based on the thingy:52 I have changed the board definition:&lt;/p&gt;
&lt;p&gt;in the base node of the board:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;outputs {
	compatible = &amp;quot;gpio-out&amp;quot;;
	out0: out_0 {
		gpios = &amp;lt;&amp;amp;portexp 8 GPIO_ACTIVE_HIGH&amp;gt;;
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and the portexpander in the i2c node:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;portexp: portexp@20 {
        compatible = &amp;quot;microchip,mcp230xx&amp;quot;;
        reg = &amp;lt;0x20&amp;gt;;
        gpio-controller;
        #gpio-cells = &amp;lt;2&amp;gt;;
		ngpios = &amp;lt;16&amp;gt;;
       	//interrupt-parent = &amp;lt;&amp;amp;gpio0&amp;gt;;
        //interrupts = &amp;lt;12 IRQ_TYPE_EDGE_RISING&amp;gt;; // You may need to adjust this GPIO number (12) based on your board configuration.
        //interrupt-controller;
        //#interrupt-cells = &amp;lt;2&amp;gt;;
    };&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And the error still happens when calling&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define OUT0_NODE DT_ALIAS(out0)
static const struct gpio_dt_spec out00 = GPIO_DT_SPEC_GET(OUT0_NODE, gpios);&lt;/pre&gt;:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;C:/Users/thoma/zephyrproject/zephyr/include/zephyr/device.h:83:41: error: &amp;#39;__device_dts_ord_DT_N_S_outputs_S_out_0_P_gpios_IDX_0_PH_ORD&amp;#39; undeclared here (not in a function)

C:/Users/thoma/zephyrproject/build/zephyr/include/generated/devicetree_generated.h:1455:29: error: &amp;#39;DT_N_S_outputs_S_out_0_P_gpios_IDX_0_VAL_pin&amp;#39; undeclared here (not in a function); did you mean &amp;#39;DT_N_S_leds_S_led_0_P_gpios_IDX_0_VAL_pin&amp;#39;?&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>