📄 chap9.s
字号:
.module CHAP9.C
.area lit(rom, con, rel)
_DeviceDescr::
.byte 18
.byte 1
.word 1
.byte 0
.byte 0
.byte 0
.byte 16
.word 33797
.word 256
.word 1
.byte 0
.byte 0
.byte 0
.byte 1
.dbfile J:\PDIUSBD12-Materials\富昌\优盘5.0\CHAP9.C
.dbstruct 0 18 _USB_DEVICE_DESCRIPTOR
.dbfield 0 bLength c
.dbfield 1 bDescriptorType c
.dbfield 2 bcdUSB s
.dbfield 4 bDeviceClass c
.dbfield 5 bDeviceSubClass c
.dbfield 6 bDeviceProtocol c
.dbfield 7 bMaxPacketSize0 c
.dbfield 8 idVendor s
.dbfield 10 idProduct s
.dbfield 12 bcdDevice s
.dbfield 14 iManufacturer c
.dbfield 15 iProduct c
.dbfield 16 iSerialNumber c
.dbfield 17 bNumConfigurations c
.dbend
.dbsym e DeviceDescr _DeviceDescr kS[_USB_DEVICE_DESCRIPTOR]
_ConfigDescr::
.byte 9
.byte 2
.word 46
.byte 1
.byte 1
.byte 0
.byte 128
.byte 250
.dbstruct 0 9 _USB_CONFIGURATION_DESCRIPTOR
.dbfield 0 bLength c
.dbfield 1 bDescriptorType c
.dbfield 2 wTotalLength s
.dbfield 4 bNumInterfaces c
.dbfield 5 bConfigurationValue c
.dbfield 6 iConfiguration c
.dbfield 7 bmAttributes c
.dbfield 8 MaxPower c
.dbend
.dbsym e ConfigDescr _ConfigDescr kS[_USB_CONFIGURATION_DESCRIPTOR]
_InterfaceDescr::
.byte 9
.byte 4
.byte 0
.byte 0
.byte 4
.byte 8
.byte 6
.byte 80
.byte 0
.dbstruct 0 9 _USB_INTERFACE_DESCRIPTOR
.dbfield 0 bLength c
.dbfield 1 bDescriptorType c
.dbfield 2 bInterfaceNumber c
.dbfield 3 bAlternateSetting c
.dbfield 4 bNumEndpoints c
.dbfield 5 bInterfaceClass c
.dbfield 6 bInterfaceSubClass c
.dbfield 7 bInterfaceProtocol c
.dbfield 8 iInterface c
.dbend
.dbsym e InterfaceDescr _InterfaceDescr kS[_USB_INTERFACE_DESCRIPTOR]
_EP1_TXDescr::
.byte 7
.byte 5
.byte 129
.byte 3
.word 4
.byte 10
.dbstruct 0 7 _USB_ENDPOINT_DESCRIPTOR
.dbfield 0 bLength c
.dbfield 1 bDescriptorType c
.dbfield 2 bEndpointAddress c
.dbfield 3 bmAttributes c
.dbfield 4 wMaxPacketSize s
.dbfield 6 bInterval c
.dbend
.dbsym e EP1_TXDescr _EP1_TXDescr kS[_USB_ENDPOINT_DESCRIPTOR]
_EP1_RXDescr::
.byte 7
.byte 5
.byte 1
.byte 3
.word 4
.byte 10
.dbsym e EP1_RXDescr _EP1_RXDescr kS[_USB_ENDPOINT_DESCRIPTOR]
_EP2_TXDescr::
.byte 7
.byte 5
.byte 130
.byte 2
.word 64
.byte 10
.dbsym e EP2_TXDescr _EP2_TXDescr kS[_USB_ENDPOINT_DESCRIPTOR]
_EP2_RXDescr::
.byte 7
.byte 5
.byte 2
.byte 2
.word 64
.byte 10
.dbsym e EP2_RXDescr _EP2_RXDescr kS[_USB_ENDPOINT_DESCRIPTOR]
.area text(rom, con, rel)
.dbfile J:\PDIUSBD12-Materials\富昌\优盘5.0\CHAP9.C
.dbfunc e reserved _reserved fV
.even
_reserved::
.dbline -1
.dbline 102
; #include <macros.h>
; #include <stdio.h>
; #include <string.h>
;
; #include "D12CI.H"
; #include "MAIN.H"
; #include "USB100.H"
; #include "CHAP9.H"
;
; extern void single_transmit(unsigned char *buf,unsigned char len);
; extern void code_transmit(const unsigned char * pRomData,unsigned short len);
; extern void stall_ep0(void);
; extern void init_unconfig(void);
; extern void init_config(void);
;
; #define NUM_ENDPOINTS 4
; #define CONFIG_DESCRIPTOR_LENGTH sizeof(USB_CONFIGURATION_DESCRIPTOR)\
; +sizeof(USB_INTERFACE_DESCRIPTOR)\
; +(NUM_ENDPOINTS*sizeof(USB_ENDPOINT_DESCRIPTOR))
; extern CONTROL_XFER ControlData;
; extern IO_REQUEST ioRequest;
; extern EPPFLAGS bEPPflags;
;
; const USB_DEVICE_DESCRIPTOR DeviceDescr=
; {
; sizeof(USB_DEVICE_DESCRIPTOR),
; USB_DEVICE_DESCRIPTOR_TYPE,
; 0x0001,//SWAP(0x0100),
; 0,//USB_CLASS_CODE_TEST_CLASS_DEVICE,
; 0,
; 0,
; EP0_PACKET_SIZE,
; 0x8405,//SWAP(0x0471),
; 0x0100,//SWAP(0x0666),
; 0x0001,//SWAP(0x0100),
; 0,
; 0,
; 0,
; 0x01
; };
; const USB_CONFIGURATION_DESCRIPTOR ConfigDescr=
; {
; sizeof(USB_CONFIGURATION_DESCRIPTOR),
; USB_CONFIGURATION_DESCRIPTOR_TYPE,
; CONFIG_DESCRIPTOR_LENGTH,//SWAP(CONFIG_DESCRIPTOR_LENGTH),
; 1,
; 1,
; 0,
; 0x80,
; 0xfa
; };
; const USB_INTERFACE_DESCRIPTOR InterfaceDescr=
; {
; sizeof(USB_INTERFACE_DESCRIPTOR),
; USB_INTERFACE_DESCRIPTOR_TYPE,
; 0,
; 0,
; NUM_ENDPOINTS,
; USB_DEVICE_CLASS_STORAGE,
; 0x06,//SCSI
; 0x50,//bulk only Transport
; 0
; };
; const USB_ENDPOINT_DESCRIPTOR EP1_TXDescr=
; {
; sizeof(USB_ENDPOINT_DESCRIPTOR),
; USB_ENDPOINT_DESCRIPTOR_TYPE,
; 0x81,
; USB_ENDPOINT_TYPE_INTERRUPT,
; EP1_PACKET_SIZE,//SWAP(EP1_PACKET_SIZE),
; 10
; };
; const USB_ENDPOINT_DESCRIPTOR EP1_RXDescr=
; {
; sizeof(USB_ENDPOINT_DESCRIPTOR),
; USB_ENDPOINT_DESCRIPTOR_TYPE,
; 0x1,
; USB_ENDPOINT_TYPE_INTERRUPT,
; EP1_PACKET_SIZE,//SWAP(EP1_PACKET_SIZE),
; 10
; };
; const USB_ENDPOINT_DESCRIPTOR EP2_TXDescr=
; {
; sizeof(USB_ENDPOINT_DESCRIPTOR),
; USB_ENDPOINT_DESCRIPTOR_TYPE,
; 0x82,
; USB_ENDPOINT_TYPE_BULK,
; EP2_PACKET_SIZE,//SWAP(EP2_PACKET_SIZE),
; 10
; };
; const USB_ENDPOINT_DESCRIPTOR EP2_RXDescr=
; {
; sizeof(USB_ENDPOINT_DESCRIPTOR),
; USB_ENDPOINT_DESCRIPTOR_TYPE,
; 0x2,
; USB_ENDPOINT_TYPE_BULK,
; EP2_PACKET_SIZE,//SWAP(EP2_PACKET_SIZE),
; 10
; };
; //USB Protocol layer
; void reserved(void)
; {
.dbline 103
; stall_ep0();
xcall _stall_ep0
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e get_status _get_status fV
; c -> R20
; endp -> R22
; txdat -> y+0
; bRecipient -> R20
.even
_get_status::
xcall push_gset2
sbiw R28,2
.dbline -1
.dbline 107
; }
; //USB standard device requests
; void get_status(void)
; {
.dbline 109
; unsigned char endp,txdat[2];
; unsigned char bRecipient=ControlData.DeviceRequest.bmRequestType&USB_RECIPIENT;
lds R20,_ControlData
andi R20,31
.dbline 111
; unsigned char c;
; if(bRecipient==USB_RECIPIENT_DEVICE)
brne L3
.dbline 112
; {
.dbline 113
; if(bEPPflags.bits.remote_wakeup==1)
lds R24,_bEPPflags
lsr R24
lsr R24
lsr R24
andi R24,1
cpi R24,1
brne L5
.dbline 114
; txdat[0]=3;
ldi R24,3
std y+0,R24
xjmp L6
L5:
.dbline 116
; else
; txdat[0]=1;
ldi R24,1
std y+0,R24
L6:
.dbline 117
; txdat[1]=0;
clr R2
std y+1,R2
.dbline 118
; single_transmit(txdat,2);
ldi R18,2
movw R16,R28
xcall _single_transmit
.dbline 119
; }
xjmp L4
L3:
.dbline 120
; else if(bRecipient==USB_RECIPIENT_INTERFACE)
cpi R20,1
brne L8
.dbline 121
; {
.dbline 122
; txdat[0]=0;
clr R2
std y+0,R2
.dbline 123
; txdat[1]=0;
std y+1,R2
.dbline 124
; single_transmit(txdat,2);
ldi R18,2
movw R16,R28
xcall _single_transmit
.dbline 125
; }
xjmp L9
L8:
.dbline 126
; else if(bRecipient==USB_RECIPIENT_ENDPOINT)
cpi R20,2
brne L11
.dbline 127
; {
.dbline 128
; endp=(unsigned char)(ControlData.DeviceRequest.wIndex&MAX_ENDPOINTS);
lds R22,_ControlData+4
andi R22,3
andi R23,0
.dbline 129
; if(ControlData.DeviceRequest.wIndex&(unsigned char)USB_ENDPOINT_DIRECTION_MASK)
lds R2,_ControlData+4
lds R3,_ControlData+4+1
sbrs R2,7
rjmp L14
.dbline 130
; c=D12_SelectEndpoint(endp*2+1);
ldi R24,2
mul R24,R22
mov R16,R0
subi R16,255 ; addi 1
xcall _D12_SelectEndpoint
mov R20,R16
xjmp L15
L14:
.dbline 132
; else
; c=D12_SelectEndpoint(endp*2);
ldi R24,2
mul R24,R22
mov R16,R0
xcall _D12_SelectEndpoint
mov R20,R16
L15:
.dbline 133
; if(c&D12_STALL)
sbrs R20,1
rjmp L17
.dbline 134
; txdat[0]=1;
ldi R24,1
std y+0,R24
xjmp L18
L17:
.dbline 136
; else
; txdat[0]=0;
clr R2
std y+0,R2
L18:
.dbline 137
; txdat[1]=0;
clr R2
std y+1,R2
.dbline 138
; single_transmit(txdat,2);
ldi R18,2
movw R16,R28
xcall _single_transmit
.dbline 139
; }
xjmp L12
L11:
.dbline 140
; else stall_ep0();
xcall _stall_ep0
L12:
L9:
L4:
.dbline -2
L2:
adiw R28,2
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r c 20 c
.dbsym r endp 22 c
.dbsym l txdat 0 A[2:2]c
.dbsym r bRecipient 20 c
.dbend
.dbfunc e clear_feature _clear_feature fV
; endp -> R20
; bRecipient -> R20
.even
_clear_feature::
xcall push_gset1
.dbline -1
.dbline 143
; }
; void clear_feature(void)
; {
.dbline 145
; unsigned char endp;
; unsigned char bRecipient=ControlData.DeviceRequest.bmRequestType&USB_RECIPIENT;
lds R20,_ControlData
andi R20,31
.dbline 146
; if(bRecipient==USB_RECIPIENT_DEVICE
brne L21
lds R24,_ControlData+2
lds R25,_ControlData+2+1
cpi R24,1
ldi R30,0
cpc R25,R30
brne L21
.dbline 148
; &&ControlData.DeviceRequest.wValue==USB_FEATURE_REMOTE_WAKEUP)
; {
.dbline 149
; DISABLE;
cli
.dbline 150
; bEPPflags.bits.remote_wakeup=0;
lds R24,_bEPPflags
andi R24,247
sts _bEPPflags,R24
.dbline 151
; ENABLE;
sei
.dbline 152
; single_transmit(0,0);
clr R18
clr R16
clr R17
xcall _single_transmit
.dbline 153
; }
xjmp L22
L21:
.dbline 154
; else if(bRecipient==USB_RECIPIENT_ENDPOINT
cpi R20,2
brne L24
lds R2,_ControlData+2
lds R3,_ControlData+2+1
tst R2
brne L24
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -