<?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>Adafruit nRF52840 Feather Express GPIO and DTS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/125575/adafruit-nrf52840-feather-express-gpio-and-dts</link><description>Hi, I have an Adafruit nRF52840 Feather Express and am developing for it using Zephyr 3.1.1 and the nRF Connect SDK with VS Code. 
 I want to read and write from two of the GPIO pins via UART but am struggling with setting this up. My understanding of</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 14 Nov 2025 05:26:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/125575/adafruit-nrf52840-feather-express-gpio-and-dts" /><item><title>RE: Adafruit nRF52840 Feather Express GPIO and DTS</title><link>https://devzone.nordicsemi.com/thread/554324?ContentTypeID=1</link><pubDate>Fri, 14 Nov 2025 05:26:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e6a1203-ed9d-40f2-bdf5-c03e5cc680c8</guid><dc:creator>bluetoothmdw</dc:creator><description>&lt;p&gt;Benjamin, thank you so much for this. Happily, last night I&amp;#39;d managed to arrive at some similar conclusions (although I ended up with the macro&amp;nbsp;GPIO_DT_SPEC_GET_OR so I need to make sure I&amp;#39;m clear on the difference between this macro and&amp;nbsp;GPIO_DT_SPEC_GET. I haven&amp;#39;t tested yet but it&amp;#39;s very reassuring to see your code fragments looking so similar to what I currently have.&lt;/p&gt;
