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

📄 main.src

📁 USB IAP (In Application Programming) Demo for uPSD32
💻 SRC
📖 第 1 页 / 共 5 页
字号:
; #include "app_intr.h"
; 
; 
;                        /*========= Prototypes =========*/
; 
; extern uchar flash_write_with_poll(volatile uchar xdata *addr, uchar dat);
; extern uchar flash_boot_write_with_poll(volatile uchar xdata *addr, uchar dat);
; extern uchar flash_erase_sector(volatile uchar xdata* addr);
; extern uchar flash_boot_erase_sector(volatile uchar xdata* addr);
; extern void flash_reset();
; extern void flash_boot_reset();
; 
; extern void initXREG();
; 
; 
; //extern
; extern PSD_REGS UPSD_xreg;                   // UPSD registers (upsd_cfg.c)
; extern data uchar LCD_buffer[];              // LCD mirror buffer (lcd_32xx.c)
; 
; 
; 
; 
; 
; 
;                       /*=========== Globals ===========*/
; 
; // uncomment the following line to enable DisconnectOndemand feature
; //#define DisconnectOnDemand
; 
; /*
;   Enable this DisconnectOnDemand define in case of usage of Disconnect-on-demand
;   feature ONLY. Be sure that all hardware modifications are present !!!
; */
; 
; unsigned char DDCCONintc = 0;
; 
; 
; 
; data int counter;                       // Incremented in do_timer0 (timer_func.c)
; 
; MCU_CMD status;                              // Status from last command executed
; data uchar   returnStatus;   // Set TRUE if we should return status record to host
; MCU_CMD currentCmd;                          // Current command we're working on
; MCU_CMD rcvReport;                           // Incoming report
; data uchar   rcvIndex;                 // Current byte position in incoming report
; MCU_CMD txReport;                            // Outgoing report
; data uchar   txIndex;
;                // Current byte position in outgoing report, but be a byte only !!!
; 
; 
; xdata char AuxTXBuf[8];                     //Aux. buffer for TXing of LCD content
; data uchar LCDBufTXIndex;              //current position of LCD buffer for USB TX
; 
; 
; data unsigned int  g_debugUSB_INT_CNT = 0;
; data unsigned char g_debugTimer2_INT_CNT = 0;
; 
; 
; 
; 
; 
; 
; 
; 
; void initXREG(void)

	RSEG  ?PR?initXREG?MAIN
initXREG:
			; SOURCE LINE # 209
; /******************************************************************************
;  Function   : void initXREG()
;  Parameters : (void)
;  Description: Init of uPSD's xregs
;  ******************************************************************************/
;  {
			; SOURCE LINE # 215
; 
; /************ VM ************/
;   UPSD_xreg.VM |= 0x80;
			; SOURCE LINE # 218
	MOV  	DPTR,#UPSD_xreg+0E2H
	MOVX 	A,@DPTR
	ORL  	A,#080H
	MOVX 	@DPTR,A
;                                              // bit 7 - PIO (1=enable)
;                                              // bit 4 - RD access FLASH (1=enable)
;                                             // bit 3 - RD access EEPROM (1=enable)
;                                            // bit 2 - PSEN access FLASH (1=enable)
;                                           // bit 1 - PSEN access EEPROM (1=enable)
;                                             // bit 0 - PSEN access SRAM (1=enable)
; 
; 
; /****** power management ******/
;   UPSD_xreg.PMMR0=0x38;                      // power-on default = 0x00
			; SOURCE LINE # 228
	MOV  	DPTR,#UPSD_xreg+0B0H
	MOV  	A,#038H
	MOVX 	@DPTR,A
;                                            // bit 5 - CLKIN input to MCell (1=off)
;                                        // bit 4 - CLKIN input to PLD array (1=off)
;                                  // bit 3 - PLD turbo mode (ZPSD only) (1=disable)
;                                              // bit 1 - APD unit (1=enable)
; 
;   UPSD_xreg.PMMR2=0x70;                      // power-on default = 0x00
			; SOURCE LINE # 234
	MOV  	DPTR,#UPSD_xreg+0B4H
	MOV  	A,#070H
	MOVX 	@DPTR,A
;                                          // bit 6 - DBE input to PLD array (1=off)
;                                          // bit 5 - ALE input to PLD array (1=off)
;                                        // bit 4 - CNTL2 input to PLD array (1=off)
;                                        // bit 3 - CNTL1 input to PLD array (1=off)
;                                        // bit 2 - CNTL0 input to PLD array (1=off)
;  }
			; SOURCE LINE # 240
	RET  	
