A Look at HIDmaker FS 's Generated Peripheral Source Code

The Universal Serial Bus is a highly unsymmetrical Master - Slave technology. That's just a fancy way of saying that USB peripheral devices do much different things than the PC host computer has to do. USB was designed that way so that peripherals could be as inexpensive as possible, e.g. by only being able to talk to the PC Host when the host asks for data. (Peripheral devices cannot talk directly to each other.)

The USB peripheral side code has to work on a small, cheap microcontroller that is a lot slower and has a whole lot less memory than your PC.

For all these reasons, HIDmaker's generated USB software for peripherals much different than the code for the PC host.

The generated peripheral code does not have an operating system, but HIDmaker's code knows how to send and receive data over the USB, and it even knows how to pack and unpack the USB data in the standard way that the PC also understands. This saves you a HUGE amount of time and effort!

The next pages give you a look at some parts of HIDmaker's generated PIC peripheral source code.

USB Descriptors

For most PIC compilers, HIDmaker FS generates a mixture of high level language (for you to work with), and highly optimized assembly language (to make the USB library code, that you don't need to touch, as fast and and compact, yet as powerful as we can make it).

HIDmaker FS is the only USB solution we know of that automatically generates all of the USB descriptors that your project needs. This includes the complex HID Report Descriptor. (Some customers who use microcontroller brands other than Microchip have bought HIDmaker FS just for that feature alone.)

As an example, here is the actual HID Report Descriptor, in PIC18 assembly language, that HIDmaker FS has generated for our Varty16 sample project:

;=============================================================

; REPORT DESCRIPTOR: Report1

; Config 1, Interface 0, Alt 0 Report1

;=============================================================


Report1:

retlw 0x06 ;Usage Page (65280),

retlw 0x00

retlw 0xFF

retlw 0x0A ;Usage (65521),

retlw 0xF1

retlw 0xFF

retlw 0xA1 ;Collection ( Application ) ; App_Collection_1

retlw 0x01

retlw 0x15 ; Logical Minimum (-128),

retlw 0x80

retlw 0x25 ; Logical Maximum (127),

retlw 0x7F

retlw 0x95 ; Report Count (1),

retlw 0x01

retlw 0x75 ; Report Size (8),

retlw 0x08

retlw 0x09 ; Usage (1),

retlw 0x01

retlw 0x81 ; Input (Data, Variable, Absolute) ; In8bit

retlw 0x02

retlw 0x26 ; Logical Maximum (130),

retlw 0x82

retlw 0x00

retlw 0x75 ; Report Size (9),

retlw 0x09

retlw 0x09 ; Usage (2),

retlw 0x02

retlw 0x81 ; Input (Data, Variable, Absolute) ; In9bit

retlw 0x02

retlw 0x16 ; Logical Minimum (-32768),

retlw 0x00

retlw 0x80

retlw 0x26 ; Logical Maximum (32767),

retlw 0xFF

retlw 0x7F

retlw 0x95 ; Report Count (15),

retlw 0x0F

retlw 0x75 ; Report Size (16),

retlw 0x10

retlw 0x09 ; Usage (3),

retlw 0x03

retlw 0x81 ; Input (Data, Variable, Absolute) ; In16bitArray

retlw 0x02

retlw 0x16 ; Logical Minimum (-4096),

retlw 0x00

retlw 0xF0

retlw 0x26 ; Logical Maximum (4095),

retlw 0xFF

retlw 0x0F

retlw 0x95 ; Report Count (1),

retlw 0x01

retlw 0x75 ; Report Size (13),

retlw 0x0D

retlw 0x09 ; Usage (4),

retlw 0x04

retlw 0x81 ; Input (Data, Variable, Absolute) ; In13bit

retlw 0x02

retlw 0x15 ; Logical Minimum (-16),

retlw 0xF0

retlw 0x25 ; Logical Maximum (15),

retlw 0x0F

retlw 0x75 ; Report Size (5),

retlw 0x05

retlw 0x09 ; Usage (5),

retlw 0x05

retlw 0x81 ; Input (Data, Variable, Absolute) ; In5bit

retlw 0x02

retlw 0x15 ; Logical Minimum (-128),

retlw 0x80

retlw 0x25 ; Logical Maximum (127),

retlw 0x7F

retlw 0x95 ; Report Count (6),

retlw 0x06

retlw 0x75 ; Report Size (8),

retlw 0x08

retlw 0x09 ; Usage (6),

retlw 0x06

retlw 0x91 ; Output (Data, Variable, Absolute) ; Out8bitArray

retlw 0x02

retlw 0x95 ; Report Count (63),

retlw 0x3F

retlw 0x09 ; Usage (7),

retlw 0x07

retlw 0x81 ; Input (Data, Variable, Absolute) ; In8bitArray

retlw 0x02

retlw 0x95 ; Report Count (1)

retlw 0x01

retlw 0x75 ; Report Size (5)

retlw 0x05

retlw 0x81 ; Input (Constant), ; Padding added by HIDmaker

retlw 0x03

retlw 0x15 ; Logical Minimum (-64),

retlw 0xC0

retlw 0x25 ; Logical Maximum (63),

retlw 0x3F

retlw 0x95 ; Report Count (1),

retlw 0x01

retlw 0x75 ; Report Size (7),

retlw 0x07

retlw 0x06 ; Usage Page (65280),

retlw 0x00

retlw 0xFF

retlw 0x09 ; Usage (8),

retlw 0x08

retlw 0x91 ; Output (Data, Variable, Absolute) ; Out7bit

retlw 0x02

retlw 0x95 ; Report Count (1)

retlw 0x01

retlw 0x75 ; Report Size (1)

retlw 0x01

retlw 0x91 ; Output (Constant), ; Padding added by HIDmaker

retlw 0x03

retlw 0xC0 ;End Collection

; This is the ending label of report descriptor Report1

EndReport1:

 

 

All USB descriptors that HIDmaker FS generates are profusely commented, to aid your understanding and to make it possible to modify them by hand if you ever need to. (We don't recommend that, but it's still an option.)

Despite severe limitations on USB what USB peripherals can do as compared to what the PC host can do, you'll be amazed at how smart a HIDmaker FS peripheral can be!

 

HIDmaker Step By Step