<?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>Thingy91 usb power state change</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/56387/thingy91-usb-power-state-change</link><description>Hi, 
 
 I am working on the Thingy91 and trying to set up an event when the USB power state changes (USB cable w/power is plugged or unplugged). For now I will just blink an LED or something simple. I have a few references but nothing that solves the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 21 Jan 2020 15:09:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/56387/thingy91-usb-power-state-change" /><item><title>RE: Thingy91 usb power state change</title><link>https://devzone.nordicsemi.com/thread/230118?ContentTypeID=1</link><pubDate>Tue, 21 Jan 2020 15:09:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8eed914f-f3ae-4915-b817-0708b795ea73</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Yes, on the Thingy:91, the USB bus is connected to the nRF52. And I believe that would be the easiest way to detect the USB status changes.&lt;/p&gt;
&lt;p&gt;As you also mention, it is also possible to read the status registers of the PMIC. However, looking at our driver, it looks like you would have to poll here as well.&lt;/p&gt;
&lt;p&gt;The PMIC also has an interrupt line connected to the nRF9160. You might be able to use that one to provide an interrupt when the USB cable is connected (I have not studied the PMIC datasheet, nor the battery management code on the Thingy).&lt;/p&gt;
&lt;p&gt;Another possibility could be to get access to one of the GPIO pins connected to the NMOS header via a test pad and use that to generate an interrupt, assuming that the voltages from the battery/USB-connection is within the parameters of the GPIO PIN.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy91 usb power state change</title><link>https://devzone.nordicsemi.com/thread/229272?ContentTypeID=1</link><pubDate>Wed, 15 Jan 2020 17:45:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e7f7988-5b24-4312-a50f-e21ed3104467</guid><dc:creator>AndrewR</dc:creator><description>&lt;p&gt;I believe you are correct about the USB bus. At least for the thingy91 which I can confirm the HCI to USB is done through the 52. I think the 9160DK is a little different as there is a Jlink chip in between the chips and the USB. I do know however that the 9160 connects to the PMIC which is where I would think I would read the charge state. Looking for an event to trigger when the power via usb is provided or stopped I&amp;#39;m not concerned with any data connection. Here is the diagram showing the connections&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/pdf/Thingy91_UG_v1.0.pdf"&gt;https://infocenter.nordicsemi.com/pdf/Thingy91_UG_v1.0.pdf&lt;/a&gt; page 14&lt;/p&gt;
&lt;p&gt;I can confirm you can tell if there is power via USB by checking the bat voltage but I don&amp;#39;t how to use that to trigger an event without constantly checking the voltage. Seems like it would be rather power hungry compared to having a pin with a pull down/up on it. I appreciate your feedback!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy91 usb power state change</title><link>https://devzone.nordicsemi.com/thread/229262?ContentTypeID=1</link><pubDate>Wed, 15 Jan 2020 15:55:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f40a154e-153f-4266-b156-b72d3d8d0e1b</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;The nRF91 does not know USB, so you would have to implement the state recognition yourself.&lt;/p&gt;
&lt;p&gt;I am not familiar enough with USB to be able to tell how viable that would be. Also, while I have not studied the schematics for the Thingy:91, I do not believe the nRF91 is connected to the USB bus.&lt;/p&gt;
&lt;p&gt;It might be possible to detect a connected USB cable by reading the battery voltage, but that is just speculation on my part.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy91 usb power state change</title><link>https://devzone.nordicsemi.com/thread/229255?ContentTypeID=1</link><pubDate>Wed, 15 Jan 2020 15:27:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f46a77c7-f3aa-4e81-b1f3-caf0a29f3f38</guid><dc:creator>AndrewR</dc:creator><description>&lt;p&gt;I&amp;#39;ve been looking into this and trying to figure out how to implement. It seems I would have to get this running on the 52 side of the board and have the 52 send any usb events detect over the 9160 side to trigger an event where the 9160 can perform an action. Is there anyway to get the 9160 to directly listen for a USB power event and respond to that without the middle man 52 chip?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy91 usb power state change</title><link>https://devzone.nordicsemi.com/thread/228612?ContentTypeID=1</link><pubDate>Fri, 10 Jan 2020 14:27:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:343faeef-4268-4e9f-8cbe-2d5f84b248f7</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;While the nrf_desktop application is not supported on the Thingy:91, it should be possible to use the USB related code on the nRF52840 on the Thingy:91.&lt;/p&gt;
&lt;p&gt;This file might be closer to what you are looking for:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/applications/nrf_desktop/src/modules/usb_state.c"&gt;https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/applications/nrf_desktop/src/modules/usb_state.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Especially the usb_init function and device_status event handler.&lt;/p&gt;
&lt;p&gt;Once the nRF52840 knows the USB state, it can then be sent to the nRF9160 over UART.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>