michaeliv wrote:I see no reason to use a GPIO-controlled transistor. I guess there must be something I'm missing.
After looking into this, I managed to find some info on it.
Apparently the issue is that you should never ever ever pull down D+. So having a resistor to another GPIO might lead to pulling down D+ when there is no power supplied to the chip(if the chip is powered then you can restrict it to being floating / 3.3V only). I haven't tested if this is actually true for the STM32F103(if when powered off, current might flow from GPIO to ground).
Ironically a PNP transistor is the worst approach to achieve this since there will basically be a diode from D+ to another GPIO, so it can happen that D+ will be pulled down through diode + transistor base resistor + GPIO powered-off resistance when the device is powered off. So a MOSFET should be used.
To me this sounds kind of too corner-case to justify adding a transistor + 2 resistors to the board.
Thread about this issue:
http://www.eevblog.com/forum/projects/d ... stor-on-d/