&lt;p&gt;So, next step is testing this in a simple application and then, per your suggestion, more work in the excellent DevAcademy!&lt;/p&gt;
&lt;p&gt;Thanks once again, Much appreciated :-)&lt;/p&gt;
&lt;p&gt;Martin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adafruit nRF52840 Feather Express GPIO and DTS</title><link>https://devzone.nordicsemi.com/thread/554314?ContentTypeID=1</link><pubDate>Thu, 13 Nov 2025 21:57:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6cf04e27-a5a6-4df8-bb24-da5a7b44e114</guid><dc:creator>Benjamin</dc:creator><description>&lt;p&gt;Hi Martin,&lt;br /&gt;&lt;br /&gt;Welcome to Nordic, it seems&amp;nbsp;like you are on a good trajectory already!&lt;br /&gt;&lt;br /&gt;I can answer some of your questions, but the best way to learn&amp;nbsp;is continuing the&amp;nbsp;DevAcademy and browsing the samples available in our SDK. There are also a ton of resources available in the documentation (&lt;a href="https://docs.nordicsemi.com"&gt;Nordic TechDocs&lt;/a&gt;&amp;nbsp;and &lt;a href="https://docs.zephyrproject.org/latest/index.html"&gt;Zephyr Project Docs&lt;/a&gt;).&lt;/p&gt;
[quote user=""]Put something in a DTS overlay file?[/quote]
&lt;p&gt;Yes,&amp;nbsp;y&lt;span&gt;ou need to define the GPIO pin in the device tree. Overlays let you avoid editing the main device tree files for the SoC and board. In an overlay, create a node for your GPIO pin. A generic GPIO pin node can look like this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {
    my_pin: my_pin_node {
        compatible = &amp;quot;nordic,gpio-pins&amp;quot;;
        gpios = &amp;lt;&amp;amp;gpio0 25 GPIO_ACTIVE_HIGH&amp;gt;;
        status = &amp;quot;okay&amp;quot;;
    };
};&lt;/pre&gt;&lt;/p&gt;
[quote user=""]What do I need to do to make the pin accessible from my C code?[/quote]
&lt;p&gt;To access the pin from your C code you need a device pointer. Here is a simple code snippet that creates a device pointer with the use of a thin &lt;a href="https://docs.nordicsemi.com/bundle/zephyr-apis-latest/page/structgpio_dt_spec.html"&gt;wrapper&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static const struct gpio_dt_spec my_pin = GPIO_DT_SPEC_GET(DT_NODELABEL(my_pin), gpios);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To make use of it you need to initialize and configure it. Here is a bare minimum example that just toggles a pin:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{
    device_is_ready(my_pin.port)

    gpio_pin_configure_dt(&amp;amp;my_pin, GPIO_OUTPUT_INACTIVE)

    while (1) {
        gpio_pin_toggle_dt(&amp;amp;my_pin);
        k_sleep(K_MSEC(500));
    }

    return 0;
}&lt;/pre&gt;&lt;/p&gt;
[quote user=""]Is the DTS file for the board basically incomplete?[/quote]
&lt;p&gt;No, it is not incomplete. Devictree is hierarchical and most&amp;nbsp;nodes&amp;nbsp;lives inside these included files:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;quot;adafruit_feather_nrf52840_common.dtsi&amp;quot;
#include &amp;lt;nordic/nrf52840_partition.dtsi&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To communicate over UART using two GPIO pins, you should check out&amp;nbsp;&lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/lessons/lesson-4-serial-communication-uart/topic/exercise-1-5/"&gt;Lesson 5 – Serial communication (UART)&lt;/a&gt;&amp;nbsp;and other relevant samples.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Benjamin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adafruit nRF52840 Feather Express GPIO and DTS</title><link>https://devzone.nordicsemi.com/thread/554184?ContentTypeID=1</link><pubDate>Wed, 12 Nov 2025 19:04:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c2b6684-dd04-4c20-a108-19df78a411b7</guid><dc:creator>bluetoothmdw</dc:creator><description>&lt;p&gt;The Nordic DevAcademy is doing a good job of educating me on the subject of the Zephyr Device Tree!&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve found the DTS definition for a node called&amp;nbsp;&lt;em&gt;connector&lt;/em&gt; which has a label of&amp;nbsp;&lt;em&gt;feather_header&lt;/em&gt;. In there, I see a property called gpio-map which includes values for all the header pins, including the one I want to write to:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;10&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;gpio0&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;25&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;&amp;gt;, &lt;/span&gt;&lt;span&gt;/* TXD */&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2020 Richard Osterloh &amp;lt;richard.osterloh@gmail.com&amp;gt;
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/ {
	feather_header: connector {
		compatible = &amp;quot;adafruit-feather-header&amp;quot;;
		#gpio-cells = &amp;lt;2&amp;gt;;
		gpio-map-mask = &amp;lt;0xffffffff 0xffffffc0&amp;gt;;
		gpio-map-pass-thru = &amp;lt;0 0x3f&amp;gt;;
		gpio-map = &amp;lt;0 0 &amp;amp;gpio0 4 0&amp;gt;,	/* A0 */
			   &amp;lt;1 0 &amp;amp;gpio0 5 0&amp;gt;,	/* A1 */
			   &amp;lt;2 0 &amp;amp;gpio0 30 0&amp;gt;,	/* A2 */
			   &amp;lt;3 0 &amp;amp;gpio0 28 0&amp;gt;,	/* A3 */
			   &amp;lt;4 0 &amp;amp;gpio0 2 0&amp;gt;,	/* A4 */
			   &amp;lt;5 0 &amp;amp;gpio0 3 0&amp;gt;,	/* A5 */
			   &amp;lt;6 0 &amp;amp;gpio0 14 0&amp;gt;,	/* SCK */
			   &amp;lt;7 0 &amp;amp;gpio0 13 0&amp;gt;,	/* MOSI */
			   &amp;lt;8 0 &amp;amp;gpio0 15 0&amp;gt;,	/* MISO */
			   &amp;lt;9 0 &amp;amp;gpio0 24 0&amp;gt;,	/* RXD */
			   &amp;lt;10 0 &amp;amp;gpio0 25 0&amp;gt;,	/* TXD */
			   &amp;lt;11 0 &amp;amp;gpio0 10 0&amp;gt;,	/* D2 (NFC2) */
			   &amp;lt;12 0 &amp;amp;gpio0 12 0&amp;gt;,	/* SDA */
			   &amp;lt;13 0 &amp;amp;gpio0 11 0&amp;gt;,	/* SCL */
			   &amp;lt;14 0 &amp;amp;gpio1 8 0&amp;gt;,	/* D5 */
			   &amp;lt;15 0 &amp;amp;gpio0 7 0&amp;gt;,	/* D6 */
			   &amp;lt;16 0 &amp;amp;gpio0 26 0&amp;gt;,	/* D9 */
			   &amp;lt;17 0 &amp;amp;gpio0 27 0&amp;gt;,	/* D10 */
			   &amp;lt;18 0 &amp;amp;gpio0 6 0&amp;gt;,	/* D11 */
			   &amp;lt;19 0 &amp;amp;gpio0 8 0&amp;gt;,	/* D12 */
			   &amp;lt;20 0 &amp;amp;gpio1 9 0&amp;gt;;	/* D13 */
	};
};

feather_serial: &amp;amp;uart0 {};
feather_i2c: &amp;amp;i2c0 {};
feather_spi: &amp;amp;spi1 {};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So, I guess I need to figure out how to use the Zephyr DTS macros to get a device pointer for feather_header and from there the specific pin I want to use? I&amp;#39;ll keep investigating but if anyone wants to make this easier for me, please don&amp;#39;t hesitate :-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>