<?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 DK Basic GPIO</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/81057/nrf-dk-basic-gpio</link><description>I have the NRF52-DK, a 3-digit seven segment display, an RGB LED and a sensor. Using SES to try and get some basic code running. 
 I manage to open an nRF Connect SDK project (rgb_led) and update it to drive 3 IO via the PWM peripheral. Next up I&amp;#39;m trying</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 27 Oct 2021 13:50:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/81057/nrf-dk-basic-gpio" /><item><title>RE: NRF DK Basic GPIO</title><link>https://devzone.nordicsemi.com/thread/336245?ContentTypeID=1</link><pubDate>Wed, 27 Oct 2021 13:50:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff6e0850-738a-41df-a4c0-1685b3aac9d2</guid><dc:creator>Geordie</dc:creator><description>&lt;p&gt;Funny enough I was already in the process of re-coding based on that very article! Got the GPIO working, although it would be nice to have done it via the dts overlay and the&amp;nbsp;GPIO_DT_SPCE_GET macro, but I guess that&amp;#39;s really now a question for the Zephyr community.&lt;/p&gt;
&lt;p&gt;It didn&amp;#39;t help that I was using some GPIO that was already being used for the xtal and other functionality on the nRF DK board. For future reference:&lt;/p&gt;
&lt;p&gt;I freed up the GPIO assigned to the DK buttons and LED&amp;#39;s by grounding the SHIELD detect header pin.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Grab a reference to the GPIO controller:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define GPIO_PORT DEVICE_DT_GET(DT_NODELABEL(gpio0))&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Grouped some IO bits together:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;typedef struct gpio_s {
    struct device const *port;
    gpio_pin_t const pin;
    gpio_flags_t flags;
} gpio_t;

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Grouped the 3-digit seven seg LED IO into a structure..&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;typedef struct three_digit_s {
    gpio_t a;
    gpio_t b;
    gpio_t c;
    gpio_t d;
    gpio_t e;
    gpio_t f;
    gpio_t g;

    gpio_t dp;
    gpio_t d1_en;
    gpio_t d2_en;
    gpio_t d3_en;
} three_digit_t;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;with some static assignments specifying the pin numbers..&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static three_digit_t three_digit = {
  .a = {
    .port = GPIO_PORT,
    .pin = 11,
    .flags = GPIO_OUTPUT_INACTIVE
  },
  .b = {
    .port = GPIO_PORT,
    .pin = 12,
    .flags = GPIO_OUTPUT_INACTIVE
  },
  
  ... etc
  
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;configure..&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;success = gpio_pin_configure(
    three_digit.a.port,
    three_digit.a.pin,
    three_digit.a.flags
  );&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;then set..&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;gpio_pin_set(
    three_digit.d1_en.port,
    three_digit.d1_en.pin,
    0   // or 1..
);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f44d_2D00_1f3fd.svg" title="Thumbsup tone3"&gt;&amp;#x1f44d;&amp;#x1f3fd;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF DK Basic GPIO</title><link>https://devzone.nordicsemi.com/thread/336019?ContentTypeID=1</link><pubDate>Tue, 26 Oct 2021 14:13:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ba1bacb-ccad-4331-8547-c48ac331bae4</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Could you try using this approach:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/72618/extra-gpios-in-board-overlay-for-nrf9160dk"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/72618/extra-gpios-in-board-overlay-for-nrf9160dk&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;Let me know if you get it to work or not&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF DK Basic GPIO</title><link>https://devzone.nordicsemi.com/thread/335875?ContentTypeID=1</link><pubDate>Tue, 26 Oct 2021 08:23:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e48a771-7565-4ddd-aaf2-bae07e5e2f8a</guid><dc:creator>Geordie</dc:creator><description>&lt;p&gt;Found the comments in&amp;nbsp;&lt;a href="https://github.com/mbolivar-nordic/zephyr/commit/19c1c2088635fe3037fefb65f3c1478f74ddc406" rel="noopener noreferrer" target="_blank"&gt;include/drivers/gpio.h&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * @brief Static initializer for a @p gpio_dt_spec
 *
 * This returns a static initializer for a @p gpio_dt_spec structure
 * given a devicetree node identifier and a property specifying a
 * GPIO.
 *
 * Example devicetree fragment:
 *
 *	n: node {
 *		foo-gpios = &amp;lt;&amp;amp;gpio1 2 GPIO_ACTIVE_LOW&amp;gt;;
 *	}
 *
 * Example usage:
 *
 *	const struct gpio_dt_spec spec = GPIO_DT_SPEC_GET(DT_NODELABEL(n),
 *							  foo_gpios);
 *	// Initializes &amp;#39;spec&amp;#39; to:
 *	// {
 *	//         .port = DEVICE_DT_GET(DT_NODELABEL(gpio1)),
 *	//         .pin = 2,
 *	//         .dt_flags = GPIO_ACTIVE_LOW
 *	// }
 *...
 */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I changed the prop names in the dts from underscore to dash, just in case. No joy.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF DK Basic GPIO</title><link>https://devzone.nordicsemi.com/thread/335830?ContentTypeID=1</link><pubDate>Mon, 25 Oct 2021 22:17:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50f50d9e-8383-4227-918b-8ee38f73f8e1</guid><dc:creator>Geordie</dc:creator><description>&lt;p&gt;I&amp;#39;ve done away with my attempt to group some IO by specifying another connector, having looked around some of the dt binding files. So I&amp;#39;m just left with this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  seven_seg_display: seven_seg {
    seg_a = &amp;lt;&amp;amp;gpio0 0 0&amp;gt;; 
    seg_b = &amp;lt;&amp;amp;gpio0 1 0&amp;gt;;
    seg_c = &amp;lt;&amp;amp;gpio0 21 0&amp;gt;;
    seg_d = &amp;lt;&amp;amp;gpio0 5 0&amp;gt;;
    seg_e = &amp;lt;&amp;amp;gpio0 6 0&amp;gt;;
    seg_f = &amp;lt;&amp;amp;gpio0 7 0&amp;gt;;
    seg_g = &amp;lt;&amp;amp;gpio0 8 0&amp;gt;;
    dp = &amp;lt;&amp;amp;gpio0 9 0&amp;gt;;
    dig_1_en = &amp;lt;&amp;amp;gpio0 10 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)&amp;gt;;
    dig_2_en = &amp;lt;&amp;amp;gpio0 11 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)&amp;gt;;
    dig_3_en = &amp;lt;&amp;amp;gpio0 12 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)&amp;gt;;
  };&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I understand my error is complaining that the properties of this node aren&amp;#39;t GPIO instances, but is something like this possible? I spotted&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/67810/reading-and-writing-to-gpio-pins-from-a-sample-zephyr-project" rel="noopener noreferrer" target="_blank"&gt;this post&lt;/a&gt;&amp;nbsp;that I&amp;#39;ll try tomorrow that describes just getting the GPIO_0 instance and using that on the configure calls, but I&amp;#39;d still like to know how to&amp;nbsp;use&amp;nbsp;GPIO_DT_SPEC_GET() with my example.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any help appreciated. Cheers.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>