Alright, at first, you have to know that we cannot to explain to you that how the USB works or how you can use it (because that's too broad) but we can give you some clue until yourself understand it.
This serial bus is organized in a star topology with host and device roles, host organizing the traffic.
Several device classes are specified, in order to ease communication in different application cases. you can see them here. they are:
- OTG : On-The-Go: An OTG peripheral can switch host and device role on the fly
- HUB : Defines what protocols to implement to build a hub application
- MS : Mass storage: Protocols to interact with storage block devices (for files)
- HID : Human interface device: Protocols for peripherals interacting with human body (mouse, keyboard, etc.)
- CDC : Communication device class: Protocols for serial communications, different sub-classes define details, for instance ACM for a standard COM port, or ECM for modems
- Printer : Defines what protocols to implement to build a printer application
- Audio : Defines what protocols to implement to build an audio application (microphone, headset, etc.)
- DFU : Device firmware upgrade: Protocols to implement firmware upgrade ability
For using the USB you can use some middleware stack. for example: CMX, EUROS, Express Logic, HCC, Keil/ARM, Micrium and etc
I just can see one of them that is free. take a look in this link and downlaod the ST USB stack (USB FS device library, USB FS&HS Host&Device lib, Continua USB certified stack). by this Stack and it's documentations, you can use it easily and if you want to know what's going on when you use it, you can see to the source and header files.
I hope this quick consultation will help you.