Post History
What should the firmware do when it detects that VBUS (re)appeared? What should the firmware do when VBUS has disappeared? I'm not familiar with the STM32 USB library, and have only dealt with th...
Answer
#3: Post edited
- <blockquote> What should the firmware do when it detects that VBUS (re)appeared? What should the firmware do when VBUS has disappeared?</blockquote>
- I'm not familiar with the STM32 USB library, and have only dealt with this on PICs using my own USB library. I'll therefore answer the generic case.
- The most important thing for the USB library to know is when a logical USB connection is opened and closed. Particularly when a new connection is opened, it needs to start with empty buffers.
- Depending on how the hardware works, there may not be a need to know when a connection is closed. Something might be waiting for new packets that never come without any harm caused. In some cases there may be efficiency advantages to knowning there is no connection. For example, my USB library discards data the app tries to send when it knows there is no logical connection.
- In this context, detecting V<sub>bus</sub> is not strictly necessary. If the USB is not physically connected, the firmware should already know there is no logical connection.
- Detecting lack of physical connection might be a convenient shortcut to absolutely knowing there is no logical connection, but ultimately it is the logical connection that you need to know is open or not. You already have to deal with that when the host does enumeration and establishes a logical connection.
Depending on how the hardware works, it may be necessary or desirable to reset it when a new physical connection is detected.
- <blockquote> What should the firmware do when it detects that VBUS (re)appeared? What should the firmware do when VBUS has disappeared?</blockquote>
- I'm not familiar with the STM32 USB library, and have only dealt with this on PICs using my own USB library. I'll therefore answer the generic case.
- The most important thing for the USB library to know is when a logical USB connection is opened and closed. Particularly when a new connection is opened, it needs to start with empty buffers.
- Depending on how the hardware works, there may not be a need to know when a connection is closed. Something might be waiting for new packets that never come without any harm caused. In some cases there may be efficiency advantages to knowning there is no connection. For example, my USB library discards data the app tries to send when it knows there is no logical connection.
- In this context, detecting V<sub>bus</sub> is not strictly necessary. If the USB is not physically connected, the firmware should already know there is no logical connection.
- Detecting lack of physical connection might be a convenient shortcut to absolutely knowing there is no logical connection, but ultimately it is the logical connection that you need to know is open or not. You already have to deal with that when the host does enumeration and establishes a logical connection.
- Depending on how the hardware works, it may be necessary or desirable to reset it when a new physical connection is detected. Note that detecting V<sub>bus</sub> is not the only way to do that. Another scheme is detecting no sync packets for some minimum time. They are sent every 1 ms when the USB connection is intact. If you don't see a sync packet for 100 ms, for example, something is definitely very wrong with the connection, whether power voltage is present or not.
#2: Post edited
- <blockquote> What should the firmware do when it detects that VBUS (re)appeared? What should the firmware do when VBUS has disappeared?</blockquote>
- I'm not familiar with the STM32 USB library, and have only dealt with this on PICs using my own USB library. I'll therefore answer the generic case.
- The most important thing for the USB library to know is when a logical USB connection is opened and closed. Particularly when a new connection is opened, it needs to start with empty buffers.
- Depending on how the hardware works, there may not be a need to know when a connection is closed. Something might be waiting for new packets that never come without any harm caused. In some cases there may be efficiency advantages to knowning there is no connection. For example, my USB library discards data the app tries to send when it knows there is no logical connection.
- In this context, detecting V<sub>bus</sub> is not strictly necessary. If the USB is not physically connected, the firmware should already know there is no logical connection.
Detecting lack of physical connection might be a convenient shortcut to absolutely knowing there is no logical connection, but ultimately it is the logical connection that you need to know is open or not. You already have to deal with that when the hosts does enumeration and establishes a logical connection.- Depending on how the hardware works, it may be necessary or desirable to reset it when a new physical connection is detected.
- <blockquote> What should the firmware do when it detects that VBUS (re)appeared? What should the firmware do when VBUS has disappeared?</blockquote>
- I'm not familiar with the STM32 USB library, and have only dealt with this on PICs using my own USB library. I'll therefore answer the generic case.
- The most important thing for the USB library to know is when a logical USB connection is opened and closed. Particularly when a new connection is opened, it needs to start with empty buffers.
- Depending on how the hardware works, there may not be a need to know when a connection is closed. Something might be waiting for new packets that never come without any harm caused. In some cases there may be efficiency advantages to knowning there is no connection. For example, my USB library discards data the app tries to send when it knows there is no logical connection.
- In this context, detecting V<sub>bus</sub> is not strictly necessary. If the USB is not physically connected, the firmware should already know there is no logical connection.
- Detecting lack of physical connection might be a convenient shortcut to absolutely knowing there is no logical connection, but ultimately it is the logical connection that you need to know is open or not. You already have to deal with that when the host does enumeration and establishes a logical connection.
- Depending on how the hardware works, it may be necessary or desirable to reset it when a new physical connection is detected.
#1: Initial revision
<blockquote> What should the firmware do when it detects that VBUS (re)appeared? What should the firmware do when VBUS has disappeared?</blockquote> I'm not familiar with the STM32 USB library, and have only dealt with this on PICs using my own USB library. I'll therefore answer the generic case. The most important thing for the USB library to know is when a logical USB connection is opened and closed. Particularly when a new connection is opened, it needs to start with empty buffers. Depending on how the hardware works, there may not be a need to know when a connection is closed. Something might be waiting for new packets that never come without any harm caused. In some cases there may be efficiency advantages to knowning there is no connection. For example, my USB library discards data the app tries to send when it knows there is no logical connection. In this context, detecting V<sub>bus</sub> is not strictly necessary. If the USB is not physically connected, the firmware should already know there is no logical connection. Detecting lack of physical connection might be a convenient shortcut to absolutely knowing there is no logical connection, but ultimately it is the logical connection that you need to know is open or not. You already have to deal with that when the hosts does enumeration and establishes a logical connection. Depending on how the hardware works, it may be necessary or desirable to reset it when a new physical connection is detected.