tags:

views:

296

answers:

4

Hi, I am new to hardware programming(especially USB) so please bear with me and my questions. I am using C++ and I need to send/receive some data (a byte array) to/from a USB port on a microprocessor board.

Now, I have done some serial port programming before and I know that for a serial port you have to open a port, setup, perform i/o and finally close the port. I am guessing to use a USB port, it is not as simple as what I mentioned above.

I do know that I want to use Microsoft standard drivers and implement standard Windows IO commands to accomplish this, since I believe there are no drivers for the microprocessor board for me to interact with.

If somebody can point me in the right direction as to the steps needed to "talk" to a USB port (open, setup, i/o) via standard Windows IO commands, I would truly and greatly appreciate it. Thanks you so much!!

+1  A: 

By hardware programming, do you mean you will be programming the microcontroller? If so, there is no way you will use "standard windows drivers" or anything like that.

The USB standard is very thick. Check it out here

It is a very involved topic and I recommend finding USB implementations already created for your microcontroller. (which we may be able to find if you gave us more info)

Earlz
No I will not be programming the micro-controller....maybe I wasn't clear enough. I just need to write to and read from a USB port.
JB_SO
+6  A: 

USB in a nutshell is excellent background reading.

For a generic USB module try LibUSB which includes some examples of talking to standard devices. LibUSB-Win32 is the windows port of that library.

You're right though, it's nowhere near as simple as an RS232 port.

What microprossor are you using? Does it come with any USB hardware or are you thinking of trying to implement it all in software (not something I'd recommend even contemplating!). A lot of microprossors come with code samples which can emulate simple HID USB devices like keyboards / mice etc. which you can use as a starting point. Failing that, there's probably a few off-the-shelf options which will save you a lot of headaches :-)

Jon Cage
+1. Your answer is much more helpful than mine :)
Earlz
+1 good advice in all. On the device side, it's best to fit into existing Windows-side drivers and HID is a pretty flexible one.
kenny
A: 

What kind of microprocessor and what kind of board?

Many processors come with support for USB ports. Also, some hardware boards come with USB contollers too.

For example, the processor that my shop is using comes with two USB controllers that can act as a hub or as a device. We're even adding another processor to act as a USB controller.

Thomas Matthews
A: 

Find out the USB chipset used on the microprocessor board, e.g. Ftdi, Cypress, etc. These manufacturers supply drivers, libraries and example programs for the comms, this is the easiest way.

There are no 'standard' drivers unless your board is set up as an HID device.

SoftDeveloper