<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Detect USB connect/disconnect using USBD ROM Stack? in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523371#M6007</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Sat Dec 12 09:06:00 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Note: I am on LPC1778, my UM says that 5V from USB connector must be available&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;on USB_PWRDx pin for detection to work!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From UM10470 (LPC17x8) Chapter 6 Pin Configuration&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;USB_PWRD1 — Power Status for USB port 1 (host power switch). When using the &lt;BR /&gt;chip in USB host mode, the USB_PWRD input must be enabled. The USB host &lt;BR /&gt;controller will only detect a device connect event when the port power bit is set in &lt;BR /&gt;the OHCI and the USB_PWRD bit is asserted for the corresponding port.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;THIS LITTLE NUGGET SHOULD BE STATED IN THE USB HOST SECTION OF THE MANUALS!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On our board (self powered) we feed in 5V to the pin via a 47K (I think, don't quote me) series resistor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers, Mike.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 16:43:06 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T16:43:06Z</dc:date>
    <item>
      <title>Detect USB connect/disconnect using USBD ROM Stack?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523367#M6003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lpetersen on Wed Dec 09 12:56:37 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I've implemented a USB Device MSC on an LPC1837, using LPCOpen 2.12 and based on the usbd_rom_msc_ram example (modified to use external memory). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm able to see the device show up in Windows as a drive, and format it through Windows. Now I need to be able to detect when the user has either 'ejected' the drive from Windows or physically disconnected USB so that I can access the files in memory. I can't seem to find documentation on an interrupt or status bit to poll. How can I detect USB connect/disconnect events using the USBD ROM stack?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Much appreciated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:43:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523367#M6003</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Detect USB connect/disconnect using USBD ROM Stack?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523368#M6004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Thu Dec 10 06:40:33 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Read the OHCI document &lt;/SPAN&gt;&lt;A href="http://www.scaramanga.co.uk/stuff/qemu-usb/hcir1_0a.pdf"&gt;here&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See the current connect status in the port[N] status register Sect 7.4.4&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You need to ensure that the rhsc (root hub status change) bit is set in the hcInterruptEnable register. Sect 7.1.5&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then on an interrupt look at the connect status.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BTW, I never used the ROM driver (I don't think that the LPC1778 even has one!),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;so I cannot give specifics to actually achieve the steps above. Presumably the docs on the various functions&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and structures of the ROM API should help once you know what you are looking for.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HTH.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers, Mike.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:43:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523368#M6004</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Detect USB connect/disconnect using USBD ROM Stack?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523369#M6005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lpetersen on Fri Dec 11 14:14:47 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Mike. That was helpful in pointing me in the right direction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I found a status bit in USB0's PORTSC1_D register for CCS which sounded promising. Upon further investigation though, that status bit does not change even when physically disconnecting USB. According to the user manual - &lt;/SPAN&gt;&lt;I&gt;&lt;BR /&gt;"A zero indicates that the device did not attach successfully or was forcibly disconnected by the software writing a zero to the Run bit in the USBCMD register. &lt;STRONG&gt;It does not state the device being disconnected or suspended&lt;/STRONG&gt;." &lt;/I&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which I found to be true. There is another bit in that same register, SUSP, which indicates when the device is in a suspended mode. It looks like I can use this to determine when USB has been physically disconnected (SUSP goes high, indicating that the device is suspended), but the status remains 'Not Suspended' even when I 'Eject' from Windows.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know if I am going about this the right way? Is there a way to detect that windows 'ejected' the device even if it is still physically connected? Does the USBD ROM stack provide any handles into this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:43:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523369#M6005</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: Detect USB connect/disconnect using USBD ROM Stack?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523370#M6006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Sat Dec 12 08:46:24 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;My bad, I was going by memory and a cursory re-read of the OHCI manual.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my Interrupt handler (when root hub status change is noted), I actually check&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;bit 16 of the PortStatus[N] register called CSC in the OHCI doc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If this is set, then I capture the CCS bit I previously mentioned (bit 0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and stash this in a (volatile) variable that the rest of the "C" code can see.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;These bit names are confusing and easy to mis-spell aren't they.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note: I cannot share: It is written in assembler and is also company confidential.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NB: remember to (a) clear the status &lt;/SPAN&gt;&lt;I&gt;change&lt;/I&gt;&lt;SPAN&gt; bit(s) in the PortStatus and&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(b) clear the IrqStatus bit(s) in the InterruptStatus in the IRQ handler.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My "C" code polls the 'connected' variable (via a function) ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;static void
WaitInsert(void)
{
static
ulongftt = 1;
ucharwrk[128], s[256];
ulongrc;

if (prvConnect == usbConnect)// any change?
return;// nope

//--------------------------------------//
prvConnect = usbConnect;// remember change

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do stuff depending on insert (1, non-zero) or remove (0) ...

&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers, Mike.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:43:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523370#M6006</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Detect USB connect/disconnect using USBD ROM Stack?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523371#M6007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Sat Dec 12 09:06:00 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Note: I am on LPC1778, my UM says that 5V from USB connector must be available&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;on USB_PWRDx pin for detection to work!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From UM10470 (LPC17x8) Chapter 6 Pin Configuration&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;USB_PWRD1 — Power Status for USB port 1 (host power switch). When using the &lt;BR /&gt;chip in USB host mode, the USB_PWRD input must be enabled. The USB host &lt;BR /&gt;controller will only detect a device connect event when the port power bit is set in &lt;BR /&gt;the OHCI and the USB_PWRD bit is asserted for the corresponding port.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;THIS LITTLE NUGGET SHOULD BE STATED IN THE USB HOST SECTION OF THE MANUALS!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On our board (self powered) we feed in 5V to the pin via a 47K (I think, don't quote me) series resistor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers, Mike.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:43:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523371#M6007</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Detect USB connect/disconnect using USBD ROM Stack?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523372#M6008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Sat Dec 12 09:12:42 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;PLEASE IGNORE MY POSTS&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had assumed that you were implementing a HOST not a DEVICE.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have no experience coding for device.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry, Mike.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:43:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523372#M6008</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Detect USB connect/disconnect using USBD ROM Stack?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523373#M6009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lpetersen on Mon Jan 11 12:22:14 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Still looking for info on this, does anybody have any input for USB device using the ROM stack?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:43:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Detect-USB-connect-disconnect-using-USBD-ROM-Stack/m-p/523373#M6009</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:43:07Z</dc:date>
    </item>
  </channel>
</rss>

