UxDIL Software Collection
This folder contains the template files for a raw (user defined) Human Interface Device (HID) firmware. In addition to the defined communication flows of the control transfers, “HID” defines also a set of predefined communication flows. If a device like this is connected with the host, it will find a new known device and will install the required drivers. They are coming with the operating system. The PC application software has to communicate with an HID device. Standard interface library code and DLLs are available. A “raw” HID is no keyboard, mouse or any other standard device. It is a user defined device. That means, we have the restricted communication rules of an HID, but we are free, which data is exchanged between host and device.
The advantage of a raw Human Interface Device:
No delivery of special drivers required. Any operating system comes with the necessary files. A new device will be installed automatically.
The disadvantages:
The communication code on the host side is more complicated.
A low real data rate. In practice only suitable for small, not very time critical data packages.
usb_rawhid_config.h
This file contains general agreements. You will modify this file for your purposes. A special point of interest will be the following defines:
STR_MANUFACTURER |
Your vendor name. Insert your company or personal name. |
STR_PRODUCT |
Your product name. Insert the name of the product. |
USESN |
0: no serial number (new driver installation, if device is plugged in another USB plug) 1: fixed serial number in flash memory 2: a changeable serial number (e.g. from EEPROM), loaded into variable RAMSN (usb_serial.h) by the firmware If a serial number is used, the drivers for the device will be installed only one time, independent from the used plug. |
STR_SERIAL_NUMBER |
Insert the fixed serial number here, if USESN=1 |
VENDOR_ID |
Your official vendor ID. Don't use the predefined ID of the template or any you like, if you want to sell the product! |
PRODUCT_ID |
Your official product ID. Don't use the predefined ID of the template or any you like, if you want to sell the product! |
POWERING |
Set to SELFPOWERED and/or BUSPOWERED, if your device is powered by his own supply and/or via USB plug. |
MAXPOWER |
Insert the bus powered current consumption of the device in milliamperes. The maximum allowed value is 500 (mA). |
The other definitions in this file shouldn't be changed to keep a compatible human interface device!
usb_rawhid.h
This file contains the definitions of some routines, which are needed. Usually no changes has been made!
usb_rawhid.c
This file contains the USB routine code for general USB communication and the HID. Usually no changes has been made!
main.c
Use this file as a base for your new project! The template contains the callback routines, which will be automatically called by the specific event. For example “usb_ep()” is called, if data is received from host. On the other hand you can call “usb_txdata()” to return data to host. The main routine has to contain the routine call “usb_init()” (initialize USB) and “sei()” (enable interrupts).
Make the template main.c file as your main file. Add the usb_rawhid files to the project. After compiling, upload into the microcontroller and connecting with the PC, it should find a new human interface device.
For more information refer to the examples.