; END OF initXREG

; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; #ifdef DisconnectOnDemand
; 
; static void ReConnectUSB()
; /******************************************************************************
;  Function   : static void ReConnectUSB()
;  Parameters : none
;  Description: Use insted of UsbInitialize when DisconnectOnDemand feature
;               is implemented.
;               Be sure that the DisconnectOnDemand feature is present on DK3200.
;  ******************************************************************************/
;  {
;   data int w;
; 
;   UIEN = 0;                                  // Disable all USB interrupts
;   UADR = 0;                                  // Disable USB hardware
; 
;   LCDBufTXIndex = 0;                         // LCD disp position for USB
; 
;   UPSD_xreg.DATAOUT_C &= 0xEF;               // PC4=0
;   UPSD_xreg.DRIVE_C |= 0x10;                 // set as OpenDrain
;   UPSD_xreg.DIRECTION_C |= 0x10;             // set as output
; 
;   printfLCD("\rUSB Disconnected");
; 
;   while ((UPSD_xreg.DATAIN_B & 0x04)==0)
;    {
;     for (w=0;w<600*50;w++);                  // wait 50 ms
;    }
; 
;   UPSD_xreg.DRIVE_C &= 0xEF;                 // set PC4 as input
;   UPSD_xreg.DIRECTION_C &= 0xEF;             // set PC4 as input
; 
;   UsbInitialize();
;   printfLCD("\rUSB Reconnected.");
;  }
; 
; #endif
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; static void WriteBufferToFlash(uchar flash, uint16 address, uchar* buf, uint16 cb)

	RSEG  ?PR?_WriteBufferToFlash?MAIN
_WriteBufferToFlash:
	USING	0
			; SOURCE LINE # 306
	MOV  	DPTR,#flash?140
	MOV  	A,R7
	MOVX 	@DPTR,A
	MOV  	DPTR,#buf?142
	MOV  	A,R3
	MOVX 	@DPTR,A
	INC  	DPTR
	MOV  	A,R2
	MOVX 	@DPTR,A
	INC  	DPTR
	MOV  	A,R1
	MOVX 	@DPTR,A
;---- Variable 'address?141' assigned to Register 'R4/R5' ----
; /******************************************************************************
;  Function   : static void WriteBufferToFlash()
;  Parameters : (uchar flash, uint16 address, uchar* buf, uint16 cb)
;  Description: WriteBufferToFlash()
;  ******************************************************************************/
;  {
			; SOURCE LINE # 312
;             // Assume desired flash segment is mapped into high 32k of xdata space
;   volatile uchar xdata* p = (volatile uchar xdata*) address;
			; SOURCE LINE # 314
	XCH  	A,R7
	MOV  	A,R5
	XCH  	A,R7
	MOV  	DPTR,#p?144
	MOV  	A,R4
	MOVX 	@DPTR,A
	INC  	DPTR
	MOV  	A,R7
	MOVX 	@DPTR,A
; 
;   if (flash == PRIMARY_FLASH)
			; SOURCE LINE # 316
	MOV  	DPTR,#flash?140
	MOVX 	A,@DPTR
	JNZ  	?C0006
;    {
			; SOURCE LINE # 317
?C0003:
;     while (cb--)
			; SOURCE LINE # 318
	MOV  	DPTR,#cb?143
	MOV  	A,#0FFH
	MOV  	B,A
	LCALL	?C?ILDIX
	ORL  	A,B
	JNZ  	$ + 5H
	LJMP 	?C0008
;      {
			; SOURCE LINE # 319
;       flash_write_with_poll(p, *buf++);
			; SOURCE LINE # 320
	MOV  	DPTR,#p?144
	MOVX 	A,@DPTR
	MOV  	R6,A
	INC  	DPTR
	MOVX 	A,@DPTR
	MOV  	R7,A
	MOV  	DPTR,#buf?142
	MOVX 	A,@DPTR
	MOV  	R3,A
	INC  	DPTR
	CLR  	A
	MOV  	B,#01H
	LCALL	?C?ILDIX
	MOV  	R1,B
	MOV  	R2,A
	LCALL	?C?CLDPTR
	MOV  	R5,A
	LCALL	_flash_write_with_poll
;       status.u.status.checkSum += *p++;
			; SOURCE LINE # 321
	MOV  	DPTR,#p?144
	CLR  	A
	MOV  	B,#01H
	LCALL	?C?ILDIX
	MOV  	DPL,B
	MOV  	DPH,A
	MOVX 	A,@DPTR
	MOV  	R7,A
	MOV  	DPTR,#status+05H
	MOVX 	A,@DPTR
	ADD  	A,R7
	MOVX 	@DPTR,A
;      }
			; SOURCE LINE # 322
	SJMP 	?C0003
;    }
			; SOURCE LINE # 323
;   else
;    {
			; SOURCE LINE # 325
?C0006:
;     while (cb--)
			; SOURCE LINE # 326
	MOV  	DPTR,#cb?143
	MOV  	A,#0FFH
	MOV  	B,A
	LCALL	?C?ILDIX
	ORL  	A,B
	JZ   	?C0008
;      {
			; SOURCE LINE # 327
;       flash_boot_write_with_poll(p, *buf++);
			; SOURCE LINE # 328
	MOV  	DPTR,#p?144
	MOVX 	A,@DPTR
	MOV  	R6,A
	INC  	DPTR
	MOVX 	A,@DPTR
	MOV  	R7,A
	MOV  	DPTR,#buf?142
	MOVX 	A,@DPTR
	MOV  	R3,A
	INC  	DPTR
	CLR  	A
	MOV  	B,#01H
	LCALL	?C?ILDIX
	MOV  	R1,B
	MOV  	R2,A
	LCALL	?C?CLDPTR
	MOV  	R5,A
	LCALL	_flash_boot_write_with_poll
;       status.u.status.checkSum += *p++;
			; SOURCE LINE # 329
	MOV  	DPTR,#p?144
	CLR  	A
	MOV  	B,#01H
	LCALL	?C?ILDIX
	MOV  	DPL,B
	MOV  	DPH,A
	MOVX 	A,@DPTR
	MOV  	R7,A
	MOV  	DPTR,#status+05H
	MOVX 	A,@DPTR
	ADD  	A,R7
	MOVX 	@DPTR,A
;      }
			; SOURCE LINE # 330
	SJMP 	?C0006
;    }
			; SOURCE LINE # 331
;  }
			; SOURCE LINE # 332
?C0008:
	RET  	
; END OF _WriteBufferToFlash

; 
; 
; 
; 
; static void ReadBufferFromFlash(uint16 address, uchar* buf, uint16 cb)

	RSEG  ?PR?_ReadBufferFromFlash?MAIN
_ReadBufferFromFlash:
	USING	0
			; SOURCE LINE # 337
	MOV  	DPTR,#buf?246
	MOV  	A,R3
	MOVX 	@DPTR,A
	INC  	DPTR
	MOV  	A,R2
	MOVX 	@DPTR,A
	INC  	DPTR
	MOV  	A,R1
	MOVX 	@DPTR,A
;---- Variable 'address?245' assigned to Register 'R6/R7' ----
; /******************************************************************************
;  Function   : static void ReadBufferFromFlash()
;  Parameters : (uint16 address, uchar* buf, uint16 cb)
;  Description: ReadBufferFromFlash()
;  ******************************************************************************/
;  {
			; SOURCE LINE # 343
;             // Assume desired flash segment is mapped into high 32k of xdata space
;   volatile uchar xdata* p = (volatile uchar xdata*) address;
			; SOURCE LINE # 345
;---- Variable 'p?248' assigned to Register 'R6/R7' ----
?C0009:
; 
;   while (cb--)
			; SOURCE LINE # 347
	MOV  	DPTR,#cb?247
	MOV  	A,#0FFH
	MOV  	B,A
	LCALL	?C?ILDIX
	ORL  	A,B
	JZ   	?C0011
;    {
			; SOURCE LINE # 348
;     *buf++ = *p++;
			; SOURCE LINE # 349
	INC  	R7
	MOV  	A,R7
	XCH  	A,R4
	MOV  	A,R6
	XCH  	A,R4
	JNZ  	?C0108
	INC  	R6
?C0108:
	DEC  	A
	MOV  	DPL,A
	MOV  	DPH,R4
	MOVX 	A,@DPTR
	MOV  	R5,A
	MOV  	DPTR,#buf?246
	MOVX 	A,@DPTR
	MOV  	R3,A
	INC  	DPTR
	CLR  	A
	MOV  	B,#01H
	LCALL	?C?ILDIX
	MOV  	R1,B
	MOV  	R2,A
	MOV  	A,R5
	LCALL	?C?CSTPTR
;    }
			; SOURCE LINE # 350
	SJMP 	?C0009
;  }
			; SOURCE LINE # 351
