r/microcontrollers • • Jun 12 '20

can a microcontroller read the input of a USB device (such as a mouse)?

if I wire the outputs of a usb device (such as a mouse) to the GPIO pins of a microcontroller, would it be able to read and interpret the signals, or is it too low-powered? (maybe there is a usb negotiation or something). How high-powered does the microcontroller need to be to read a usb device (such as a mouse) and get its signals, or what else is required?

0 Upvotes

11 comments sorted by

2

u/ceojp Jun 12 '20

Not through GPIO. It requires USB host/USB OTG. The good news is there are a lot of mid-level microcontrollers that support this.

1

u/curiousabtuc Jun 12 '20

what cost range are we looking at here?

1

u/[deleted] Jun 12 '20

Stm from 50c, Atmel from $1, depends on how big and meaty you need to be with the application.

2

u/skurk Jun 12 '20 edited Jun 12 '20

Just to nitpick, you can run V-USB on Atmel MCUs. I've used it earlier and it's a viable option. But for the path of least resistance I'd go for one with native USB host.

5

u/ProbablePenguin Jun 12 '20 edited Mar 16 '25

Removed due to leaving reddit

1

u/brendenderp Jun 12 '20

There is back and forth and mice and keyboards require drivers to be understood. You could make your own if your MCU is fast enough. Some micro controllers have usn support out of the box

1

u/curiousabtuc Jun 12 '20

oh okay. what range microcontrollers? (like in terms of cost)

0

u/[deleted] Jun 12 '20

[deleted]

1

u/curiousabtuc Jun 12 '20

ARM chipsets run Linux, right? If so, it's not what I meant. I meant a bare metal microcontroller without an operating system.

2

u/skurk Jun 12 '20

Not all ARM controllers are capable of running Linux (without tons of hacking), and those that do don't have to run it either. Consider it optional.

Take the popular Raspberry Pi, for example. I've written emulators for it that runs completely standalone, no operating system involved at all. However by doing so I had to supply my own drivers for USB, video, sound, SD card, ethernet, etc.

0

u/[deleted] Jun 12 '20

[deleted]

1

u/curiousabtuc Jun 12 '20 edited Jun 12 '20

you can't run linux on an arduino, an arduino isn't nearly powerful enough (64 kb of ram vs megabytes of necesssary RAM in the smallest possible Linux version, for example.)

someone managed to have one bit-bang an old RAM stick. The result took 2 hours to boot to a shell, and 4 more hours to boot Ubuntu.

in short, no way. an arduino can't run linux, it's not powerful enough, has much too little RAM, and isn't at least 32-bit as Linux requires.

1

u/Ironballs Jun 12 '20

The Atmel SAM C2x/D2x/D5x have native USB 2.0 host capabilities, they're about in the $1-2 USD range.

SAM C2x/D2x

SAM D5x

For instance, Arduino's use a FT2232 USB-to-serial converter to do the USB stuff, that's the second bit of silicon you see on the Arduino boards. But with these chips you won't need that.