<?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>Read GPIO Output State</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11275/read-gpio-output-state</link><description>Hi, 
 What is the best way to read the state of an output pin? I have an LED connected to a pin and want to know in a different part of the program whether the LED is currently on or off. 
 Thanks,</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 25 May 2017 08:06:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11275/read-gpio-output-state" /><item><title>RE: Read GPIO Output State</title><link>https://devzone.nordicsemi.com/thread/42407?ContentTypeID=1</link><pubDate>Thu, 25 May 2017 08:06:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff3e0f16-8c76-4e1a-ab4e-09c44bc698bd</guid><dc:creator>RPDben</dc:creator><description>&lt;p&gt;It appears so. However, this question was asked in reference to SDK 10. This function is only in SDK12 or later.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO Output State</title><link>https://devzone.nordicsemi.com/thread/42406?ContentTypeID=1</link><pubDate>Thu, 25 May 2017 07:38:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ce7ed51-f64c-4856-a165-78ea32f2d94d</guid><dc:creator>Eliot Stock</dc:creator><description>&lt;p&gt;Isn&amp;#39;t this what this function in &lt;code&gt;nrf_gpio.h&lt;/code&gt; is doing? &lt;code&gt;uint32_t nrf_gpio_pin_out_read(uint32_t pin_number)&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO Output State</title><link>https://devzone.nordicsemi.com/thread/42405?ContentTypeID=1</link><pubDate>Tue, 12 Jan 2016 15:33:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f904587-5a32-456d-85a5-57f187638ff8</guid><dc:creator>RPDben</dc:creator><description>&lt;p&gt;I think this is exactly what I was looking for, thanks. I will test it as soon as I can.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO Output State</title><link>https://devzone.nordicsemi.com/thread/42403?ContentTypeID=1</link><pubDate>Tue, 12 Jan 2016 15:26:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05deb728-a3cd-4bf4-96a1-fd5e85965700</guid><dc:creator>Wojtek</dc:creator><description>&lt;p&gt;You may try reading OUT register of GPIO, but I don&amp;#39;t think this is the best way to do this. It would be better to keep the state as variabl accessed by some &amp;quot;library&amp;quot;, or global one.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO Output State</title><link>https://devzone.nordicsemi.com/thread/42404?ContentTypeID=1</link><pubDate>Tue, 12 Jan 2016 15:25:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:405caae6-56d3-4a29-849e-84382c1d12fc</guid><dc:creator>Nikolaus Wittenstein</dc:creator><description>&lt;p&gt;You can just check the same register that you wrote to. Are you using &lt;code&gt;nrf_gpio_pin_write&lt;/code&gt;? If you dig into how it works, you can find the &lt;code&gt;OUT&lt;/code&gt;, &lt;code&gt;OUTSET&lt;/code&gt;, and &lt;code&gt;OUTCLR&lt;/code&gt; registers. The &lt;code&gt;OUTSET&lt;/code&gt; and &lt;code&gt;OUTCLR&lt;/code&gt; registers simply modify the &lt;code&gt;OUT&lt;/code&gt; register, which holds the current output state.&lt;/p&gt;
&lt;p&gt;In conclusion, &lt;code&gt;NRF_GPIO-&amp;gt;OUT&lt;/code&gt; is the register you&amp;#39;re looking for, and you just need to mask it to get the correct bit. The masking can also be found in &lt;code&gt;nrf_gpio.h&lt;/code&gt;, and will look something like this: &lt;code&gt;((NRF_GPIO-&amp;gt;OUT &amp;gt;&amp;gt; pin_number) &amp;amp; 1UL)&lt;/code&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>