<?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>Zephyr, nrf5340 and pin number</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86255/zephyr-nrf5340-and-pin-number</link><description>Hi, 
 I am using the nrfx GPIOTE driver to manage the output, input and interrupt on a nRF5340 on top of Zephyr Framework. 
 I know I can use the GPIO Api from Zephyr, but this is not my case. 
 I would like to retrieve the absolute pin numbers starting</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 31 Mar 2022 08:51:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86255/zephyr-nrf5340-and-pin-number" /><item><title>RE: Zephyr, nrf5340 and pin number</title><link>https://devzone.nordicsemi.com/thread/360952?ContentTypeID=1</link><pubDate>Thu, 31 Mar 2022 08:51:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c51c1ea-7b35-4590-81fc-6f218b6313fb</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This looks like a good approach, it is quite similar to the helper &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.99-ncs1-1/boards/arm/nrf9160dk_nrf52840/board.c#L18-L21"&gt;macros defined in the nrf9160dk_nrf52840 board file&lt;/a&gt;.&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><item><title>RE: Zephyr, nrf5340 and pin number</title><link>https://devzone.nordicsemi.com/thread/360782?ContentTypeID=1</link><pubDate>Wed, 30 Mar 2022 11:17:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4c8b436-f057-4763-972b-ed13ee854781</guid><dc:creator>Riccardo Gaiati</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;i came out with this approach:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define GPIO_PORT(pin)    DT_PROP_BY_PHANDLE_IDX(DT_NODELABEL(pin), gpios, 0, port)
#define GPIO_PIN(pin)     DT_GPIO_PIN(DT_ALIAS(pin), gpios)
#define GPIO_ABS_PIN(pin) NRF_GPIO_PIN_MAP(GPIO_PORT(pin), GPIO_PIN(pin))&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;where &lt;em&gt;pin&lt;/em&gt; is the label used (in &lt;strong&gt;bold&lt;/strong&gt;) in the device tree file (see below).&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;leds&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;compatible&lt;/span&gt;&lt;span&gt; = &lt;/span&gt;&lt;span&gt;&amp;quot;gpio-leds&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;&lt;strong&gt;led0&lt;/strong&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;led_0&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;gpios&lt;/span&gt;&lt;span&gt; = &amp;lt;&amp;amp;&lt;/span&gt;&lt;span&gt;gpio1&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;7&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;GPIO_ACTIVE_LOW&lt;/span&gt;&lt;span&gt;&amp;gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;label&lt;/span&gt;&lt;span&gt; = &lt;/span&gt;&lt;span&gt;&amp;quot;Green LED 0&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr, nrf5340 and pin number</title><link>https://devzone.nordicsemi.com/thread/360495?ContentTypeID=1</link><pubDate>Tue, 29 Mar 2022 09:50:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd602482-567e-4aba-a5cf-9406569b7ab2</guid><dc:creator>Riccardo Gaiati</dc:creator><description>&lt;p&gt;Could you please elaborate with an example when you say &amp;#39;&lt;span&gt;for pins on P1, you can use&amp;nbsp;&lt;/span&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi#L480"&gt;gpio1 in the devicetree&lt;/a&gt;&lt;span&gt;.&lt;/span&gt;&amp;#39;.&lt;/p&gt;
&lt;p&gt;thanks in advance !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr, nrf5340 and pin number</title><link>https://devzone.nordicsemi.com/thread/360493?ContentTypeID=1</link><pubDate>Tue, 29 Mar 2022 09:43:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f963946d-9b65-4266-a653-f13d78167873</guid><dc:creator>Riccardo Gaiati</dc:creator><description>&lt;p&gt;Hi J&amp;oslash;rgen,&lt;/p&gt;
&lt;p&gt;i just tried to run quickly an example project where the led0 is configured in the device tree in this way:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;leds&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;compatible&lt;/span&gt;&lt;span&gt; = &lt;/span&gt;&lt;span&gt;&amp;quot;gpio-leds&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;led0:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;led_0&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;gpios&lt;/span&gt;&lt;span&gt; = &amp;lt;&amp;amp;&lt;/span&gt;&lt;span&gt;gpio1&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;7&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;GPIO_ACTIVE_LOW&lt;/span&gt;&lt;span&gt;&amp;gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;label&lt;/span&gt;&lt;span&gt; = &lt;/span&gt;&lt;span&gt;&amp;quot;Green LED 0&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;So the absolute pin number is 32 + 7 = 39&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;The macro&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;#define INPUT_PIN&amp;nbsp; DT_GPIO_PIN(DT_ALIAS(led0), gpios)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;has a value of 7 instead. So the port number is not considered.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr, nrf5340 and pin number</title><link>https://devzone.nordicsemi.com/thread/360489?ContentTypeID=1</link><pubDate>Tue, 29 Mar 2022 09:19:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:808c8f2f-4de5-4156-a6f3-f7265a12a6b9</guid><dc:creator>Riccardo Gaiati</dc:creator><description>&lt;p&gt;Hi J&amp;oslash;rgen. Thanks for the reply. I saw this example. The point is that both the pins used here are on the GPIO port 0. I was wondering if those macro works properly even when the pin belong to GPIO port 1. Does it ? Since im interested in the absolute value of the pin, so port_number * 32 + pin_number.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr, nrf5340 and pin number</title><link>https://devzone.nordicsemi.com/thread/360476?ContentTypeID=1</link><pubDate>Tue, 29 Mar 2022 08:57:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d6724b2-3b5b-48c5-aee3-256902f32e0b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There is an existing &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/samples/boards/nrf/nrfx/README.html"&gt;example in nRF Connect SDK/Zephyr that shows how to use the GPIOTE and PPI peripherals using nrfx drivers&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.99-ncs1-1/samples/boards/nrf/nrfx/src/main.c#L20-L21"&gt;These lines&lt;/a&gt; shows how you can &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/boards/arm/nrf5340dk_nrf5340/nrf5340_cpuapp_common.dts#L19-L21"&gt;get the GPIOs from the devicetree&lt;/a&gt;, for pins on P1, you can use &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi#L480"&gt;gpio1 in the devicetree&lt;/a&gt;.&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>