?C0011:
	RET  	
; END OF _ReadBufferFromFlash

; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; void OnDeviceConfigured()

	RSEG  ?PR?OnDeviceConfigured?MAIN
OnDeviceConfigured:
			; SOURCE LINE # 365
; /******************************************************************************
;  Function   : void OnDeviceConfigured()
;  Parameters : none
;  Description: Called after device is completely configured.
;  ******************************************************************************/
;  {
			; SOURCE LINE # 371
;   TXD1F = 1;                                 // Set up first tx on EP1 if not
			; SOURCE LINE # 372
	SETB 	TXD1F
;  }
			; SOURCE LINE # 373
	RET  	
; END OF OnDeviceConfigured

; 
; 
; 
; 
; 
; 
; 
; 
; static void PrepareTransmitSegment(uchar index)

	RSEG  ?PR?_PrepareTransmitSegment?MAIN
_PrepareTransmitSegment:
	USING	0
			; SOURCE LINE # 382
	MOV  	DPTR,#index?449
	MOV  	A,R7
	MOVX 	@DPTR,A
; /******************************************************************************
;  Function   : static void PrepareTransmitSegment()
;  Parameters : (uchar index) -  current byte index into txReport.
;  Description: Prepare next segment of feature report for transmission.
;  ******************************************************************************/
;  {
			; SOURCE LINE # 388
;   data uchar cbData;
;   data uchar i;
; 
;   if (returnStatus)
			; SOURCE LINE # 392
	MOV  	A,returnStatus
	JZ   	?C0013
;    {
			; SOURCE LINE # 393
;     if (index == 0)               // Prepare the whole status report on first call
			; SOURCE LINE # 394
	MOVX 	A,@DPTR
	JZ   	$ + 5H
	LJMP 	?C0015
;      {
			; SOURCE LINE # 395
;       status.u.cmd               = CMD_STATUS;
			; SOURCE LINE # 396
	MOV  	DPTR,#status
	MOV  	A,#05H
	MOVX 	@DPTR,A
;       status.u.status.currentCmd = currentCmd.u.cmd;
			; SOURCE LINE # 397
	MOV  	DPTR,#currentCmd
	MOVX 	A,@DPTR
	MOV  	DPTR,#status+01H
	MOVX 	@DPTR,A
;       status.u.status.page       = UPSD_xreg.PAGE;
			; SOURCE LINE # 398
	MOV  	DPTR,#UPSD_xreg+0E0H
	MOVX 	A,@DPTR
	MOV  	DPTR,#status+02H
	MOVX 	@DPTR,A
;       status.u.status.vm         = UPSD_xreg.VM;
			; SOURCE LINE # 399
	MOV  	DPTR,#UPSD_xreg+0E2H
	MOVX 	A,@DPTR
	MOV  	DPTR,#status+03H
	MOVX 	@DPTR,A
;       memcpy(&txReport, &status, CMD_SIZE);
			; SOURCE LINE # 400
	MOV  	R0,#LOW (txReport)
	MOV  	R4,#HIGH (txReport)
	MOV  	R5,#01H
	MOV  	R3,#01H
	MOV  	R2,#HIGH (status)
	MOV  	R1,#LOW (status)
	MOV  	R6,#00H
	MOV  	R7,#040H
	LJMP 	?C?COPY
;      }
			; SOURCE LINE # 401
;     return;
;    }
			; SOURCE LINE # 403
?C0013:
; 
; 
;   /*= The Read command is executed very fast, it can be present at this place.
;                    If you use some time-consuming operations
;              or your routine takes more than 450us, place your code
;             instead of CMD_ERASE, where can be long services ... =*/
; 
;   switch (currentCmd.u.cmd)
			; SOURCE LINE # 411
	MOV  	DPTR,#currentCmd
	MOVX 	A,@DPTR
	ADD  	A,#0FCH
	JZ   	$ + 5H
	LJMP 	?C0025

⌨️ 快捷键说明

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