⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.s

📁 基于D12
💻 S
📖 第 1 页 / 共 2 页
字号:
	.dbline -1
	.dbline 107
; }
; void init_config(void)
; {
	.dbline 108
;   D12_SetEndpointEnable(1);
	ldi R16,1
	xcall _D12_SetEndpointEnable
	.dbline -2
L12:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e single_transmit _single_transmit fV
;            len -> R20
;            buf -> R22,R23
	.even
_single_transmit::
	xcall push_gset2
	mov R20,R18
	movw R22,R16
	sbiw R28,2
	.dbline -1
	.dbline 111
	.dbline 112
	ldi R24,16
	cp R24,R20
	brlo L14
	.dbline 113
	.dbline 114
	std y+1,R23
	std y+0,R22
	mov R18,R20
	ldi R16,1
	xcall _D12_WriteEndpoint
	.dbline 115
L14:
	.dbline -2
L13:
	adiw R28,2
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r len 20 c
	.dbsym r buf 22 pc
	.dbend
	.dbfunc e code_transmit _code_transmit fV
;            len -> R22,R23
;       pRomData -> R20,R21
	.even
_code_transmit::
	xcall push_gset2
	movw R22,R18
	movw R20,R16
	sbiw R28,2
	.dbline -1
	.dbline 118
; }
; void single_transmit(unsigned char * buf,unsigned char len)
; {
;   if(len<=EP0_PACKET_SIZE)
;   {
;      D12_WriteEndpoint(1,len,buf);
;   }
; }
; void code_transmit(const unsigned char * pRomData,unsigned short len)
; {
	.dbline 119
;   ControlData.wCount=0;
	clr R2
	clr R3
	sts _ControlData+10+1,R3
	sts _ControlData+10,R2
	.dbline 120
;   if(ControlData.wLength>len)
	lds R2,_ControlData+8
	lds R3,_ControlData+8+1
	cp R22,R2
	cpc R23,R3
	brsh L18
	.dbline 121
;      ControlData.wLength=len;
	sts _ControlData+8+1,R23
	sts _ControlData+8,R22
L18:
	.dbline 122
;   ControlData.pCData=pRomData;  
	sts _ControlData+14+1,R21
	sts _ControlData+14,R20
	.dbline 123
;   if(ControlData.wLength>=EP0_PACKET_SIZE)
	lds R24,_ControlData+8
	lds R25,_ControlData+8+1
	cpi R24,16
	ldi R30,0
	cpc R25,R30
	brlo L23
	.dbline 124
;   {
	.dbline 125
;      bEPPflags.bits.rom_state=1;
	lds R24,_bEPPflags
	lds R25,_bEPPflags+1
	ori R25,8
	sts _bEPPflags+1,R25
	sts _bEPPflags,R24
	.dbline 126
;      D12_CWriteEndpoint(1,EP0_PACKET_SIZE,ControlData.pCData);
	movw R2,R20
	std y+1,R3
	std y+0,R2
	ldi R18,16
	ldi R19,0
	ldi R16,1
	ldi R17,0
	xcall _D12_CWriteEndpoint
	.dbline 127
;      ControlData.wCount+=EP0_PACKET_SIZE;
	lds R24,_ControlData+10
	lds R25,_ControlData+10+1
	adiw R24,16
	sts _ControlData+10+1,R25
	sts _ControlData+10,R24
	.dbline 128
;      DISABLE;
	cli
	.dbline 129
;      bEPPflags.bits.control_state=USB_TRANSMIT;
	lds R24,_bEPPflags
	andi R24,159
	ori R24,32
	sts _bEPPflags,R24
	.dbline 130
;      ENABLE;
	sei
	.dbline 131
;   }
	xjmp L24
L23:
	.dbline 133
	.dbline 134
	std y+1,R21
	std y+0,R20
	lds R18,_ControlData+8
	lds R19,_ControlData+8+1
	ldi R16,1
	ldi R17,0
	xcall _D12_CWriteEndpoint
	.dbline 135
	lds R2,_ControlData+8
	lds R3,_ControlData+8+1
	lds R4,_ControlData+10
	lds R5,_ControlData+10+1
	add R4,R2
	adc R5,R3
	sts _ControlData+10+1,R5
	sts _ControlData+10,R4
	.dbline 136
	cli
	.dbline 137
	lds R24,_bEPPflags
	andi R24,159
	sts _bEPPflags,R24
	.dbline 138
	sei
	.dbline 139
L24:
	.dbline -2
L16:
	adiw R28,2
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r len 22 s
	.dbsym r pRomData 20 pkc
	.dbend
	.dbfunc e control_handler _control_handler fV
;            req -> R20
;           type -> R22
	.even
_control_handler::
	xcall push_gset2
	.dbline -1
	.dbline 142
;   else
;   {
;      D12_CWriteEndpoint(1,ControlData.wLength,pRomData);
;      ControlData.wCount+=ControlData.wLength;
;      DISABLE;
;      bEPPflags.bits.control_state=USB_IDLE;
;      ENABLE;
;   }
; }
; void control_handler()
; {
	.dbline 144
;   unsigned char type,req;
;   type=ControlData.DeviceRequest.bmRequestType&USB_REQUEST_TYPE_MASK;
	lds R22,_ControlData
	andi R22,96
	.dbline 145
;   req=ControlData.DeviceRequest.bRequest&USB_REQUEST_MASK;
	lds R20,_ControlData+1
	andi R20,15
	.dbline 146
;   if(type==USB_STANDARD_REQUEST)
	tst R22
	brne L33
	.dbline 147
;      (*StandardDeviceRequest[req])();
	ldi R24,2
	mul R24,R20
	movw R30,R0
	ldi R24,<_StandardDeviceRequest
	ldi R25,>_StandardDeviceRequest
	add R30,R24
	adc R31,R25
	ldd R26,z+0
	ldd R27,z+1
	movw R30,R26
	xcall xicall
	xjmp L34
L33:
	.dbline 148
;   else if(type==USB_VENDOR_REQUEST)
	cpi R22,64
	brne L35
	.dbline 149
;      (*VendorDeviceRequest[req])();
	ldi R24,2
	mul R24,R20
	movw R30,R0
	ldi R24,<_VendorDeviceRequest
	ldi R25,>_VendorDeviceRequest
	add R30,R24
	adc R31,R25
	ldd R26,z+0
	ldd R27,z+1
	movw R30,R26
	xcall xicall
	xjmp L36
L35:
	.dbline 150
;   else stall_ep0();
	xcall _stall_ep0
L36:
L34:
	.dbline -2
L31:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r req 20 c
	.dbsym r type 22 c
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 153
; }
; void main(void)
; {
	.dbline 154
;   NOP();NOP();
	nop
	.dbline 154
	nop
	.dbline 155
;   NOP();NOP();
	nop
	.dbline 155
	nop
	.dbline 156
;   DISABLE;
	cli
	.dbline 157
;   init_port();
	xcall _init_port
	.dbline 158
;   init_serial();
	xcall _init_serial
	.dbline 160
;  // Format_Fat16Media();
;   D12_ReadInterruptRegister();
	xcall _D12_ReadInterruptRegister
	.dbline 161
;   D12_ReadLastTransactionStatus(0);
	clr R16
	xcall _D12_ReadLastTransactionStatus
	.dbline 162
;   D12_ReadLastTransactionStatus(1);
	ldi R16,1
	xcall _D12_ReadLastTransactionStatus
	.dbline 163
;   D12_ReadLastTransactionStatus(2);
	ldi R16,2
	xcall _D12_ReadLastTransactionStatus
	.dbline 164
;   D12_ReadLastTransactionStatus(3);
	ldi R16,3
	xcall _D12_ReadLastTransactionStatus
	.dbline 165
;   D12_ReadLastTransactionStatus(4);
	ldi R16,4
	xcall _D12_ReadLastTransactionStatus
	.dbline 166
;   D12_ReadLastTransactionStatus(5);
	ldi R16,5
	xcall _D12_ReadLastTransactionStatus
	.dbline 167
;   reconnect_USB();
	xcall _reconnect_USB
	.dbline 168
;   ENABLE;
	sei
	xjmp L39
L38:
	.dbline 170
;   while(TRUE)    
;   {
	.dbline 171
;      if(bEPPflags.bits.bus_reset)
	lds R24,_bEPPflags
	andi R24,1
	breq L41
	.dbline 172
;      {
	.dbline 173
;          DISABLE;
	cli
	.dbline 174
;          bEPPflags.bits.bus_reset=0;
	lds R24,_bEPPflags
	andi R24,254
	sts _bEPPflags,R24
	.dbline 175
;          ENABLE;
	sei
	.dbline 176
;      }
L41:
	.dbline 177
;      if(bEPPflags.bits.suspend)
	lds R24,_bEPPflags
	lsr R24
	andi R24,1
	breq L43
	.dbline 178
;      {
	.dbline 179
;         DISABLE;
	cli
	.dbline 180
;         bEPPflags.bits.suspend=0;
	lds R24,_bEPPflags
	andi R24,253
	sts _bEPPflags,R24
	.dbline 181
;         ENABLE;
	sei
	.dbline 182
;      }
L43:
	.dbline 183
;      if(bEPPflags.bits.setup_packet)
	lds R24,_bEPPflags
	lsr R24
	lsr R24
	andi R24,1
	breq L45
	.dbline 184
;      {
	.dbline 185
;         DISABLE;
	cli
	.dbline 186
;         bEPPflags.bits.setup_packet=0;
	lds R24,_bEPPflags
	andi R24,251
	sts _bEPPflags,R24
	.dbline 187
;         ENABLE;
	sei
	.dbline 188
;         control_handler();
	xcall _control_handler
	.dbline 189
;      }	
L45:
	.dbline 190
L39:
	.dbline 169
	xjmp L38
X0:
	.dbline -2
L37:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile J:\PDIUSBD12-Materials\富昌\优盘5.0\MAIN.C
_ControlData::
	.blkb 24
	.dbstruct 0 8 _device_request
	.dbfield 0 bmRequestType c
	.dbfield 1 bRequest c
	.dbfield 2 wValue s
	.dbfield 4 wIndex s
	.dbfield 6 wLength s
	.dbend
	.dbstruct 0 24 _control_xfer
	.dbfield 0 DeviceRequest S[_device_request]
	.dbfield 8 wLength s
	.dbfield 10 wCount s
	.dbfield 12 pData pc
	.dbfield 14 pCData pkc
	.dbfield 16 dataBuffer A[8:8]c
	.dbend
	.dbsym e ControlData _ControlData S[_control_xfer]
	.area func_lit
PL_set_interface:	.word `_set_interface
PL_get_interface:	.word `_get_interface
PL_set_configuration:	.word `_set_configuration
PL_get_configuration:	.word `_get_configuration
PL_get_descriptor:	.word `_get_descriptor
PL_set_address:	.word `_set_address
PL_set_feature:	.word `_set_feature
PL_reserved:	.word `_reserved
PL_clear_feature:	.word `_clear_feature
PL_get_status:	.word `_get_status

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -