-*- lisp -*- Some dev notes on the usb driver. DEV DOC -- USB TRANSFER TREE An attempt to make sense of the plethora of USB requests. The idea is to compile a decoder from a description, instead of writing all by hand. There's two sides to the story. (A) getting a set of records about the device on the chip (B) generating the usb service routine I'd like to keep both as minimal as possible. Since the (A) part is just data, it should be entered in the form of s expressions. A lot of defaults could be used. Given (A), there should be enough data to perform (B). Tasks to do: Some simplifications and random implementation remarks - support only one configuration - need string management - need pluggable descriptor management (i.e. HID) - interfaces are 'virtual devices' - without bAlternateSetting, is there need for SetInterface? - string index 0 returns a list of languages see http://www.beyondlogic.org/usbnutshell/ ;; TRANSFER TREE Some remarks for the standard requests. I find it clearer to separate device, interface and endpoint requests out, then divide the requests into setters and getters. ((0x1 in) (0x3 out) (0xD setup (0x1 class) (0x2 vendor) (0x0 standard (0x0 device (0x0 set (0x05 set-address) (0x07 set-descriptor) (0x09 set-configuration) (0x01 clear-feature) (0x03 set-feature)) (0x1 get (0x00 get-status) (0x08 get-configuration) (0x06 get-descriptor (0x1 device) (0x2 configuration) ; sends interfaces too (0x3 string)))) (0x1 interface (0x0 set (0x01 clear-feature) (0x03 set-feature) (0x0a set-interface)) (0x1 get (0x00 get-status) (0x0b get-interface))) (0x2 endpoint (0x0 set (0x01 clear-feature) (0x03 set-feature)) (0x1 get (0x00 get-status) (0x0c synch-frame)))))) ;; DESCRIPTOR RECORDS ((device (0 b Length) (1 b DescryptorType 1) (2 bcd USB 0x110) (4 b DeviceClass 0) (5 b DeviceSubClass 0) (6 b DeviceProtocol 0) (7 b MaxPacketSize0 8) (8 id Vendor 0x04D8) ; microchip (10 id Product 0x0001) (12 bcd Device 0) (14 i Manufacturer "Microchip Technology, Inc.") (15 i Product "USB Hack") (16 i SerialNumber "") (17 b NumConfigurations 1)) (configuration (0 b Length) (1 b DescryptorType 2) (2 w TotalLength) ; including all interfaces (4 b NumberInterfaces) ; number of interface descriptors (5 b ConfigurationValue 1) (6 i Configuration "") (7 bm Attributes 0xA0) ; remote wakeup (8 b MaxPower 0x32)) ; 100 mA (string (0 b Length) (1 b DescriptorType 3) (2 b String)) (interface (0 b Length) (1 b DescriptorType 4) (2 b InterfaceNumber) (3 b AlternateSetting 0) (4 b NumEndpoints) (5 b InterfaceClass 0xFF) (6 b InterfaceSubClass 0x00) (7 b InterfaceProtocol 0xFF) (8 i Interface "")) (endpoint (0 b Length) (1 b DescriptorType 5) (2 b EndpointAddress) (3 bm Attributes) (4 w MaxPacketSize) (6 b Interval))) ;; EXAMPLE DEVICE CONFIG FILE (device (Product "general funny keyboard") (Interfaces ((NumEndpoints 1) (InterfaceClass 3) ;; HID code (InterfaceSubClass 1) ;; Boot subclass (InterfaceProtocol 1)))) ;; Keyboard protocol