Saitama
- 3rd April 2023, 18:26
Hello everyone.
I always try to use microde studio for many of my projects because of the speed and ease of reading the code, with its disadvantages such as higher space usage per program and a very small community, I use it because its benefits are greater. among my projects I need to create a composite device, searching the internet I have not found precise information on this topic, not even an example.
I have worked on this and I have achieved something that is close to achieving it,
At this point I think I need to properly address the second device endpoints.
I have analyzed pbppic18.mac USBOUT-->L?CALL PutUSB and the respective usb_dev.asm where I find that I can address correctly without modifying the code because the required Endpoint has been correctly stored in FSR0L. Despite my poor understanding, I have so far modified the usb_mem.asm, usb_dev.inc, and usb_hid.asm files.
The result of this has been that the PC recognizes the composite device correctly and interface 0 communicates (with some easily fixable glitches), but interface 1 is not heard. I think this potential problem is in usb_hid.asm, because invoking endpoint 82 I think it sends to both endpoints 81 and 82, causing me to lose data on device 0 and abort receiving from device 1
https://i.postimg.cc/bvsGSysv/Untitleddf.png
I need some help to find a solution to this problem, if you can help with any contribution I will be very grateful
DES_FirmAC01.bas
' USB descriptors for a HID device
'USBMEMORYADDRESS Con $400 ' USB RAM starts here (set in device header file)
USBMEMORYSIZE Con 256 ' USB RAM size in bytes
USBReservedMemory Var Byte[USBMEMORYSIZE] USBMEMORYADDRESS ' Reserve memory used by USB assembler code
goto hid_desc_end ' Skip over all of the USB assembler code
asm
#define USB_EP0_BUFF_SIZE 8 ; 8, 16, 32, or 64
#define USB_MAX_NUM_INT 2 ; For tracking Alternate Setting
#define USB_MAX_EP_NUMBER 2 ; UEP1
#define NUM_CONFIGURATIONS 1
#define NUM_INTERFACES 2
#define UCFG_VAL USB_PULLUP_ENABLE|USB_INTERNAL_TRANSCEIVER|USB_FUL L_SPEED|USB_PING_PONG__NO_PING_PONG
;#define UCFG_VAL USB_PULLUP_ENABLE|USB_INTERNAL_TRANSCEIVER|USB_LOW _SPEED|USB_PING_PONG__NO_PING_PONG
;#define USE_SELF_POWER_SENSE_IO
;#define USE_USB_BUS_SENSE_IO
#define USB_POLLING
; HID
; Endpoints Allocation
#define HID_INTF_ID 0x00
#define HID_EP 1
#define HID_INT_OUT_EP_SIZE 16
#define HID_INT_IN_EP_SIZE 16
#define HID_DEV_INTF_ID 0x01
#define HID_DEV_EP 2
#define HID_DEV_INT_OUT_EP_SIZE 16
#define HID_DEV_INT_IN_EP_SIZE 16
#define HID_NUM_OF_DSC 1
include "usb_hid.asm" ; Include rest of USB files, starting with HID class code
; ************************************************** ****************
; This table is polled by the host immediately after USB Reset has been released.
; This table defines the maximum packet size EP0 can take.
; See section 9.6.1 of the Rev 1.0 USB specification.
; These fields are application DEPENDENT. Modify these to meet
; your specifications.
; ************************************************** ****************
DeviceDescriptor
retlw (EndDeviceDescriptor-DeviceDescriptor)/2 ; bLength Length of this descriptor
retlw USB_DESCRIPTOR_DEVICE ; bDescType This is a DEVICE descriptor
retlw 0x00 ; bcdUSBUSB Revision 1.10 (low byte)
retlw 0x02 ; high byte
retlw 0x00 ; bDeviceClass zero means each interface operates independently
retlw 0x00 ; bDeviceSubClass
retlw 0x00 ; bDeviceProtocol
retlw USB_EP0_BUFF_SIZE ; bMaxPacketSize for EP0
; idVendor (low byte, high byte)
retlw 0xD9
retlw 0x04
; idProduct (low byte, high byte)
retlw 0x3C
retlw 0x00
retlw 0x00 ; bcdDevice (low byte)
retlw 0x01 ; (high byte)
retlw 0x01 ; iManufacturer (string index)
retlw 0x02 ; iProduct (string index)
retlw 0x03 ; iSerialNumber (string index)
retlw NUM_CONFIGURATIONS ; bNumConfigurations
EndDeviceDescriptor
; ************************************************** ****************
; This table is retrieved by the host after the address has been set.
; This table defines the configurations available for the device.
; See section 9.6.2 of the Rev 1.0 USB specification (page 184).
; These fields are application DEPENDENT.
; Modify these to meet your specifications.
; ************************************************** ****************
; Configuration pointer table
USB_CD_Ptr
Configs
db low Config1, high Config1
db upper Config1, 0
; Configuration Descriptor
Config1
retlw (Interface1-Config1)/2 ; bLength Length of this descriptor
retlw USB_DESCRIPTOR_CONFIGURATION ; bDescType 2=CONFIGURATION
Config1Len
retlw low ((EndConfig1 - Config1)/2) ; Length of this configuration
retlw high ((EndConfig1 - Config1)/2)
retlw NUM_INTERFACES ; bNumInterfaces Number of interfaces
retlw 0x01 ; bConfigValue Configuration Value
retlw 0x00 ; iConfig (string index)
retlw _DEFAULT|_SELF ; bmAttributes attributes - bus powered
retlw 0x32 ; Max power consumption (2X mA)
Interface1
retlw (HIDDescriptor1-Interface1)/2 ; length of descriptor
retlw USB_DESCRIPTOR_INTERFACE
retlw 0x00 ; number of interface, 0 based array
retlw 0x00 ; alternate setting
retlw 0x01 ; number of endpoints used in this interface
retlw 0x03 ; interface class - assigned by the USB
retlw 0x00 ; boot device
retlw 0x00 ; interface protocol
retlw 0x04 ; index to string descriptor that describes this interface
HIDDescriptor1
retlw (Endpoint1In-HIDDescriptor1)/2 ; descriptor size (9 bytes)
retlw DSC_HID ; descriptor type (HID)
retlw 0x11 ; HID class release number (1.11)
retlw 0x01
retlw 0x00 ; Localized country code (none)
retlw 0x01 ; # of HID class descriptor to follow (1)
retlw 0x22 ; Report descriptor type (HID)
ReportDescriptor1Len
retlw low ((EndReportDescriptor1-ReportDescriptor1)/2)
retlw high ((EndReportDescriptor1-ReportDescriptor1)/2)
Endpoint1In
retlw (Interface2-Endpoint1In)/2 ; length of descriptor
retlw USB_DESCRIPTOR_ENDPOINT
retlw HID_EP|_EP_IN ; EP1, In
retlw _INT ; Interrupt
retlw low (HID_INT_IN_EP_SIZE) ; This should be the size of the endpoint buffer
retlw high (HID_INT_IN_EP_SIZE)
retlw 0x01 ; Polling interval
;EndPoint1Out
; retlw (Interface2-EndPoint1Out)/2 ; Length of this Endpoint Descriptor
; retlw USB_DESCRIPTOR_ENDPOINT ; bDescriptorType = 5 for Endpoint Descriptor
; retlw HID_EP|_EP_OUT ; Endpoint number & direction
; retlw _INT ; Transfer type supported by this Endpoint
; retlw low (HID_INT_OUT_EP_SIZE) ; This should be the size of the endpoint buffer
; retlw high (HID_INT_OUT_EP_SIZE)
; retlw 0x01 ; Polling interval
Interface2
retlw (HIDDescriptor2-Interface2)/2 ; length of descriptor
retlw USB_DESCRIPTOR_INTERFACE ; INTERFACE descriptor type
retlw 0x01 ; number of interface, 0 based array
retlw 0x00 ; alternate setting
retlw 0x01 ; number of endpoints used in this interface
retlw 0x03 ; interface class - assigned by the USB
retlw 0x00 ; boot device
retlw 0x00 ; interface protocol
retlw 0x04 ; index to string descriptor that describes this interface
HIDDescriptor2
retlw (Endpoint2In-HIDDescriptor2)/2 ; descriptor size (9 bytes)
retlw DSC_HID ; descriptor type (HID)
retlw 0x11 ; HID class release number (1.11)
retlw 0x01
retlw 0x00 ; Localized country code (none)
retlw 0x01 ; # of HID class descriptor to follow (1)
retlw 0x22 ; Report descriptor type (HID)
ReportDescriptor2Len
retlw low ((EndReportDescriptor2-ReportDescriptor2)/2)
retlw high ((EndReportDescriptor2-ReportDescriptor2)/2)
Endpoint2In
retlw (EndConfig1-Endpoint2In)/2 ; length of descriptor
retlw USB_DESCRIPTOR_ENDPOINT
retlw HID_DEV_EP|_EP_IN ; EP2, In
retlw _INT ; Interrupt
retlw low (HID_DEV_INT_IN_EP_SIZE) ; This should be the size of the endpoint buffer
retlw high (HID_DEV_INT_IN_EP_SIZE)
retlw 0x01 ; Polling interval
;EndPoint2Out
; retlw (EndConfig1-EndPoint2Out)/2 ; Length of this Endpoint Descriptor
; retlw USB_DESCRIPTOR_ENDPOINT ; bDescriptorType = 5 for Endpoint Descriptor
; retlw HID_DEV_EP|_EP_OUT ; Endpoint number & direction
; retlw _INT ; Transfer type supported by this Endpoint
; retlw low (HID_DEV_INT_OUT_EP_SIZE) ; This should be the size of the endpoint buffer
; retlw high (HID_DEV_INT_OUT_EP_SIZE)
; retlw 0x01 ; Polling interval
EndConfig1
ReportDescriptor1
retlw 0x05 ; USAGE_PAGE (generic desktop Choose the usage page "mouse" is on
retlw 0x01 ; LOW
retlw 0x09 ; USAGE Device is a Gamepad
retlw 0x05 ; LOW
retlw 0xA1 ; COLLECTION (APPLICATION)
retlw 0x01 ; LOW
retlw 0x85 ; REPORT_ID (1 Pad1)
retlw 0x01 ; LOW
retlw 0xA1 ; Colection Physycal
retlw 0x00 ; LOW
retlw 0x09 ; usage x
retlw 0x30 ;
retlw 0x09 ; usage y
retlw 0x31 ;
retlw 0x15 ; logical minimun 0
retlw 0x00 ;
retlw 0x26 ; logical maximun 1023
retlw 0xFF ;
retlw 0x03 ;
retlw 0x35 ; Physical Minimum (0)
retlw 0x00 ;
retlw 0x46 ; Physical Maximum (1023)
retlw 0xFF ;
retlw 0x03 ;
retlw 0x95 ; REPORT_COUNT 2
retlw 0x02 ;
retlw 0x75 ; report size 16
retlw 0x10 ;
retlw 0x81 ; data,var,abs
retlw 0x02 ;
retlw 0xC0 ; END_COLLECTION
;******************************************
retlw 0xA1 ; Colection Physycal
retlw 0x00 ; LOW
retlw 0x09 ; usage Rx
retlw 0x33 ;
retlw 0x09 ; usage Ry
retlw 0x34 ;
retlw 0x15 ; logical minimun 0
retlw 0x00 ;
retlw 0x26 ; logical maximun 2047
retlw 0xFF ;
retlw 0x03 ;
retlw 0x35 ; Physical Minimum (0)
retlw 0x00 ;
retlw 0x46 ; Physical Maximum (2047)
retlw 0xFF ;
retlw 0x03 ;
retlw 0x95 ; REPORT_COUNT 2
retlw 0x02 ;
retlw 0x75 ; report size 16
retlw 0x10 ;
retlw 0x81 ; data,var,abs
retlw 0x02 ;
retlw 0xC0 ; END_COLLECTION
;******************************************
retlw 0x05 ; USAGE_PAGE (Button)
retlw 0x09 ; low
retlw 0x19 ; Usage Minimum (Button 1)
retlw 0x01 ;
retlw 0x29 ; Usage Maximum (Button 13)
retlw 0x0D ;
retlw 0x95 ; report count 13
retlw 0x0D ;
retlw 0x75 ; report size 1
retlw 0x01 ;
retlw 0x81 ; input data,var,abs
retlw 0x02 ;
retlw 0x95 ; report count 1
retlw 0x01 ;
retlw 0x75 ; report size 3
retlw 0x03 ;
retlw 0x81 ; input Cnst,var,abs
retlw 0x01 ;
retlw 0xC0 ; END_COLLECTION
;************************************************* **********************
;* GamePAD 2 *
;************************************************* **********************
retlw 0x05 ; USAGE_PAGE (generic desktop Choose the usage page "mouse" is on
retlw 0x01 ; LOW
retlw 0x09 ; USAGE Device is a Gamepad
retlw 0x05 ; LOW
retlw 0xA1 ; COLLECTION (APPLICATION)
retlw 0x01 ; LOW
retlw 0x85 ; REPORT_ID (1 Pad1)
retlw 0x02 ; LOW
retlw 0xA1 ; Colection Physycal
retlw 0x00 ; LOW
retlw 0x09 ; usage x
retlw 0x30 ;
retlw 0x09 ; usage y
retlw 0x31 ;
retlw 0x15 ; logical minimun 0
retlw 0x00 ;
retlw 0x26 ; logical maximun 1023
retlw 0xFF ;
retlw 0x03 ;
retlw 0x35 ; Physical Minimum (0)
retlw 0x00 ;
retlw 0x46 ; Physical Maximum (1023)
retlw 0xFF ;
retlw 0x03 ;
retlw 0x95 ; REPORT_COUNT 2
retlw 0x02 ;
retlw 0x75 ; report size 16
retlw 0x10 ;
retlw 0x81 ; data,var,abs
retlw 0x02 ;
retlw 0xC0 ; END_COLLECTION
;******************************************
retlw 0xA1 ; Colection Physycal
retlw 0x00 ; LOW
retlw 0x09 ; usage Rx
retlw 0x33 ;
retlw 0x09 ; usage Ry
retlw 0x34 ;
retlw 0x15 ; logical minimun 0
retlw 0x00 ;
retlw 0x26 ; logical maximun 2047
retlw 0xFF ;
retlw 0x03 ;
retlw 0x35 ; Physical Minimum (0)
retlw 0x00 ;
retlw 0x46 ; Physical Maximum (2047)
retlw 0xFF ;
retlw 0x03 ;
retlw 0x95 ; REPORT_COUNT 2
retlw 0x02 ;
retlw 0x75 ; report size 16
retlw 0x10 ;
retlw 0x81 ; data,var,abs
retlw 0x02 ;
retlw 0xC0 ; END_COLLECTION
;******************************************
retlw 0x05 ; USAGE_PAGE (Button)
retlw 0x09 ; low
retlw 0x19 ; Usage Minimum (Button 1)
retlw 0x01 ;
retlw 0x29 ; Usage Maximum (Button 13)
retlw 0x0E ;
retlw 0x95 ; report count 13
retlw 0x0E ;
retlw 0x75 ; report size 1
retlw 0x01 ;
retlw 0x81 ; input data,var,abs
retlw 0x02 ;
retlw 0x95 ; report count 1
retlw 0x01 ;
retlw 0x75 ; report size 2
retlw 0x02 ;
retlw 0x81 ; input Cnst,var,abs
retlw 0x01 ;
retlw 0xC0 ; END_COLLECTION
EndReportDescriptor1
ReportDescriptor2
;***************************************
;* Mouse Emu *
;***************************************
retlw 0x05 ; USAGE_PAGE (generic desktop)
retlw 0x01 ; LOW
retlw 0x09 ; USAGE Mouse
retlw 0x02 ; LOW
retlw 0xA1 ; COLLECTION (APPLICATION)
retlw 0x01 ; LOW
retlw 0x85 ; REPORT_ID (1)
retlw 0x01 ; LOW
retlw 0x09 ; USAGE_PAGE (Pointer)
retlw 0x01 ; LOW
retlw 0xA1 ; COLLECTION (Physical)
retlw 0x00 ;
retlw 0x05 ; USAGE_PAGE (Button)
retlw 0x09 ;
retlw 0x19 ; Usage Minimum (Button 1)
retlw 0x01 ;
retlw 0x29 ; Usage Maximum (Button 2)
retlw 0x02 ;
retlw 0x15 ; logical minimun
retlw 0x00 ;
retlw 0x25 ; logical maximun
retlw 0x01 ;
retlw 0x75 ; report size 1
retlw 0x01 ;
retlw 0x95 ; report count 3
retlw 0x02 ;
retlw 0x81 ; input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
retlw 0x02 ;
retlw 0x95 ; report count 3
retlw 0x06 ;
retlw 0x81 ; input (Data,Var,Abs)
retlw 0x03 ;
retlw 0x05 ; USAGE_PAGE (Generic Desktop)
retlw 0x01 ; LOW
retlw 0x09 ; Usage(X)
retlw 0x30 ;
retlw 0x09 ; Usage(Y)
retlw 0x31 ;
retlw 0x15 ; logical minimun (-127)
retlw 0x81 ;
retlw 0x25 ; logical maximun (127)
retlw 0x7F ;
retlw 0x75 ; report size 8
retlw 0x08 ;
retlw 0x95 ; report count 2
retlw 0x02 ;
retlw 0x81 ; INPUT (Data,Var,Rel)
retlw 0x06 ;
retlw 0xC0 ; END_COLLECTION
retlw 0xC0 ; END_COLLECTION
;***************************************
;* Keyboard Emu *
;***************************************
;***************************************
;* Volume Control *
;***************************************
retlw 0x05 ; USAGE_PAGE (Consumer Devices)
retlw 0x0C ; LOW
retlw 0x09 ; USAGE (Consumer Control)
retlw 0x01 ; LOW
retlw 0xA1 ; COLLECTION (APPLICATION)
retlw 0x01 ; LOW
retlw 0x85 ; REPORT_ID (2 Media)
retlw 0x02 ; LOW
retlw 0x19 ; Usage Minimum (0x00)
retlw 0x00 ;
retlw 0x2A ; Usage Maximum (0xAC format)
retlw 0x3C ;
retlw 0x02
retlw 0x15 ; logical minimun
retlw 0x00 ;
retlw 0x26 ; logical maximun (572)
retlw 0x3C ;
retlw 0x02 ;
retlw 0x95 ; report count 1
retlw 0x01 ;
retlw 0x75 ; report size 16
retlw 0x10 ;
retlw 0x81 ; input (Data,Var,Abs)
retlw 0x00 ;
retlw 0xC0 ; END_COLLECTION
EndReportDescriptor2
; String pointer table
USB_SD_Ptr
Strings
db low String0, high String0
db upper String0, 0
db low String1, high String1
db upper String1, 0
db low String2, high String2
db upper String2, 0
db low String3, high String3
db upper String3, 0
String0
retlw (String1-String0)/2 ; Length of string
retlw USB_DESCRIPTOR_STRING ; Descriptor type 3
retlw 0x09 ; Language ID (as defined by MS 0x0409)
retlw 0x04
; company name
String1
retlw (String2-String1)/2
retlw USB_DESCRIPTOR_STRING
retlw 'D'
retlw 0x00
retlw 'C'
retlw 0x00
retlw 'L'
retlw 0x00
retlw '.'
retlw 0x00
; product name
String2
retlw (String3-String2)/2
retlw USB_DESCRIPTOR_STRING
retlw 'P'
retlw 0x00
retlw 'B'
retlw 0x00
retlw 'J'
retlw 0x00
retlw 'U'
retlw 0x00
retlw 'I'
retlw 0x00
retlw '3'
retlw 0x00
retlw '2'
retlw 0x00
retlw 'I'
retlw 0x00
retlw 'A'
retlw 0x00
retlw '8'
retlw 0x00
retlw 'O'
retlw 0x00
retlw '2'
retlw 0x00
retlw '4'
retlw 0x00
; serial number
String3
retlw (String4-String3)/2
retlw USB_DESCRIPTOR_STRING
retlw 'D'
retlw 0x00
retlw 'J'
retlw 0x00
retlw 'C'
retlw 0x00
retlw '0'
retlw 0x00
retlw '0'
retlw 0x00
retlw '2'
retlw 0x00
retlw '2'
retlw 0x00
String4
retlw (String5-String4)/2
retlw USB_DESCRIPTOR_STRING
retlw 'A'
retlw 0x00
retlw 'R'
retlw 0x00
retlw 'C'
retlw 0x00
retlw 'A'
retlw 0x00
retlw 'D'
retlw 0x00
retlw 'E'
retlw 0x00
retlw ' '
retlw 0x00
retlw 'J'
retlw 0x00
retlw 'A'
retlw 0x00
retlw 'M'
retlw 0x00
retlw 'M'
retlw 0x00
retlw 'A'
retlw 0x00
String5
endasm
hid_desc_end
usb_hid.asm
; usb_hid.asm
;************************************************* *******************
; File Description:
; Change History:
; Rev Date Description
; 1.0 11/19/2004 Initial release
; 2.1 02/26/2007 Updated for simplicity and to use common
; coding style
;************************************************* ******************/
;/** INCLUDES ************************************************** *****/
;#include "GenericTypeDefs.h"
;#include "Compiler.h"
;#include "usb_config.h"
;#include "./USB/usb_device.h"
;#include "./USB/usb_function_hid.h"
;/** VARIABLES ************************************************** ****/
;#pragma udata
;BYTE idle_rate;
;BYTE active_protocol; // [0] Boot Protocol [1] Report Protocol
;BYTE hid_rpt_rx_len;
;/** PRIVATE PROTOTYPES *********************************************/
;void HIDGetReportHandler(void);
;void HIDSetReportHandler(void);
;/** DECLARATIONS ************************************************** */
;#pragma code
;/** CLASS SPECIFIC REQUESTS ****************************************/
;/************************************************** ******************
; * Function: void USBCheckHIDRequest(void)
; *
; * PreCondition: None
; *
; * Input: None
; *
; * Output: None
; *
; * Side Effects: None
; *
; * Overview: This routine checks the setup data packet to see
; * if it knows how to handle it
; *
; * Note: None
; ************************************************** *****************/
;//void USBCheckHIDRequest(void)
USBCheckHIDRequest
;//{
movlb high _USBMEMORYADDRESS ; Point to proper bank
;// if(SetupPkt.Recipient != RCPT_INTF) return;
movf SetupPkt, W ; Recipient = RCPT_INTF?
andlw 0x1f ; Mask to lower 5 bits
sublw RCPT_INTF
bnz USBCheckHIDRequestExit ; No
;// if((SetupPkt.bIntfID != HID_INTF_ID)&&
movlw HID_INTF_ID ; IntfID = HID_INTF_ID?
cpfseq SetupPkt + bIntfID
;// (SetupPkt.bIntfID != HID_DEV_INTF_ID)) return;
movlw HID_DEV_INTF_ID ; IntfID = HID_DEV_INTF_ID?
cpfseq SetupPkt + bIntfID
USBCheckHIDRequestExit
return ; No
; /*
; * There are two standard requests that hid.c may support.
; * 1. GET_DSC(DSC_HID,DSC_RPT,DSC_PHY);
; * 2. SET_DSC(DSC_HID,DSC_RPT,DSC_PHY);
; */
;// if(SetupPkt.bRequest == GET_DSC)
movlw GET_DSC ; Request = GET_DSC?
cpfseq SetupPkt + bRequest
bra USBCheckHIDRequestClass ; No
;// {
;// switch(SetupPkt.bDescriptorType)
;// {
;// case DSC_HID:
movlw DSC_HID ; DescriptorType = DSC_HID?
cpfseq SetupPkt + bDescriptorType
bra USBCheckHIDRequest1 ; No
;// if(USBActiveConfiguration == 1)
movlw 1 ; USBActiveConfiguration = 1?
cpfseq USBActiveConfiguration
bra USBCheckHIDRequestClass ; No
;// {
;// USBEP0SendROMPtr(
;// (ROM BYTE*)&configDescriptor1 + 18,
;// sizeof(USB_HID_DSC)+3, // RRoj hack
;// USB_EP0_INCLUDE_ZERO);
movlw HID_INTF_ID ; IntfID = HID_INTF_ID?
cpfseq SetupPkt + bIntfID
bra USBHdesc2 ; Use HIDDescriptor2
mSetSourcePointer HIDDescriptor1
mGetRomTableCount ; Set wCount
;// clrf info
bcf info, ctrl_trf_mem ; Indicate ROM
bsf info, includeZero ; Include a trailing zero packet
bsf info, busy
bra USBCheckHIDRequestClass
USBHdesc2
mSetSourcePointer HIDDescriptor2
mGetRomTableCount ; Set wCount
;// clrf info
bcf info, ctrl_trf_mem ; Indicate ROM
bsf info, includeZero ; Include a trailing zero packet
bsf info, busy
bra USBCheckHIDRequestClass
;// }
;// break;
USBCheckHIDRequest1
; case DSC_RPT:
movlw DSC_RPT ; DescriptorType = DSC_RPT?
cpfseq SetupPkt + bDescriptorType
bra USBCheckHIDRequest2 ; No
; if(USBActiveConfiguration == 1)
movlw 1 ; USBActiveConfiguration = 1?
cpfseq USBActiveConfiguration
bra USBCheckHIDRequestClass ; No
; {
; USBEP0SendROMPtr(
; (ROM BYTE*)&hid_rpt01,
; sizeof(hid_rpt01), //See usbcfg.h
; USB_EP0_INCLUDE_ZERO);
movlw HID_INTF_ID ; IntfID = HID_INTF_ID?
cpfseq SetupPkt + bIntfID
bra USBRDasc2 ; Use ReportDescriptor2
mSetSourcePointer ReportDescriptor1
movlw low (ReportDescriptor1Len) ; Set wCount
movwf TBLPTRL
movlw high (ReportDescriptor1Len)
movwf TBLPTRH
movlw upper (ReportDescriptor1Len)
movwf TBLPTRU
tblrd *+ ; Read count low
movff TABLAT, inCount
tblrd *+ ; Skip next
tblrd * ; Read count high
movff TABLAT, inCount + 1
;// clrf info
bcf info, ctrl_trf_mem ; Indicate ROM
bsf info, includeZero ; Include a trailing zero packet
bsf info, busy
bra USBCheckHIDRequestClass
USBRDasc2
mSetSourcePointer ReportDescriptor2
movlw low (ReportDescriptor1Len) ; Set wCount
movwf TBLPTRL
movlw high (ReportDescriptor1Len)
movwf TBLPTRH
movlw upper (ReportDescriptor1Len)
movwf TBLPTRU
tblrd *+ ; Read count low
movff TABLAT, inCount
tblrd *+ ; Skip next
tblrd * ; Read count high
movff TABLAT, inCount + 1
;// clrf info
bcf info, ctrl_trf_mem ; Indicate ROM
bsf info, includeZero ; Include a trailing zero packet
bsf info, busy
bra USBCheckHIDRequestClass
;// }
;// break;
https://drive.google.com/file/d/1J_o76uFFcyrDTBeuz-tusKk6rdubFsge/view?usp=sharing
I always try to use microde studio for many of my projects because of the speed and ease of reading the code, with its disadvantages such as higher space usage per program and a very small community, I use it because its benefits are greater. among my projects I need to create a composite device, searching the internet I have not found precise information on this topic, not even an example.
I have worked on this and I have achieved something that is close to achieving it,
At this point I think I need to properly address the second device endpoints.
I have analyzed pbppic18.mac USBOUT-->L?CALL PutUSB and the respective usb_dev.asm where I find that I can address correctly without modifying the code because the required Endpoint has been correctly stored in FSR0L. Despite my poor understanding, I have so far modified the usb_mem.asm, usb_dev.inc, and usb_hid.asm files.
The result of this has been that the PC recognizes the composite device correctly and interface 0 communicates (with some easily fixable glitches), but interface 1 is not heard. I think this potential problem is in usb_hid.asm, because invoking endpoint 82 I think it sends to both endpoints 81 and 82, causing me to lose data on device 0 and abort receiving from device 1
https://i.postimg.cc/bvsGSysv/Untitleddf.png
I need some help to find a solution to this problem, if you can help with any contribution I will be very grateful
DES_FirmAC01.bas
' USB descriptors for a HID device
'USBMEMORYADDRESS Con $400 ' USB RAM starts here (set in device header file)
USBMEMORYSIZE Con 256 ' USB RAM size in bytes
USBReservedMemory Var Byte[USBMEMORYSIZE] USBMEMORYADDRESS ' Reserve memory used by USB assembler code
goto hid_desc_end ' Skip over all of the USB assembler code
asm
#define USB_EP0_BUFF_SIZE 8 ; 8, 16, 32, or 64
#define USB_MAX_NUM_INT 2 ; For tracking Alternate Setting
#define USB_MAX_EP_NUMBER 2 ; UEP1
#define NUM_CONFIGURATIONS 1
#define NUM_INTERFACES 2
#define UCFG_VAL USB_PULLUP_ENABLE|USB_INTERNAL_TRANSCEIVER|USB_FUL L_SPEED|USB_PING_PONG__NO_PING_PONG
;#define UCFG_VAL USB_PULLUP_ENABLE|USB_INTERNAL_TRANSCEIVER|USB_LOW _SPEED|USB_PING_PONG__NO_PING_PONG
;#define USE_SELF_POWER_SENSE_IO
;#define USE_USB_BUS_SENSE_IO
#define USB_POLLING
; HID
; Endpoints Allocation
#define HID_INTF_ID 0x00
#define HID_EP 1
#define HID_INT_OUT_EP_SIZE 16
#define HID_INT_IN_EP_SIZE 16
#define HID_DEV_INTF_ID 0x01
#define HID_DEV_EP 2
#define HID_DEV_INT_OUT_EP_SIZE 16
#define HID_DEV_INT_IN_EP_SIZE 16
#define HID_NUM_OF_DSC 1
include "usb_hid.asm" ; Include rest of USB files, starting with HID class code
; ************************************************** ****************
; This table is polled by the host immediately after USB Reset has been released.
; This table defines the maximum packet size EP0 can take.
; See section 9.6.1 of the Rev 1.0 USB specification.
; These fields are application DEPENDENT. Modify these to meet
; your specifications.
; ************************************************** ****************
DeviceDescriptor
retlw (EndDeviceDescriptor-DeviceDescriptor)/2 ; bLength Length of this descriptor
retlw USB_DESCRIPTOR_DEVICE ; bDescType This is a DEVICE descriptor
retlw 0x00 ; bcdUSBUSB Revision 1.10 (low byte)
retlw 0x02 ; high byte
retlw 0x00 ; bDeviceClass zero means each interface operates independently
retlw 0x00 ; bDeviceSubClass
retlw 0x00 ; bDeviceProtocol
retlw USB_EP0_BUFF_SIZE ; bMaxPacketSize for EP0
; idVendor (low byte, high byte)
retlw 0xD9
retlw 0x04
; idProduct (low byte, high byte)
retlw 0x3C
retlw 0x00
retlw 0x00 ; bcdDevice (low byte)
retlw 0x01 ; (high byte)
retlw 0x01 ; iManufacturer (string index)
retlw 0x02 ; iProduct (string index)
retlw 0x03 ; iSerialNumber (string index)
retlw NUM_CONFIGURATIONS ; bNumConfigurations
EndDeviceDescriptor
; ************************************************** ****************
; This table is retrieved by the host after the address has been set.
; This table defines the configurations available for the device.
; See section 9.6.2 of the Rev 1.0 USB specification (page 184).
; These fields are application DEPENDENT.
; Modify these to meet your specifications.
; ************************************************** ****************
; Configuration pointer table
USB_CD_Ptr
Configs
db low Config1, high Config1
db upper Config1, 0
; Configuration Descriptor
Config1
retlw (Interface1-Config1)/2 ; bLength Length of this descriptor
retlw USB_DESCRIPTOR_CONFIGURATION ; bDescType 2=CONFIGURATION
Config1Len
retlw low ((EndConfig1 - Config1)/2) ; Length of this configuration
retlw high ((EndConfig1 - Config1)/2)
retlw NUM_INTERFACES ; bNumInterfaces Number of interfaces
retlw 0x01 ; bConfigValue Configuration Value
retlw 0x00 ; iConfig (string index)
retlw _DEFAULT|_SELF ; bmAttributes attributes - bus powered
retlw 0x32 ; Max power consumption (2X mA)
Interface1
retlw (HIDDescriptor1-Interface1)/2 ; length of descriptor
retlw USB_DESCRIPTOR_INTERFACE
retlw 0x00 ; number of interface, 0 based array
retlw 0x00 ; alternate setting
retlw 0x01 ; number of endpoints used in this interface
retlw 0x03 ; interface class - assigned by the USB
retlw 0x00 ; boot device
retlw 0x00 ; interface protocol
retlw 0x04 ; index to string descriptor that describes this interface
HIDDescriptor1
retlw (Endpoint1In-HIDDescriptor1)/2 ; descriptor size (9 bytes)
retlw DSC_HID ; descriptor type (HID)
retlw 0x11 ; HID class release number (1.11)
retlw 0x01
retlw 0x00 ; Localized country code (none)
retlw 0x01 ; # of HID class descriptor to follow (1)
retlw 0x22 ; Report descriptor type (HID)
ReportDescriptor1Len
retlw low ((EndReportDescriptor1-ReportDescriptor1)/2)
retlw high ((EndReportDescriptor1-ReportDescriptor1)/2)
Endpoint1In
retlw (Interface2-Endpoint1In)/2 ; length of descriptor
retlw USB_DESCRIPTOR_ENDPOINT
retlw HID_EP|_EP_IN ; EP1, In
retlw _INT ; Interrupt
retlw low (HID_INT_IN_EP_SIZE) ; This should be the size of the endpoint buffer
retlw high (HID_INT_IN_EP_SIZE)
retlw 0x01 ; Polling interval
;EndPoint1Out
; retlw (Interface2-EndPoint1Out)/2 ; Length of this Endpoint Descriptor
; retlw USB_DESCRIPTOR_ENDPOINT ; bDescriptorType = 5 for Endpoint Descriptor
; retlw HID_EP|_EP_OUT ; Endpoint number & direction
; retlw _INT ; Transfer type supported by this Endpoint
; retlw low (HID_INT_OUT_EP_SIZE) ; This should be the size of the endpoint buffer
; retlw high (HID_INT_OUT_EP_SIZE)
; retlw 0x01 ; Polling interval
Interface2
retlw (HIDDescriptor2-Interface2)/2 ; length of descriptor
retlw USB_DESCRIPTOR_INTERFACE ; INTERFACE descriptor type
retlw 0x01 ; number of interface, 0 based array
retlw 0x00 ; alternate setting
retlw 0x01 ; number of endpoints used in this interface
retlw 0x03 ; interface class - assigned by the USB
retlw 0x00 ; boot device
retlw 0x00 ; interface protocol
retlw 0x04 ; index to string descriptor that describes this interface
HIDDescriptor2
retlw (Endpoint2In-HIDDescriptor2)/2 ; descriptor size (9 bytes)
retlw DSC_HID ; descriptor type (HID)
retlw 0x11 ; HID class release number (1.11)
retlw 0x01
retlw 0x00 ; Localized country code (none)
retlw 0x01 ; # of HID class descriptor to follow (1)
retlw 0x22 ; Report descriptor type (HID)
ReportDescriptor2Len
retlw low ((EndReportDescriptor2-ReportDescriptor2)/2)
retlw high ((EndReportDescriptor2-ReportDescriptor2)/2)
Endpoint2In
retlw (EndConfig1-Endpoint2In)/2 ; length of descriptor
retlw USB_DESCRIPTOR_ENDPOINT
retlw HID_DEV_EP|_EP_IN ; EP2, In
retlw _INT ; Interrupt
retlw low (HID_DEV_INT_IN_EP_SIZE) ; This should be the size of the endpoint buffer
retlw high (HID_DEV_INT_IN_EP_SIZE)
retlw 0x01 ; Polling interval
;EndPoint2Out
; retlw (EndConfig1-EndPoint2Out)/2 ; Length of this Endpoint Descriptor
; retlw USB_DESCRIPTOR_ENDPOINT ; bDescriptorType = 5 for Endpoint Descriptor
; retlw HID_DEV_EP|_EP_OUT ; Endpoint number & direction
; retlw _INT ; Transfer type supported by this Endpoint
; retlw low (HID_DEV_INT_OUT_EP_SIZE) ; This should be the size of the endpoint buffer
; retlw high (HID_DEV_INT_OUT_EP_SIZE)
; retlw 0x01 ; Polling interval
EndConfig1
ReportDescriptor1
retlw 0x05 ; USAGE_PAGE (generic desktop Choose the usage page "mouse" is on
retlw 0x01 ; LOW
retlw 0x09 ; USAGE Device is a Gamepad
retlw 0x05 ; LOW
retlw 0xA1 ; COLLECTION (APPLICATION)
retlw 0x01 ; LOW
retlw 0x85 ; REPORT_ID (1 Pad1)
retlw 0x01 ; LOW
retlw 0xA1 ; Colection Physycal
retlw 0x00 ; LOW
retlw 0x09 ; usage x
retlw 0x30 ;
retlw 0x09 ; usage y
retlw 0x31 ;
retlw 0x15 ; logical minimun 0
retlw 0x00 ;
retlw 0x26 ; logical maximun 1023
retlw 0xFF ;
retlw 0x03 ;
retlw 0x35 ; Physical Minimum (0)
retlw 0x00 ;
retlw 0x46 ; Physical Maximum (1023)
retlw 0xFF ;
retlw 0x03 ;
retlw 0x95 ; REPORT_COUNT 2
retlw 0x02 ;
retlw 0x75 ; report size 16
retlw 0x10 ;
retlw 0x81 ; data,var,abs
retlw 0x02 ;
retlw 0xC0 ; END_COLLECTION
;******************************************
retlw 0xA1 ; Colection Physycal
retlw 0x00 ; LOW
retlw 0x09 ; usage Rx
retlw 0x33 ;
retlw 0x09 ; usage Ry
retlw 0x34 ;
retlw 0x15 ; logical minimun 0
retlw 0x00 ;
retlw 0x26 ; logical maximun 2047
retlw 0xFF ;
retlw 0x03 ;
retlw 0x35 ; Physical Minimum (0)
retlw 0x00 ;
retlw 0x46 ; Physical Maximum (2047)
retlw 0xFF ;
retlw 0x03 ;
retlw 0x95 ; REPORT_COUNT 2
retlw 0x02 ;
retlw 0x75 ; report size 16
retlw 0x10 ;
retlw 0x81 ; data,var,abs
retlw 0x02 ;
retlw 0xC0 ; END_COLLECTION
;******************************************
retlw 0x05 ; USAGE_PAGE (Button)
retlw 0x09 ; low
retlw 0x19 ; Usage Minimum (Button 1)
retlw 0x01 ;
retlw 0x29 ; Usage Maximum (Button 13)
retlw 0x0D ;
retlw 0x95 ; report count 13
retlw 0x0D ;
retlw 0x75 ; report size 1
retlw 0x01 ;
retlw 0x81 ; input data,var,abs
retlw 0x02 ;
retlw 0x95 ; report count 1
retlw 0x01 ;
retlw 0x75 ; report size 3
retlw 0x03 ;
retlw 0x81 ; input Cnst,var,abs
retlw 0x01 ;
retlw 0xC0 ; END_COLLECTION
;************************************************* **********************
;* GamePAD 2 *
;************************************************* **********************
retlw 0x05 ; USAGE_PAGE (generic desktop Choose the usage page "mouse" is on
retlw 0x01 ; LOW
retlw 0x09 ; USAGE Device is a Gamepad
retlw 0x05 ; LOW
retlw 0xA1 ; COLLECTION (APPLICATION)
retlw 0x01 ; LOW
retlw 0x85 ; REPORT_ID (1 Pad1)
retlw 0x02 ; LOW
retlw 0xA1 ; Colection Physycal
retlw 0x00 ; LOW
retlw 0x09 ; usage x
retlw 0x30 ;
retlw 0x09 ; usage y
retlw 0x31 ;
retlw 0x15 ; logical minimun 0
retlw 0x00 ;
retlw 0x26 ; logical maximun 1023
retlw 0xFF ;
retlw 0x03 ;
retlw 0x35 ; Physical Minimum (0)
retlw 0x00 ;
retlw 0x46 ; Physical Maximum (1023)
retlw 0xFF ;
retlw 0x03 ;
retlw 0x95 ; REPORT_COUNT 2
retlw 0x02 ;
retlw 0x75 ; report size 16
retlw 0x10 ;
retlw 0x81 ; data,var,abs
retlw 0x02 ;
retlw 0xC0 ; END_COLLECTION
;******************************************
retlw 0xA1 ; Colection Physycal
retlw 0x00 ; LOW
retlw 0x09 ; usage Rx
retlw 0x33 ;
retlw 0x09 ; usage Ry
retlw 0x34 ;
retlw 0x15 ; logical minimun 0
retlw 0x00 ;
retlw 0x26 ; logical maximun 2047
retlw 0xFF ;
retlw 0x03 ;
retlw 0x35 ; Physical Minimum (0)
retlw 0x00 ;
retlw 0x46 ; Physical Maximum (2047)
retlw 0xFF ;
retlw 0x03 ;
retlw 0x95 ; REPORT_COUNT 2
retlw 0x02 ;
retlw 0x75 ; report size 16
retlw 0x10 ;
retlw 0x81 ; data,var,abs
retlw 0x02 ;
retlw 0xC0 ; END_COLLECTION
;******************************************
retlw 0x05 ; USAGE_PAGE (Button)
retlw 0x09 ; low
retlw 0x19 ; Usage Minimum (Button 1)
retlw 0x01 ;
retlw 0x29 ; Usage Maximum (Button 13)
retlw 0x0E ;
retlw 0x95 ; report count 13
retlw 0x0E ;
retlw 0x75 ; report size 1
retlw 0x01 ;
retlw 0x81 ; input data,var,abs
retlw 0x02 ;
retlw 0x95 ; report count 1
retlw 0x01 ;
retlw 0x75 ; report size 2
retlw 0x02 ;
retlw 0x81 ; input Cnst,var,abs
retlw 0x01 ;
retlw 0xC0 ; END_COLLECTION
EndReportDescriptor1
ReportDescriptor2
;***************************************
;* Mouse Emu *
;***************************************
retlw 0x05 ; USAGE_PAGE (generic desktop)
retlw 0x01 ; LOW
retlw 0x09 ; USAGE Mouse
retlw 0x02 ; LOW
retlw 0xA1 ; COLLECTION (APPLICATION)
retlw 0x01 ; LOW
retlw 0x85 ; REPORT_ID (1)
retlw 0x01 ; LOW
retlw 0x09 ; USAGE_PAGE (Pointer)
retlw 0x01 ; LOW
retlw 0xA1 ; COLLECTION (Physical)
retlw 0x00 ;
retlw 0x05 ; USAGE_PAGE (Button)
retlw 0x09 ;
retlw 0x19 ; Usage Minimum (Button 1)
retlw 0x01 ;
retlw 0x29 ; Usage Maximum (Button 2)
retlw 0x02 ;
retlw 0x15 ; logical minimun
retlw 0x00 ;
retlw 0x25 ; logical maximun
retlw 0x01 ;
retlw 0x75 ; report size 1
retlw 0x01 ;
retlw 0x95 ; report count 3
retlw 0x02 ;
retlw 0x81 ; input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
retlw 0x02 ;
retlw 0x95 ; report count 3
retlw 0x06 ;
retlw 0x81 ; input (Data,Var,Abs)
retlw 0x03 ;
retlw 0x05 ; USAGE_PAGE (Generic Desktop)
retlw 0x01 ; LOW
retlw 0x09 ; Usage(X)
retlw 0x30 ;
retlw 0x09 ; Usage(Y)
retlw 0x31 ;
retlw 0x15 ; logical minimun (-127)
retlw 0x81 ;
retlw 0x25 ; logical maximun (127)
retlw 0x7F ;
retlw 0x75 ; report size 8
retlw 0x08 ;
retlw 0x95 ; report count 2
retlw 0x02 ;
retlw 0x81 ; INPUT (Data,Var,Rel)
retlw 0x06 ;
retlw 0xC0 ; END_COLLECTION
retlw 0xC0 ; END_COLLECTION
;***************************************
;* Keyboard Emu *
;***************************************
;***************************************
;* Volume Control *
;***************************************
retlw 0x05 ; USAGE_PAGE (Consumer Devices)
retlw 0x0C ; LOW
retlw 0x09 ; USAGE (Consumer Control)
retlw 0x01 ; LOW
retlw 0xA1 ; COLLECTION (APPLICATION)
retlw 0x01 ; LOW
retlw 0x85 ; REPORT_ID (2 Media)
retlw 0x02 ; LOW
retlw 0x19 ; Usage Minimum (0x00)
retlw 0x00 ;
retlw 0x2A ; Usage Maximum (0xAC format)
retlw 0x3C ;
retlw 0x02
retlw 0x15 ; logical minimun
retlw 0x00 ;
retlw 0x26 ; logical maximun (572)
retlw 0x3C ;
retlw 0x02 ;
retlw 0x95 ; report count 1
retlw 0x01 ;
retlw 0x75 ; report size 16
retlw 0x10 ;
retlw 0x81 ; input (Data,Var,Abs)
retlw 0x00 ;
retlw 0xC0 ; END_COLLECTION
EndReportDescriptor2
; String pointer table
USB_SD_Ptr
Strings
db low String0, high String0
db upper String0, 0
db low String1, high String1
db upper String1, 0
db low String2, high String2
db upper String2, 0
db low String3, high String3
db upper String3, 0
String0
retlw (String1-String0)/2 ; Length of string
retlw USB_DESCRIPTOR_STRING ; Descriptor type 3
retlw 0x09 ; Language ID (as defined by MS 0x0409)
retlw 0x04
; company name
String1
retlw (String2-String1)/2
retlw USB_DESCRIPTOR_STRING
retlw 'D'
retlw 0x00
retlw 'C'
retlw 0x00
retlw 'L'
retlw 0x00
retlw '.'
retlw 0x00
; product name
String2
retlw (String3-String2)/2
retlw USB_DESCRIPTOR_STRING
retlw 'P'
retlw 0x00
retlw 'B'
retlw 0x00
retlw 'J'
retlw 0x00
retlw 'U'
retlw 0x00
retlw 'I'
retlw 0x00
retlw '3'
retlw 0x00
retlw '2'
retlw 0x00
retlw 'I'
retlw 0x00
retlw 'A'
retlw 0x00
retlw '8'
retlw 0x00
retlw 'O'
retlw 0x00
retlw '2'
retlw 0x00
retlw '4'
retlw 0x00
; serial number
String3
retlw (String4-String3)/2
retlw USB_DESCRIPTOR_STRING
retlw 'D'
retlw 0x00
retlw 'J'
retlw 0x00
retlw 'C'
retlw 0x00
retlw '0'
retlw 0x00
retlw '0'
retlw 0x00
retlw '2'
retlw 0x00
retlw '2'
retlw 0x00
String4
retlw (String5-String4)/2
retlw USB_DESCRIPTOR_STRING
retlw 'A'
retlw 0x00
retlw 'R'
retlw 0x00
retlw 'C'
retlw 0x00
retlw 'A'
retlw 0x00
retlw 'D'
retlw 0x00
retlw 'E'
retlw 0x00
retlw ' '
retlw 0x00
retlw 'J'
retlw 0x00
retlw 'A'
retlw 0x00
retlw 'M'
retlw 0x00
retlw 'M'
retlw 0x00
retlw 'A'
retlw 0x00
String5
endasm
hid_desc_end
usb_hid.asm
; usb_hid.asm
;************************************************* *******************
; File Description:
; Change History:
; Rev Date Description
; 1.0 11/19/2004 Initial release
; 2.1 02/26/2007 Updated for simplicity and to use common
; coding style
;************************************************* ******************/
;/** INCLUDES ************************************************** *****/
;#include "GenericTypeDefs.h"
;#include "Compiler.h"
;#include "usb_config.h"
;#include "./USB/usb_device.h"
;#include "./USB/usb_function_hid.h"
;/** VARIABLES ************************************************** ****/
;#pragma udata
;BYTE idle_rate;
;BYTE active_protocol; // [0] Boot Protocol [1] Report Protocol
;BYTE hid_rpt_rx_len;
;/** PRIVATE PROTOTYPES *********************************************/
;void HIDGetReportHandler(void);
;void HIDSetReportHandler(void);
;/** DECLARATIONS ************************************************** */
;#pragma code
;/** CLASS SPECIFIC REQUESTS ****************************************/
;/************************************************** ******************
; * Function: void USBCheckHIDRequest(void)
; *
; * PreCondition: None
; *
; * Input: None
; *
; * Output: None
; *
; * Side Effects: None
; *
; * Overview: This routine checks the setup data packet to see
; * if it knows how to handle it
; *
; * Note: None
; ************************************************** *****************/
;//void USBCheckHIDRequest(void)
USBCheckHIDRequest
;//{
movlb high _USBMEMORYADDRESS ; Point to proper bank
;// if(SetupPkt.Recipient != RCPT_INTF) return;
movf SetupPkt, W ; Recipient = RCPT_INTF?
andlw 0x1f ; Mask to lower 5 bits
sublw RCPT_INTF
bnz USBCheckHIDRequestExit ; No
;// if((SetupPkt.bIntfID != HID_INTF_ID)&&
movlw HID_INTF_ID ; IntfID = HID_INTF_ID?
cpfseq SetupPkt + bIntfID
;// (SetupPkt.bIntfID != HID_DEV_INTF_ID)) return;
movlw HID_DEV_INTF_ID ; IntfID = HID_DEV_INTF_ID?
cpfseq SetupPkt + bIntfID
USBCheckHIDRequestExit
return ; No
; /*
; * There are two standard requests that hid.c may support.
; * 1. GET_DSC(DSC_HID,DSC_RPT,DSC_PHY);
; * 2. SET_DSC(DSC_HID,DSC_RPT,DSC_PHY);
; */
;// if(SetupPkt.bRequest == GET_DSC)
movlw GET_DSC ; Request = GET_DSC?
cpfseq SetupPkt + bRequest
bra USBCheckHIDRequestClass ; No
;// {
;// switch(SetupPkt.bDescriptorType)
;// {
;// case DSC_HID:
movlw DSC_HID ; DescriptorType = DSC_HID?
cpfseq SetupPkt + bDescriptorType
bra USBCheckHIDRequest1 ; No
;// if(USBActiveConfiguration == 1)
movlw 1 ; USBActiveConfiguration = 1?
cpfseq USBActiveConfiguration
bra USBCheckHIDRequestClass ; No
;// {
;// USBEP0SendROMPtr(
;// (ROM BYTE*)&configDescriptor1 + 18,
;// sizeof(USB_HID_DSC)+3, // RRoj hack
;// USB_EP0_INCLUDE_ZERO);
movlw HID_INTF_ID ; IntfID = HID_INTF_ID?
cpfseq SetupPkt + bIntfID
bra USBHdesc2 ; Use HIDDescriptor2
mSetSourcePointer HIDDescriptor1
mGetRomTableCount ; Set wCount
;// clrf info
bcf info, ctrl_trf_mem ; Indicate ROM
bsf info, includeZero ; Include a trailing zero packet
bsf info, busy
bra USBCheckHIDRequestClass
USBHdesc2
mSetSourcePointer HIDDescriptor2
mGetRomTableCount ; Set wCount
;// clrf info
bcf info, ctrl_trf_mem ; Indicate ROM
bsf info, includeZero ; Include a trailing zero packet
bsf info, busy
bra USBCheckHIDRequestClass
;// }
;// break;
USBCheckHIDRequest1
; case DSC_RPT:
movlw DSC_RPT ; DescriptorType = DSC_RPT?
cpfseq SetupPkt + bDescriptorType
bra USBCheckHIDRequest2 ; No
; if(USBActiveConfiguration == 1)
movlw 1 ; USBActiveConfiguration = 1?
cpfseq USBActiveConfiguration
bra USBCheckHIDRequestClass ; No
; {
; USBEP0SendROMPtr(
; (ROM BYTE*)&hid_rpt01,
; sizeof(hid_rpt01), //See usbcfg.h
; USB_EP0_INCLUDE_ZERO);
movlw HID_INTF_ID ; IntfID = HID_INTF_ID?
cpfseq SetupPkt + bIntfID
bra USBRDasc2 ; Use ReportDescriptor2
mSetSourcePointer ReportDescriptor1
movlw low (ReportDescriptor1Len) ; Set wCount
movwf TBLPTRL
movlw high (ReportDescriptor1Len)
movwf TBLPTRH
movlw upper (ReportDescriptor1Len)
movwf TBLPTRU
tblrd *+ ; Read count low
movff TABLAT, inCount
tblrd *+ ; Skip next
tblrd * ; Read count high
movff TABLAT, inCount + 1
;// clrf info
bcf info, ctrl_trf_mem ; Indicate ROM
bsf info, includeZero ; Include a trailing zero packet
bsf info, busy
bra USBCheckHIDRequestClass
USBRDasc2
mSetSourcePointer ReportDescriptor2
movlw low (ReportDescriptor1Len) ; Set wCount
movwf TBLPTRL
movlw high (ReportDescriptor1Len)
movwf TBLPTRH
movlw upper (ReportDescriptor1Len)
movwf TBLPTRU
tblrd *+ ; Read count low
movff TABLAT, inCount
tblrd *+ ; Skip next
tblrd * ; Read count high
movff TABLAT, inCount + 1
;// clrf info
bcf info, ctrl_trf_mem ; Indicate ROM
bsf info, includeZero ; Include a trailing zero packet
bsf info, busy
bra USBCheckHIDRequestClass
;// }
;// break;
https://drive.google.com/file/d/1J_o76uFFcyrDTBeuz-tusKk6rdubFsge/view?usp=sharing