Микроконтроллеры, АЦП, память и т.д Темы касающиеся микроконтроллеров разных производителей, памяти, АЦП/ЦАП, периферийных модулей... |
27.06.2010, 20:44
|
|
Гуру портала
Регистрация: 27.10.2008
Адрес: ЕС
Сообщений: 10,835
Сказал спасибо: 919
Сказали Спасибо 4,308 раз(а) в 2,573 сообщении(ях)
|
Re: USB HID report descriptor
Сообщение от AJScorp
|
Не указан REPORT_SIZE - размер в битах для X и Y
Код:
|
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x09, 0x04, // USAGE (Joystick)
0xa1, 0x01, // COLLECTION (Application)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION |
|
Не работает
Сообщение от oleg_harp
|
Уважаемый Easyrider83. У меня Ваша проект работает в Proteus 7.6 SP0. Скачал простейшую тестовую программу JoyTester2. Управление по каналам X, У и газ работает. Единственное, USB-устройство через некоторое время вываливается из системы, но, может быть, это проблема Proteus.
|
Я выложил проект с рабочим дескриптором. Джойстик нормально работает по USB1.1 и нормально калибруется. Непонятка только с кнопками и HAT свичем. Но я с ними не разбирался. Просто отправил значение порта в РС. Это так, тренажер, бета версия. Как данные отправлять я разобрался. Пока не ясно, как дескрипторы писать. Кстати, у меня при работе джойстика ничего не глючило с протеусом. Загрузка ЦП 3%.
|
|
|
|
27.06.2010, 20:58
|
|
Почётный гражданин KAZUS.RU
Регистрация: 10.05.2005
Адрес: Саратов.ru
Сообщений: 1,548
Сказал спасибо: 384
Сказали Спасибо 737 раз(а) в 417 сообщении(ях)
|
Re: USB HID report descriptor
Сообщение от Easyrider83
|
Не работает
|
Не работает как джойстик или отсутствует опрос endpoint?
Пост #8 смотрели? Для этого дескриптора размер данных - 2 байта.
|
|
|
|
27.06.2010, 21:06
|
|
Гуру портала
Регистрация: 27.10.2008
Адрес: ЕС
Сообщений: 10,835
Сказал спасибо: 919
Сказали Спасибо 4,308 раз(а) в 2,573 сообщении(ях)
|
Re: USB HID report descriptor
Сообщение от AJScorp
|
Не работает как джойстик или отсутствует опрос endpoint?
|
В списке устройств висит с восклицательным знаком. В калибровку не пускает.
Сообщение от AJScorp
|
Пост #8 смотрели? Для этого дескриптора размер данных - 2 байта.
|
Конечно, смотрел.
Цитата:
|
while(HID_Write(@writebuff,2) = 0) wend
|
|
|
|
|
27.06.2010, 21:32
|
|
Почётный гражданин KAZUS.RU
Регистрация: 10.05.2005
Адрес: Саратов.ru
Сообщений: 1,548
Сказал спасибо: 384
Сказали Спасибо 737 раз(а) в 417 сообщении(ях)
|
Re: USB HID report descriptor
Сообщение от Easyrider83
|
В списке устройств висит с восклицательным знаком
|
Значит ошибка возникла на этапе енумерации..
USB_HID_RPT_SIZE исправили?
|
|
|
|
27.06.2010, 23:54
|
|
Гуру портала
Регистрация: 27.10.2008
Адрес: ЕС
Сообщений: 10,835
Сказал спасибо: 919
Сказали Спасибо 4,308 раз(а) в 2,573 сообщении(ях)
|
Re: USB HID report descriptor
Сообщение от AJScorp
|
Значит ошибка возникла на этапе енумерации..
USB_HID_RPT_SIZE исправили?
|
Конечно. Исправил.
Последний раз редактировалось Easyrider83; 28.06.2010 в 02:23.
|
|
|
|
28.06.2010, 02:25
|
|
Гуру портала
Регистрация: 27.10.2008
Адрес: ЕС
Сообщений: 10,835
Сказал спасибо: 919
Сказали Спасибо 4,308 раз(а) в 2,573 сообщении(ях)
|
Re: USB HID report descriptor
Выкладываю полный дескриптор для прояснения ситуации:
Цитата:
|
module USBdsc
const USB_VENDOR_ID as word = 0x1234
const USB_PRODUCT_ID as word = 0x0001
const USB_SELF_POWER as char = 0x80 ' Self powered 0xC0, 0x80 bus powered
const USB_MAX_POWER as char = 50 ' Bus power required in units of 2 mA
const HID_INPUT_REPORT_BYTES as char = 1
const HID_OUTPUT_REPORT_BYTES as char = 1
const EP_IN_INTERVAL as char = 1
const EP_OUT_INTERVAL as char = 1
const USB_INTERRUPT as char = 1
const USB_TRANSFER_TYPE as char = 0x03 '0x03 Interrupt
const USB_HID_EP as char = 1
const USB_HID_RPT_SIZE as char = 27
structure device_descriptor
dim bLength as char ' bLength - Descriptor size in bytes (12h)
dim bDescriptorType as char ' bDescriptorType - The constant DEVICE (01h)
dim bcdUSB as word ' bcdUSB - USB specification release number (BCD)
dim bDeviceClass as char ' bDeviceClass - Class Code
dim bDeviceSubClass as char ' bDeviceSubClass - Subclass code
dim bDeviceProtocol as char ' bDeviceProtocol - Protocol code
dim bMaxPacketSize0 as char ' bMaxPacketSize0 - Maximum packet size for endpoint 0
dim idVendor as word ' idVendor - Vendor ID
dim idProduct as word ' idProduct - Product ID
dim bcdDevice as word ' bcdDevice - Device release number (BCD)
dim iManufacturer as char ' iManufacturer - Index of string descriptor for the manufacturer
dim iProduct as char ' iProduct - Index of string descriptor for the product.
dim iSerialNumber as char ' iSerialNumber - Index of string descriptor for the serial number.
dim bNumConfigurations as char ' bNumConfigurations - Number of possible configurations
end structure
const device_dsc as device_descriptor = (
0x12, ' bLength
0x01, ' bDescriptorType
0x0200, ' bcdUSB
0x00, ' bDeviceClass
0x00, ' bDeviceSubClass
0x00, ' bDeviceProtocol
8, ' bMaxPacketSize0
USB_VENDOR_ID, ' idVendor
USB_PRODUCT_ID, ' idProduct
0x0001, ' bcdDevice
0x01, ' iManufacturer
0x02, ' iProduct
0x00, ' iSerialNumber
0x01 ' bNumConfigurations
)
' Configuration 1 Descriptor
const configDescriptor1 as byte[41] = (
' Configuration Descriptor
0x09, ' bLength - Descriptor size in bytes
0x02, ' bDescriptorType - The constant CONFIGURATION (02h)
0x29,0x00, ' wTotalLength - The number of bytes in the configuration descriptor and all of its subordinate descriptors
1, ' bNumInterfaces - Number of interfaces in the configuration
1, ' bConfigurationValue - Identifier for Set Configuration and Get Configuration requests
0, ' iConfiguration - Index of string descriptor for the configuration
USB_SELF_POWER, ' bmAttributes - Self/bus power and remote wakeup settings
USB_MAX_POWER, ' bMaxPower - Bus power required in units of 2 mA
' Interface Descriptor
0x09, ' bLength - Descriptor size in bytes (09h)
0x04, ' bDescriptorType - The constant Interface (04h)
0, ' bInterfaceNumber - Number identifying this interface
0, ' bAlternateSetting - A number that identifies a descriptor with alternate settings for this bInterfaceNumber.
2, ' bNumEndpoint - Number of endpoints supported not counting endpoint zero
0x03, ' bInterfaceClass - Class code
0, ' bInterfaceSubclass - Subclass code
0, ' bInterfaceProtocol - Protocol code
0, ' iInterface - Interface string index
' HID Class-Specific Descriptor
0x09, ' bLength - Descriptor size in bytes.
0x21, ' bDescriptorType - This descriptor's type: 21h to indicate the HID class.
0x01,0x01, ' bcdHID - HID specification release number (BCD).
0x00, ' bCountryCode - Numeric expression identifying the country for localized hardware (BCD) or 00h.
1, ' bNumDescriptors - Number of subordinate report and physical descriptors.
0x22, ' bDescriptorType - The type of a class-specific descriptor that follows
USB_HID_RPT_SIZE,0x00, ' wDescriptorLength - Total length of the descriptor identified above.
' Endpoint Descriptor
0x07, ' bLength - Descriptor size in bytes (07h)
0x05, ' bDescriptorType - The constant Endpoint (05h)
USB_HID_EP or 0x80, ' bEndpointAddress - Endpoint number and direction
USB_TRANSFER_TYPE, ' bmAttributes - Transfer type and supplementary information
0x40,0x00, ' wMaxPacketSize - Maximum packet size supported
EP_IN_INTERVAL, ' bInterval - Service interval or NAK rate
' Endpoint Descriptor
0x07, ' bLength - Descriptor size in bytes (07h)
0x05, ' bDescriptorType - The constant Endpoint (05h)
USB_HID_EP, ' bEndpointAddress - Endpoint number and direction
USB_TRANSFER_TYPE, ' bmAttributes - Transfer type and supplementary information
0x40,0x00, ' wMaxPacketSize - Maximum packet size supported
EP_OUT_INTERVAL ' bInterval - Service interval or NAK rate
)
structure hid_report_descriptor
dim report as char[USB_HID_RPT_SIZE]
end structure
const hid_rpt_desc as hid_report_descriptor = (
(0x05, 0x01, ' USAGE_PAGE (Generic Desktop)
0x15, 0x00, ' LOGICAL_MINIMUM (0)
0x09, 0x04, ' USAGE (Joystick)
0xa1, 0x01, ' COLLECTION (Application)
0x05, 0x01, ' USAGE_PAGE (Generic Desktop)
0x09, 0x01, ' USAGE (Pointer)
0xa1, 0x00, ' COLLECTION (Physical)
0x09, 0x30, ' USAGE (X)
0x09, 0x31, ' USAGE (Y)
0x75, 0x08, ' REPORT_SIZE (
0x95, 0x02, ' REPORT_COUNT (2)
0x81, 0x02, ' INPUT (Data,Var,Abs)
0xc0, ' END_COLLECTION
0xc0
)
)
'Language code string descriptor
structure str1
dim bLength as char
dim bDscType as char
dim wString as word[1]
end structure
const strd1 as str1 = (
4,
0x03,
(0x0409)
)
'Manufacturer string descriptor
structure str2
dim bLength as char
dim bDscType as char
dim wString as word[13]
end structure
const strd2 as str2 = (
28, 'sizeof this descriptor string
0x03,
("V","i","r","v","i","g","l","a","z"," ","C","o",".")
)
'Product string descriptor
structure str3
dim bLength as char
dim bDscType as char
dim wString as word[15]
end structure
const strd3 as str3 = (
32, 'sizeof this descriptor string
0x03,
("S","i","m","p","l","e"," ","J","o","y","s","t","i","c","k")
)
dim USB_config_dsc_ptr as ^const char[1]
dim USB_string_dsc_ptr as ^const char[3]
sub procedure USB_Init_desc()
implements
sub procedure USB_Init_desc()
USB_config_dsc_ptr[0] = @configDescriptor1
USB_string_dsc_ptr[0] = ^const char(@strd1)
USB_string_dsc_ptr[1] = ^const char(@strd2)
USB_string_dsc_ptr[2] = ^const char(@strd3)
end sub
end.
|
|
|
|
|
28.06.2010, 02:29
|
|
Гуру портала
Регистрация: 27.10.2008
Адрес: ЕС
Сообщений: 10,835
Сказал спасибо: 919
Сказали Спасибо 4,308 раз(а) в 2,573 сообщении(ях)
|
Re: USB HID report descriptor
Сообщение от DK
|
Вот мой дескриптор
Цитата:
0x05,0x01, // USAGE_PAGE (Generic Desktop)
0x15,0x00, // LOGICAL_MINIMUM (0)
0x09,0x04, // USAGE (Joystick)
0xa1,0x01, // COLLECTION (Application)
0x05,0x02, // USAGE_PAGE (Simulation Controls)
0x09,0xbb, // USAGE (Throttle)
0x15,0x81, // LOGICAL_MINIMUM (-127)
0x25,0x7f, // LOGICAL_MAXIMUM (127)
0x75,0x08, // REPORT_SIZE (
0x95,0x01, // REPORT_COUNT (1)
0x81,0x02, // INPUT (Data,Var,Abs)
0x05,0x01, // USAGE_PAGE (Generic Desktop)
0x09,0x01, // USAGE (Pointer)
0xa1,0x00, // COLLECTION (Physical)
0x09,0x30, // USAGE (X)
0x09,0x31, // USAGE (Y)
0x95,0x02, // REPORT_COUNT (2)
0x81,0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0x05,0x09, // USAGE_PAGE (Button)
0x19,0x01, // USAGE_MINIMUM (Button 1)
0x29,0x04, // USAGE_MAXIMUM (Button 4)
0x15,0x00, // LOGICAL_MINIMUM (0)
0x25,0x01, // LOGICAL_MAXIMUM (1)
0x75,0x01, // REPORT_SIZE (1)
0x95,0x04, // REPORT_COUNT (4)
0x55,0x00, // UNIT_EXPONENT (0)
0x65,0x00, // UNIT (None)
0x81,0x02, // INPUT (Data,Var,Abs)
0x95,0x04, // REPORT_COUNT (4)
0x81,0x03, // INPUT (Cnst,Var,Abs)
0xc0, // END_COLLECTION
Два направления, скорость и 4 кнопки
|
Этот работает )
|
|
|
|
28.06.2010, 07:08
|
|
Почётный гражданин KAZUS.RU
Регистрация: 10.05.2005
Адрес: Саратов.ru
Сообщений: 1,548
Сказал спасибо: 384
Сказали Спасибо 737 раз(а) в 417 сообщении(ях)
|
Re: USB HID report descriptor
Сообщение от Easyrider83
|
const USB_HID_RPT_SIZE as char = 27
|
Должно быть 26
|
|
|
Сказали "Спасибо" AJScorp
|
|
|
28.06.2010, 22:07
|
|
Гуру портала
Регистрация: 27.10.2008
Адрес: ЕС
Сообщений: 10,835
Сказал спасибо: 919
Сказали Спасибо 4,308 раз(а) в 2,573 сообщении(ях)
|
Re: USB HID report descriptor
Сообщение от AJScorp
|
Должно быть 26
|
Вы правы. Работает.
Мне бы все таки понять принцип. Не все же время я буду просить о помощи на форуме.
Можно ли менять порядок строчек? Какие строчки что обозначают?
|
|
|
|
29.06.2010, 00:56
|
|
Гуру портала
Регистрация: 27.10.2008
Адрес: ЕС
Сообщений: 10,835
Сказал спасибо: 919
Сказали Спасибо 4,308 раз(а) в 2,573 сообщении(ях)
|
Re: USB HID report descriptor
Написал сам такой вот дескриптор на основе вашего:
Цитата:
|
0x05, 0x01, ' USAGE_PAGE (Generic Desktop)
0x15, 0x00, ' LOGICAL_MINIMUM (0)
0x09, 0x04, ' USAGE (Joystick)
0xa1, 0x01, ' COLLECTION (Application)
0x05, 0x01, ' USAGE_PAGE (Generic Desktop)
0x09, 0x01, ' USAGE (Pointer)
0xa1, 0x00, ' COLLECTION (Physical)
0x09, 0x30, ' USAGE (X)
0x09, 0x31, ' USAGE (Y)
0x75, 0x08, ' REPORT_SIZE (
0x95, 0x02, ' REPORT_COUNT (2)
0x15, 0x00, ' LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, ' LOGICAL_MAXIMUM (255)
0x35, 0x00, ' PHYSICAL_MINIMUM (0)
0x46, 0xff, 0x00, ' PHYSICAL_MAXIMUM (255)
0x81, 0x02, ' INPUT (Data,Var,Abs)
0xc0, ' END_COLLECTION
0xc0 ' END_COLLECTION
|
Работает. Ожидал, что если сразу указать пределы изменения осей, калибровка не потребуется. Ошибся - потребовалась. Уже потихоньку начинаю въезжать в тему. Но все равно пока темный лес.
|
|
|
|
Ваши права в разделе
|
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения
HTML код Выкл.
|
|
|
Часовой пояс GMT +4, время: 17:17.
|
|