<?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 set 2 separate callbacks on the same pin, for pin raise and fall in zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85806/how-to-set-2-separate-callbacks-on-the-same-pin-for-pin-raise-and-fall-in-zephyr</link><description>hello Nordic 
 i am working with nrf52840, with zephyr 2.6.9, ncs 1.7.1 
 i want to have an interrupt on a pin toggle and have a callback for up and one for down 
 i configure the pin as follows: 
 
 but initialising the callback i don&amp;#39;t see how i can</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 18 Mar 2022 09:00:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85806/how-to-set-2-separate-callbacks-on-the-same-pin-for-pin-raise-and-fall-in-zephyr" /><item><title>RE: how to set 2 separate callbacks on the same pin, for pin raise and fall in zephyr</title><link>https://devzone.nordicsemi.com/thread/358793?ContentTypeID=1</link><pubDate>Fri, 18 Mar 2022 09:00:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d756489-8842-4c6c-b38f-b0fd59b00e99</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;hi Priyanka&lt;/p&gt;
[quote userid="107729" url="~/f/nordic-q-a/85806/how-to-set-2-separate-callbacks-on-the-same-pin-for-pin-raise-and-fall-in-zephyr/358663#358663"]you could try to use the &lt;a href="https://docs.zephyrproject.org/latest/reference/peripherals/gpio.html#:~:text=and%20enables%20it.-,GPIO_INT_EDGE_BOTH,-%C2%B6"&gt;GPIO_INT_EDGE_BOTH&lt;/a&gt; and check the pin state in the callback maybe.[/quote]
&lt;p&gt;that is what i have done but if i remember correct nrf sdk dose allow to have 2 callbacks on same pin one for ACTIVE_HIGH and one for ACTIVE_LOW&amp;nbsp;&lt;/p&gt;
&lt;p&gt;i understand from your answer that it is not the case with zephyr&lt;/p&gt;
&lt;p&gt;ok, thanks&amp;nbsp;&lt;span&gt;Priyanka&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to set 2 separate callbacks on the same pin, for pin raise and fall in zephyr</title><link>https://devzone.nordicsemi.com/thread/358663?ContentTypeID=1</link><pubDate>Thu, 17 Mar 2022 13:17:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea4a1870-7906-4fcc-b3a1-43bfdb43c438</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi Ziv,&lt;/p&gt;
&lt;p&gt;This is not possible to implement as the flags are configured per pin and not per &lt;a href="https://docs.zephyrproject.org/latest/reference/peripherals/gpio.html#:~:text=static%20inline%20void-,gpio_init_callback(,-struct%20gpio_callback%20*callback"&gt;callback&lt;/a&gt;. It is possible to add &lt;a href="https://docs.zephyrproject.org/1.14.0/reference/peripherals/gpio.html#:~:text=gpio_pin_enable_callback"&gt;multiple callbacks for a single pin&lt;/a&gt;, but only one interrupt configuration can be used for the pin. But, you could try to use the &lt;a href="https://docs.zephyrproject.org/latest/reference/peripherals/gpio.html#:~:text=and%20enables%20it.-,GPIO_INT_EDGE_BOTH,-%C2%B6"&gt;GPIO_INT_EDGE_BOTH&lt;/a&gt; and check the pin state in the callback maybe.&lt;/p&gt;
&lt;p&gt;You can take a look at few examples:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/main/tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c"&gt;test callback&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/include/drivers/gpio.h"&gt;Gpio.h&amp;nbsp;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>