<?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>Long button sleep/wakeup</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/27699/long-button-sleep-wakeup</link><description>Hi! 
 I would like to use long button press to send device into sleep mode (using BSP module). Since button is tied to ground, when device goes to sleep mode, and when I release button, there is transition on IO pin, and device goes back from sleep.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 30 Nov 2017 06:38:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/27699/long-button-sleep-wakeup" /><item><title>RE: Long button sleep/wakeup</title><link>https://devzone.nordicsemi.com/thread/109345?ContentTypeID=1</link><pubDate>Thu, 30 Nov 2017 06:38:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07194e96-5f29-4432-aff9-8a42ee7db75c</guid><dc:creator>Sejl</dc:creator><description>&lt;p&gt;Again, let me comment on myself :)&lt;/p&gt;
&lt;p&gt;If I&amp;#39;m already setting flag for a device to shutdown, I can turn off everything in this procedure, and then just shut down processor on button release. Customer will see that device is apparently turned off when shutdown flag has been set, and will release button...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Long button sleep/wakeup</title><link>https://devzone.nordicsemi.com/thread/109344?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2017 15:28:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d19f559-6847-414d-8f92-54f8573d2335</guid><dc:creator>Sejl</dc:creator><description>&lt;p&gt;Yes, that is an option, but as in original post my pcb is already layed out so...
Thank you anyway.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Long button sleep/wakeup</title><link>https://devzone.nordicsemi.com/thread/109340?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2017 15:10:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d15b83a-7cbc-41b0-ab45-031a1f882632</guid><dc:creator>J&amp;#248;rn</dc:creator><description>&lt;p&gt;Yet another possibility, as described in &lt;a href="https://devzone.nordicsemi.com/question/70332/wakeup-at-lo-hi-transition-not-just-state-sense/"&gt;this post&lt;/a&gt; is to use the low power comparator to trigger a wake-up signal on high to low transition. That way you can simply disable sensing of the pin, and configure the LPCOMP. This will allow the chip to go to sleep, as the DETECT signal will now be low, and releasing the button will not affect it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Long button sleep/wakeup</title><link>https://devzone.nordicsemi.com/thread/109343?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2017 14:32:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0bb9a6aa-3120-4342-81e0-afb5b9e44c21</guid><dc:creator>Sejl</dc:creator><description>&lt;p&gt;This is exactly what I am doing right now :)
Thank you!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; It is working. However, it is not elegant solution because device is powered off upon release. Customer can expect to hold down button until device turns off, and it will never happen until he releases the button. But, OK....&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Long button sleep/wakeup</title><link>https://devzone.nordicsemi.com/thread/109342?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2017 14:31:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f94445d7-9e04-4b02-8b93-e97bb916638f</guid><dc:creator>J&amp;#248;rn</dc:creator><description>&lt;p&gt;Another possibility is instead of triggering the actual sleep routine by the long press, the long press detection could simply set a flag, and when the release of the button triggers a new event you can perform a check on said flag and go to sleep if it is set.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Long button sleep/wakeup</title><link>https://devzone.nordicsemi.com/thread/109341?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2017 14:27:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83bdb409-de95-41c3-a2bd-5f3aab448017</guid><dc:creator>Sejl</dc:creator><description>&lt;p&gt;Since there is only one button in my system, I will have to rethink moving sleep action from long press to short.
Thank you for your answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Long button sleep/wakeup</title><link>https://devzone.nordicsemi.com/thread/109339?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2017 14:00:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4fe9bcf1-9dd3-4cc9-a6e2-9e8916d0363b</guid><dc:creator>J&amp;#248;rn</dc:creator><description>&lt;p&gt;Hello Sejl&lt;/p&gt;
&lt;p&gt;According to the product specification page 44, the chip is brought out of system off by an active DETECT signal. The DETECT signal is generated when a pin is in the state it is configured to sense. The bsp module uses the app_button library, which in turn uses GPIOTE.&lt;/p&gt;
&lt;p&gt;By default it configures the buttons to detect toggle, this is implemented by the GPIOTE driver by changing the sense configuration for the specific pin whenever the DETECT signal triggers. So as you push the button, the pin it is connected to goes low, which triggers a low-to-high transition of the DETECT signal. The GPIOTE driver then changes the polarity, causing the DETECT signal to go low again, and then executes the specified handlers. Now your button is specified to generate a DETECT signal on a high input, which is what you get when you release the button.&lt;/p&gt;
&lt;p&gt;You could try use bsp_buttons_disable() and bsp_wakeup_button_enable before you initiate sleep. The first function disables sense for all buttons, and the second enables sensing for the state defined as active state in pca10028.h (Low state).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I realized this wouldn&amp;#39;t work properly if your designated wake-up pin is the same as the pin you use to put it to sleep as the button would naturally have a high DETECT signal since you&amp;#39;re holding it down. You would then need to wait to initate the sleep until you have released the button, or use different buttons for sleep and wake.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Jørn Frøysa&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>