<?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>How to link nrfx_gpiote and GPIO1 port on Zephyr?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92870/how-to-link-nrfx_gpiote-and-gpio1-port-on-zephyr</link><description>Hi guys. 
 I&amp;#39;m using the development board NFR52840DK and I modified the sample in zephyr\samples\boards\nrf\nrfx to use twp buttons, sw0 and sw1. 
 The sw0 button reset a counter when interruption occours and sw1 increments the counter. 
 I tried this</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 25 Oct 2022 11:44:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92870/how-to-link-nrfx_gpiote-and-gpio1-port-on-zephyr" /><item><title>RE: How to link nrfx_gpiote and GPIO1 port on Zephyr?</title><link>https://devzone.nordicsemi.com/thread/392368?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2022 11:44:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:235754d1-8988-43b5-be33-e119c236a9af</guid><dc:creator>msfassarella</dc:creator><description>&lt;p&gt;Very good. It also works.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks Jorgen.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to link nrfx_gpiote and GPIO1 port on Zephyr?</title><link>https://devzone.nordicsemi.com/thread/392300?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2022 07:47:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ed0dd20-6930-480d-bd33-55089f52599d</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, it looks like&amp;nbsp;DT_GPIO_PIN does not take the port into account when getting the pin from the devicetree. You can use this line to get both port and pin:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define INPUT_PIN1	NRF_GPIO_PIN_MAP(DT_PROP(DT_GPIO_CTLR(DT_ALIAS(sw1), gpios), port), DT_GPIO_PIN(DT_ALIAS(sw1), gpios)) &lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to link nrfx_gpiote and GPIO1 port on Zephyr?</title><link>https://devzone.nordicsemi.com/thread/392269?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2022 02:27:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd37dc05-fdcf-421d-b4a7-23c963a8e226</guid><dc:creator>msfassarella</dc:creator><description>&lt;p&gt;I discovered how to make it work with P1.3.&amp;nbsp; Instead of use&amp;nbsp;#define INPUT_PIN DT_GPIO_PIN(DT_ALIAS(sw0), gpios) I changed to #define INPUT_PIN 35&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My solution was similar to&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/23786/how-do-i-use-the-gpio-pin-on-nrf52-devices"&gt;do I use the GPIO pin on nrf52 devices?&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I believe it&amp;#39;s possible to use&amp;nbsp;NRF_GPIO_PIN_MAP instead the number 35, but I don&amp;#39;t know how.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to link nrfx_gpiote and GPIO1 port on Zephyr?</title><link>https://devzone.nordicsemi.com/thread/391989?ContentTypeID=1</link><pubDate>Sun, 23 Oct 2022 14:48:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c907d093-b80f-4db7-a265-35dec0018115</guid><dc:creator>msfassarella</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I tried with SDK 2.1.0 and the problem is still there.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To eliminate any mistake that I could have done in my early program, I tried with the original sample but I did&amp;nbsp;one modification on it. This modification is an overlay for button0 .&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If I use P0.02 in the overlay everything works fine.&lt;/p&gt;
&lt;p&gt;Now for P0.03&amp;nbsp;I notice that instead P1.03 the program is working with P0.03.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Someone has any idea why is this happening?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2019 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include &amp;lt;zephyr/zephyr.h&amp;gt;

#include &amp;lt;nrfx_gpiote.h&amp;gt;
#include &amp;lt;helpers/nrfx_gppi.h&amp;gt;
#if defined(DPPI_PRESENT)
#include &amp;lt;nrfx_dppi.h&amp;gt;
#else
#include &amp;lt;nrfx_ppi.h&amp;gt;
#endif

#include &amp;lt;zephyr/logging/log.h&amp;gt;
LOG_MODULE_REGISTER(nrfx_sample, LOG_LEVEL_INF);

#define INPUT_PIN	DT_GPIO_PIN(DT_ALIAS(sw0), gpios)
#define OUTPUT_PIN	DT_GPIO_PIN(DT_ALIAS(led0), gpios)

static void button_handler(nrfx_gpiote_pin_t pin,
			   nrfx_gpiote_trigger_t trigger,
			   void *context)
{
	LOG_INF(&amp;quot;GPIO input event callback&amp;quot;);
}

