I don't understand why you would plug a battery charger into a USB port? How many people don't have an extra power plug, but do have a laptop that they are going to let run for hours to charge their AA batteries.
If you are on the move it can be quite handy. Instead of dragging N wall warts with you (esp. if you're traveling internationally, as the cheap ones often are 110V only), you just use your laptop as a universal power adapter.
But that's one thing. To get power out of a usb port, you don't need to install any software. And that's what blows my mind, why would you even want to install some software to run a battery charger??
To get power out of a usb port, you don't need to install
any software. And that's what blows my mind, why would
you even want to install some software to run a battery
charger??
You are right. The 5V and GND are right there. You don't need to enumerate the device at all. Just tap the power and be on your way. A lot of cheap products to that..
However, there are two reasons that you shouldn't do that, and why you need your device to actually enumerate itself on the users system.
The important reason, is to insure that the 500mA you think you have coming to you, is actually delivered. Technically, a motherboard can choose to assume you are broken, and disable the USB port, if you draw more than 100mA and haven't identified yourself as a high current device. Almost nobody actually does this, but the risk is there.
The 2nd reason is so you can place the little USB-IF logo on your product, reassuring people that your product complies with the USB specs. This logo, in the early days of USB, was very important. It's less so now. If you want it, you need to enumerate within $time (I forget the number of milliseconds) after you begin drawing power. If you don't, USB-IF doesn't like you and you can't put the logo on your product.
Both items 1 and 2 could be accomplished using just the USB controller in the USB device, with no driver needed ... But only if the USB controller lied about who it was. It would have to say, "I'm a hard disk", or "I'm a speaker". As soon as you lie, you're also not USB-IF compliant. Plus, it will look pretty unprofessional to have your battery charger show up on the hardware manifest as a hard drive. It would have been better to not enumerate at all, then to do that.
So, you need to supply a driver, if you're doing something that every OS doesn't have drivers for already, even if technically, it's not required.
So, really, this was Bill Gates fault. I knew we could lay this one on him if we dug deep enough. Windows should ship with OS drivers for USB battery chargers. Curse you Bill Gates, curse you.
Another issue is that USB ports have a pretty small power limit - 2.5 Watts, so using it as a charger is going to take significantly longer than what you plug into the wall...
But that's one thing. To get power out of a usb port, you don't need to install any software. And that's what blows my mind, why would you even want to install some software to run a battery charger??