UxDIL Software Collection

Template: Serial

This folder contains the template files for a Communication Device Class (CDC) firmware. If a CDC device is connected to the host, you will find one more serial (COM) port. The application software on the PC will communicate with the device as a serial device. The baud rate and other settings (such like number of data bits, parity, stop bits) can be set, but doesn't matter.

The advantages of a CDC device:

The disadvantages:

The files of the Serial template

usb_serial_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 and new COM port number, 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 device generates only one COM port number, 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 CDC device!

usb_serial.h

This file contains the definitions of some routines, which are needed. Usually no changes has been made!

usb_serial.c

This file contains the USB routine code for general USB communication and the CDC device. 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_serial files to the project. After compiling, upload into the microcontroller and connecting with the PC, it should find a new COM port.

For more information refer to the examples.