void main(void)
{
	LOG_INF(&amp;quot;nrfx_gpiote sample on %s&amp;quot;, CONFIG_BOARD);

	nrfx_err_t err;
	uint8_t in_channel, out_channel;
	uint8_t ppi_channel;

	/* Connect GPIOTE_0 IRQ to nrfx_gpiote_irq_handler */
	IRQ_CONNECT(DT_IRQN(DT_NODELABEL(gpiote)),
		    DT_IRQ(DT_NODELABEL(gpiote), priority),
		    nrfx_isr, nrfx_gpiote_irq_handler, 0);

	/* Initialize GPIOTE (the interrupt priority passed as the parameter
	 * here is ignored, see nrfx_glue.h).
	 */
	err = nrfx_gpiote_init(0);
	if (err != NRFX_SUCCESS) {
		LOG_ERR(&amp;quot;nrfx_gpiote_init error: 0x%08X&amp;quot;, err);
		return;
	}

	err = nrfx_gpiote_channel_alloc(&amp;amp;in_channel);
	if (err != NRFX_SUCCESS) {
		LOG_ERR(&amp;quot;Failed to allocate in_channel, error: 0x%08X&amp;quot;, err);
		return;
	}

	err = nrfx_gpiote_channel_alloc(&amp;amp;out_channel);
	if (err != NRFX_SUCCESS) {
		LOG_ERR(&amp;quot;Failed to allocate out_channel, error: 0x%08X&amp;quot;, err);
		return;
	}

	/* Initialize input pin to generate event on high to low transition
	 * (falling edge) and call button_handler()
	 */
	static const nrfx_gpiote_input_config_t input_config = {
		.pull = NRF_GPIO_PIN_PULLUP,
	};
	const nrfx_gpiote_trigger_config_t trigger_config = {
		.trigger = NRFX_GPIOTE_TRIGGER_HITOLO,
		.p_in_channel = &amp;amp;in_channel,
	};
	static const nrfx_gpiote_handler_config_t handler_config = {
		.handler = button_handler,
	};
	err = nrfx_gpiote_input_configure(INPUT_PIN,
					  &amp;amp;input_config,
					  &amp;amp;trigger_config,
					  &amp;amp;handler_config);
	if (err != NRFX_SUCCESS) {
		LOG_ERR(&amp;quot;nrfx_gpiote_input_configure error: 0x%08X&amp;quot;, err);
		return;
	}

	/* Initialize output pin. SET task will turn the LED on,
	 * CLR will turn it off and OUT will toggle it.
	 */
	static const nrfx_gpiote_output_config_t output_config = {
		.drive = NRF_GPIO_PIN_S0S1,
		.input_connect = NRF_GPIO_PIN_INPUT_DISCONNECT,
		.pull = NRF_GPIO_PIN_NOPULL,
	};
	const nrfx_gpiote_task_config_t task_config = {
		.task_ch = out_channel,
		.polarity = NRF_GPIOTE_POLARITY_TOGGLE,
		.init_val = 1,
	};
	err = nrfx_gpiote_output_configure(OUTPUT_PIN,
					   &amp;amp;output_config,
					   &amp;amp;task_config);
	if (err != NRFX_SUCCESS) {
		LOG_ERR(&amp;quot;nrfx_gpiote_output_configure error: 0x%08X&amp;quot;, err);
		return;
	}

	nrfx_gpiote_trigger_enable(INPUT_PIN, true);
	nrfx_gpiote_out_task_enable(OUTPUT_PIN);

	LOG_INF(&amp;quot;nrfx_gpiote initialized&amp;quot;);

	/* Allocate a (D)PPI channel. */
	err = nrfx_gppi_channel_alloc(&amp;amp;ppi_channel);
	if (err != NRFX_SUCCESS) {
		LOG_ERR(&amp;quot;nrfx_gppi_channel_alloc error: 0x%08X&amp;quot;, err);
		return;
	}

	/* Configure endpoints of the channel so that the input pin event is
	 * connected with the output pin OUT task. This means that each time
	 * the button is pressed, the LED pin will be toggled.
	 */
	nrfx_gppi_channel_endpoints_setup(ppi_channel,
		nrfx_gpiote_in_event_addr_get(INPUT_PIN),
		nrfx_gpiote_out_task_addr_get(OUTPUT_PIN));

	/* Enable the channel. */
	nrfx_gppi_channels_enable(BIT(ppi_channel));

	LOG_INF(&amp;quot;(D)PPI configured, leaving main()&amp;quot;);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;nrf52840dk_nrf52840.overlay&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// P0.02 works
// P1.03 for some unknow reason configure P0.03
&amp;amp;button0 {
	gpios = &amp;lt;&amp;amp;gpio1 3 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)&amp;gt;;
};
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to link nrfx_gpiote and GPIO1 port on Zephyr?</title><link>https://devzone.nordicsemi.com/thread/391187?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 12:09:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4010cf4-83d5-4a7f-b804-0855fa8e6f65</guid><dc:creator>msfassarella</dc:creator><description>&lt;p&gt;Hi.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using the SDK version v1.9.0.&lt;/p&gt;
&lt;p&gt;The definitions of input pins are&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define INPUT_PIN DT_GPIO_PIN(DT_ALIAS(sw0), gpios)
#define INPUT_PIN1 DT_GPIO_PIN(DT_ALIAS(sw1), gpios)
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I will try with SDK 2.1.0.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to link nrfx_gpiote and GPIO1 port on Zephyr?</title><link>https://devzone.nordicsemi.com/thread/391113?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 08:32:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb804527-0a36-49f5-932a-3adc7558114c</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Which version of nRF Connect SDK are you using? It seems that the &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.1.99-ncs1/samples/boards/nrf/nrfx/src/main.c"&gt;APIs in the sample&lt;/a&gt; have changed in v2.1.0, compared to what you have in your code snippets. Can you try the same using the latest release?&lt;/p&gt;
&lt;p&gt;What is the definition of&amp;nbsp;INPUT_PIN1?&amp;nbsp;&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>