Author: [email protected]
Date: Sun Mar 15 16:51:37 2009
New Revision: 854
Added:
trunk/include/peripheral/usb/usb_hid_generic_config.jal
trunk/include/peripheral/usb/usb_hid_keyboard_config.jal
Removed:
trunk/test/peripheral/usb/usb_hid_generic_config.jal
trunk/test/peripheral/usb/usb_hid_keyboard_config.jal
Log:
Update USB library files (moved config files)
Added: trunk/include/peripheral/usb/usb_hid_generic_config.jal
==============================================================================
--- (empty file)
+++ trunk/include/peripheral/usb/usb_hid_generic_config.jal Sun Mar 15
16:51:37 2009
@@ -0,0 +1,218 @@
+-- Title: USB Communication HID Device descriptor constants
+-- Author: Albert Faber, Copyright (c) 2008..2009, all rights reserved.
+-- Adapted-by: -
+-- Compiler: >=2.4j
+--
+-- This file is part of jallib (http:--jallib.googlecode.com)
+-- Released under the BSD license
(http:--www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: Constants for configuring the USB device
+-- --
+--
+-- Sources: http:--www.usb.org for USB specifications
+--
+-- Notes: not sure about the compiler version
+--
+-- ------------------------------------------------------
+-- ------------------------------------------------------
+--
+--
+
+const word USB_EP_BASE_ADDRESS = 0x0500
+
+const bit USB_EP0 = 1
+const byte USB_EP0_OUT_SIZE = 8
+const word USB_EP0_OUT_ADDR = USB_EP_BASE_ADDRESS
+const byte USB_EP0_IN_SIZE = USB_EP0_OUT_SIZE
+const word USB_EP0_IN_ADDR = USB_EP_BASE_ADDRESS + USB_EP0_OUT_SIZE
+
+const bit USB_EP1 = 1
+const byte USB_EP1_OUT_SIZE = 8
+const word USB_EP1_OUT_ADDR = USB_EP_BASE_ADDRESS + USB_EP0_OUT_SIZE +
USB_EP0_IN_SIZE
+const byte USB_EP1_IN_SIZE = USB_EP1_OUT_SIZE
+const word USB_EP1_IN_ADDR = USB_EP_BASE_ADDRESS + USB_EP0_OUT_SIZE +
USB_EP0_IN_SIZE + USB_EP1_OUT_SIZE
+var volatile byte usb_ep1in_buf[ 8 ]
+
+const bit USB_EP2 = 0
+const byte USB_EP2_OUT_SIZE = 8
+const word USB_EP2_OUT_ADDR = 0x0520
+const byte USB_EP2_IN_SIZE = 8
+const word USB_EP2_IN_ADDR = 0x0528
+
+const bit USB_EP3 = 0
+const byte USB_EP3_OUT_SIZE = 8
+const word USB_EP3_OUT_ADDR = 0x0600
+const byte USB_EP3_IN_SIZE = 8
+const word USB_EP3_IN_ADDR = 0x0680
+
+
+const byte HID_OUT_REPORT_SIZE = 8
+
+const bit USB_CALLBACK_ON_CLASS_CTRL = false
+const bit USB_CALLBACK_ON_DEVICE_CONFIGURED = false
+const bit USB_CALLBACK_ON_VENDOR_CTRL = false
+const bit USB_EP_DATA_CALLBACK = true
+const bit USB_CALLBACK_ON_SOF = false
+
+
+const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] = {
+ USB_DEVICE_DESCRIPTOR_SIZE, -- 18 bytes long
+ USB_DT_DEVICE, -- DEVICE 01h
+ 0x00,
+ 0x02, -- usb version 2.00
+ 0x00, -- class
+ 0x00, -- subclass
+ 0x00, -- protocol
+ 0x08, -- max packet size for end point 0
+ 0x25,
+ 0x09, -- Vendor ID
+ 0x01,
+ 0x70, -- Product ID
+ 0x01,
+ 0x00, -- version 0.1 of the product
+ 0x01, -- string 1 for manufacturer
+ 0x02, -- string 2 for product
+ 0x00, -- string 3 for serial number
+ 0x01 -- number of configurations
+}
+
+
+const byte USB_HID_REPORT1[]=
+{
+
+ 0x06, 0xA0, 0xFF, -- Usage page (vendor defined)
+ 0x09, 0x01, -- Usage ID (vendor
defined)
+ 0xA1, 0x01, -- Collection
(application)
+
+ -- The Input report
+ 0x09, 0x03, -- Usage ID - vendor defined
+ 0x15, 0x00, -- Logical Minimum (0)
+ 0x26, 0xFF, 0x00, -- Logical Maximum (255)
+ 0x75, 0x08, -- Report Size (8 bits)
+ 0x95, HID_OUT_REPORT_SIZE, -- Report Count (8 fields)
+ 0x81, 0x02, -- Input (Data, Variable,
Absolute)
+
+ -- The Output report
+ 0x09, 0x04, -- Usage ID - vendor defined
+ 0x15, 0x00, -- Logical Minimum (0)
+ 0x26, 0xFF, 0x00, -- Logical Maximum (255)
+ 0x75, 0x08, -- Report Size (8 bits)
+ 0x95, HID_OUT_REPORT_SIZE, -- Report Count (8 fields)
+ 0x91, 0x02, -- Output (Data, Variable,
Absolute)
+
+ -- The Feature report
+ 0x09, 0x05, -- Usage ID - vendor defined
+ 0x15, 0x00, -- Logical Minimum (0)
+ 0x26, 0xFF, 0x00, -- Logical Maximum (255)
+ 0x75, 0x08, -- Report Size (8 bits)
+ 0x95, HID_OUT_REPORT_SIZE, -- Report Count (8 fields)
+ 0xB1, 0x02, -- Feature (Data, Variable,
Absolute)
+
+ 0xC0 -- end collection
+}
+
+const USB_CONFIGURATION_DESCRIPTOR_SIZE = 0x09 + 0x09 + 0x09 + 0x07 + 0x07
+
+const byte USB_CONFIGURATION_DESCRIPTOR[ USB_CONFIGURATION_DESCRIPTOR_SIZE
]=
+{
+ -- configuration descriptor - - - - - - - - - -
+ 0x09, -- length,
+ USB_DT_CONFIGURATION, -- descriptor_type
+
+ USB_CONFIGURATION_DESCRIPTOR_SIZE,
+ 0x00, -- total_length;
+
+ 0x01, -- num_interfaces,
+ 0x01, -- configuration_value,
+ 0x00, -- configuration_string_id,
+ 0b10000000, -- attributes (bus powered, no remote wake up)
+ 100, -- max_power; (200ma)
+
+ -- interface descriptor - - - - - - - - - - - -
+ 0x09, -- length,
+ USB_DT_INTERFACE, -- descriptor_type,
+ 0x00, -- interface_number, (starts at zero)
+ 0x00, -- alternate_setting, (no alternatives)
+ 0x02, -- num_endpoints,
+ USB_HID_INTF, -- interface_class, (HID)
+ 0x00, -- interface_subclass
+ 0x00, -- interface_protocol
+ 0x00, -- interface_string_id;
+
+ -- hid descriptor - - - - - - - - - - - - - - -
+ 0x09, -- length,
+ USB_DT_HID, -- descriptor_type;
+ 0x11,
+ 0x01, -- hid_spec in BCD (1.11)
+ 0x00, -- country_code, (0=not country
specific)
+ 0x01, -- num_class_descriptors, (1)
+ USB_DT_HID_REPORT, -- class_descriptor_type; (0x22 = report)
+ (count( USB_HID_REPORT1 ) & 0xFF ),
+ (count( USB_HID_REPORT1 ) >> 8 ),
+
+ 0x07, -- length,
+ USB_DT_ENDPOINT, -- descriptor_type,
+ 0b10000001, -- endpoint_address, (Endpoint 1, IN)
+ USB_EPT_INT, -- attributes; (Interrupt)
+ USB_EP1_IN_SIZE,
+ 0x00, -- max_packet_size
+ 0x01, -- interval (1ms)
+
+ 0x07, -- length,
+ USB_DT_ENDPOINT, -- descriptor_type,
+ 0b00000001, -- endpoint_address, (Endpoint 1, OUT)
+ USB_EPT_INT, -- attributes; (Interrupt)
+ USB_EP1_OUT_SIZE,
+ 0x00, -- max_packet_size
+ 0x01 -- interval (1ms)
+}
+
+const byte USB_STRING0[] =
+{
+ 0x04, -- bLength
+ USB_DT_STRING, -- bDescriptorType
+ 0x09, -- wLANGID[0] (low byte)
+ 0x04 -- wLANGID[0] (high byte)
+}
+
+const byte USB_STRING1[18] =
+{
+ 18, -- bLength
+ USB_DT_STRING, -- bDescriptorType
+ "J", 0x00,
+ "A", 0x00,
+ "L", 0x00,
+ " ", 0x00,
+ "L", 0x00,
+ "I", 0x00,
+ "B", 0x00,
+ ".", 0x00
+}
+
+const byte USB_STRING2[42] =
+{
+ 42, -- bLength
+ USB_DT_STRING, -- bDescriptorType
+ "J", 0x00,
+ "A", 0x00,
+ "L", 0x00,
+ " ", 0x00,
+ "G", 0x00,
+ "e", 0x00,
+ "n", 0x00,
+ "e", 0x00,
+ "r", 0x00,
+ "i", 0x00,
+ "c", 0x00,
+ " ", 0x00,
+ "H", 0x00,
+ "I", 0x00,
+ "D", 0x00,
+ " ", 0x00,
+ "D", 0x00,
+ "e", 0x00,
+ "m", 0x00,
+ "o", 0x00
+}
+
+
Added: trunk/include/peripheral/usb/usb_hid_keyboard_config.jal
==============================================================================
--- (empty file)
+++ trunk/include/peripheral/usb/usb_hid_keyboard_config.jal Sun Mar 15
16:51:37 2009
@@ -0,0 +1,225 @@
+-- Title: USB Communication HID Device descriptor constants
+-- Author: Albert Faber, Copyright (c) 2008..2009, all rights reserved.
+-- Adapted-by: -
+-- Compiler: >=2.4i
+--
+-- This file is part of jallib (http:--jallib.googlecode.com)
+-- Released under the BSD license
(http:--www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: Constants for configuring the USB device
+-- --
+--
+-- Sources: http:--www.usb.org for USB specifications
+--
+-- Notes: not sure about the compiler version
+--
+-- ------------------------------------------------------
+-- ------------------------------------------------------
+--
+--
+const bit USB_EP0 = 1
+const byte USB_EP0_OUT_SIZE = 8
+const word USB_EP0_OUT_ADDR = 0x0500
+const byte USB_EP0_IN_SIZE = USB_EP0_OUT_SIZE
+const word USB_EP0_IN_ADDR = 0x0508
+
+const bit USB_EP1 = 1
+const byte USB_EP1_OUT_SIZE = 8
+const word USB_EP1_OUT_ADDR = 0x0510
+const byte USB_EP1_IN_SIZE = 8
+const word USB_EP1_IN_ADDR = 0x0518
+var volatile byte usb_ep1in_buf[ 8 ]
+
+const bit USB_EP2 = 0
+const byte USB_EP2_OUT_SIZE = 8
+const word USB_EP2_OUT_ADDR = 0x0520
+const byte USB_EP2_IN_SIZE = 8
+const word USB_EP2_IN_ADDR = 0x0528
+
+const bit USB_EP3 = 0
+const byte USB_EP3_OUT_SIZE = 8
+const word USB_EP3_OUT_ADDR = 0x0600
+const byte USB_EP3_IN_SIZE = 8
+const word USB_EP3_IN_ADDR = 0x0680
+
+
+
+const bit USB_CALLBACK_ON_CLASS_CTRL = true
+const bit USB_CALLBACK_ON_DEVICE_CONFIGURED = false
+const bit USB_CALLBACK_ON_VENDOR_CTRL = false
+const bit USB_EP_DATA_CALLBACK = true
+const bit USB_CALLBACK_ON_SOF = false
+
+
+const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] = {
+ USB_DEVICE_DESCRIPTOR_SIZE, -- 18 bytes long
+ USB_DT_DEVICE, -- DEVICE 01h
+ 0x00,
+ 0x02, -- usb version 2.00
+ 0x00, -- class
+ 0x00, -- subclass
+ 0x00, -- protocol
+ USB_EP0_OUT_SIZE, -- max packet size for end point 0
+ 0xd8,
+ 0x04, -- Microchip's vendor
+ 0x55,
+ 0x00, -- Microchip keyboard demo
+ 0x01,
+ 0x00, -- version 1.0 of the product
+ 0x01, -- string 1 for manufacturer
+ 0x02, -- string 2 for product
+ 0x00, -- string 3 for serial number
+ 0x01 -- number of configurations
+}
+
+
+const byte USB_HID_REPORT1[]=
+{
+ 0x05, 0x01, -- USAGE_PAGE (Generic Desktop)
+ 0x09, 0x06, -- USAGE (Keyboard)
+ 0xa1, 0x01, -- COLLECTION (Application)
+ 0x05, 0x07, -- USAGE_PAGE (Keyboard)
+ 0x19, 0xe0, -- USAGE_MINIMUM (Keyboard LeftControl)
+ 0x29, 0xe7, -- USAGE_MAXIMUM (Keyboard Right GUI)
+ 0x15, 0x00, -- LOGICAL_MINIMUM (0)
+ 0x25, 0x01, -- LOGICAL_MAXIMUM (1)
+ 0x75, 0x01, -- REPORT_SIZE (1)
+ 0x95, 0x08, -- REPORT_COUNT (8)
+ 0x81, 0x02, -- INPUT (Data,Var,Abs)
+ 0x95, 0x01, -- REPORT_COUNT (1)
+ 0x75, 0x08, -- REPORT_SIZE (8)
+ 0x81, 0x03, -- INPUT (Cnst,Var,Abs)
+ 0x95, 0x05, -- REPORT_COUNT (5)
+ 0x75, 0x01, -- REPORT_SIZE (1)
+ 0x05, 0x08, -- USAGE_PAGE (LEDs)
+ 0x19, 0x01, -- USAGE_MINIMUM (Num Lock)
+ 0x29, 0x05, -- USAGE_MAXIMUM (Kana)
+ 0x91, 0x02, -- OUTPUT (Data,Var,Abs)
+ 0x95, 0x01, -- REPORT_COUNT (1)
+ 0x75, 0x03, -- REPORT_SIZE (3)
+ 0x91, 0x03, -- OUTPUT (Cnst,Var,Abs)
+ 0x95, 0x06, -- REPORT_COUNT (6)
+ 0x75, 0x08, -- REPORT_SIZE (8)
+ 0x15, 0x00, -- LOGICAL_MINIMUM (0)
+ 0x25, 0x65, -- LOGICAL_MAXIMUM (101)
+ 0x05, 0x07, -- USAGE_PAGE (Keyboard)
+ 0x19, 0x00, -- USAGE_MINIMUM (Reserved (no event
indicated))
+ 0x29, 0x65, -- USAGE_MAXIMUM (Keyboard Application)
+ 0x81, 0x00, -- INPUT (Data,Ary,Abs)
+ 0xc0
+}
+const USB_CONFIGURATION_DESCRIPTOR_SIZE = 0x09 + 0x09 + 0x09 + 0x07
+
+const byte USB_CONFIGURATION_DESCRIPTOR[ USB_CONFIGURATION_DESCRIPTOR_SIZE
]=
+{
+ -- configuration descriptor - - - - - - - - - -
+ 0x09, -- length,
+ USB_DT_CONFIGURATION, -- descriptor_type
+
+ USB_CONFIGURATION_DESCRIPTOR_SIZE,
+ 0x00, -- total_length;
+
+ 0x01, -- num_interfaces,
+ 0x01, -- configuration_value,
+ 0x00, -- configuration_string_id,
+ 0b10000000, -- attributes (bus powered, no remote wake up)
+ 100, -- max_power; (200ma)
+
+ -- interface descriptor - - - - - - - - - - - -
+ 0x09, -- length,
+ USB_DT_INTERFACE, -- descriptor_type,
+ 0x00, -- interface_number,
(starts at zero)
+ 0x00, -- alternate_setting,
(no alternatives)
+ 0x01, -- num_endpoints,
+ USB_HID_INTF, -- interface_class, (HID)
+ USB_BOOT_INTF_SUBCLASS, -- interface_subclass, (boot)
+ USB_HID_PROTOCOL_KEYBOARD, -- interface_protocol, (keyboard)
+ 0x00, -- interface_string_id;
+
+ -- hid descriptor - - - - - - - - - - - - - - -
+ 0x09, -- length,
+ USB_DT_HID, -- descriptor_type;
+ 0x11,
+ 0x01, -- hid_spec in BCD (1.11)
+ 0x00, -- country_code, (0=not country
specific)
+ 0x01, -- num_class_descriptors, (1)
+ USB_DT_HID_REPORT, -- class_descriptor_type; (0x22 = report)
+ (count( USB_HID_REPORT1 ) & 0xFF ),
+ (count( USB_HID_REPORT1 ) >> 8 ),
+
+ 0x07, -- length,
+ USB_DT_ENDPOINT, -- descriptor_type,
+ 0b10000001, -- endpoint_address, (Endpoint 1, IN)
+ USB_EPT_INT, -- attributes; (Interrupt)
+ USB_EP1_IN_SIZE,
+ 0x00, -- max_packet_size
+ 0x01 -- interval (1ms)
+}
+
+const byte USB_STRING0[] =
+{
+ 0x04, -- bLength
+ USB_DT_STRING, -- bDescriptorType
+ 0x09, -- wLANGID[0] (low byte)
+ 0x04 -- wLANGID[0] (high byte)
+}
+
+const byte USB_STRING1[] =
+{
+ 0x36, -- bLength
+ USB_DT_STRING, -- bDescriptorType
+ "M", 0x00,
+ "i", 0x00,
+ "c", 0x00,
+ "r", 0x00,
+ "o", 0x00,
+ "c", 0x00,
+ "h", 0x00,
+ "i", 0x00,
+ "p", 0x00,
+ " ", 0x00,
+ "T", 0x00,
+ "e", 0x00,
+ "c", 0x00,
+ "h", 0x00,
+ "n", 0x00,
+ "o", 0x00,
+ "l", 0x00,
+ "o", 0x00,
+ "g", 0x00,
+ "y", 0x00,
+ ",", 0x00,
+ " ", 0x00,
+ "I", 0x00,
+ "n", 0x00,
+ "c", 0x00,
+ ".", 0x00
+}
+
+const byte USB_STRING2[42] =
+{
+ 38, -- bLength
+ USB_DT_STRING, -- bDescriptorType
+ "J", 0x00,
+ "A", 0x00,
+ "L", 0x00,
+ " ", 0x00,
+ "H", 0x00,
+ "I", 0x00,
+ "D", 0x00,
+ " ", 0x00,
+ "K", 0x00,
+ "e", 0x00,
+ "b", 0x00,
+ "o", 0x00,
+ "a", 0x00,
+ "r", 0x00,
+ " ", 0x00,
+ " ", 0x00,
+ "D", 0x00,
+ "e", 0x00,
+ "m", 0x00,
+ "o", 0x00
+}
+
+
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---