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

📄 stm8s_flash.ls

📁 STM8-触摸例程
💻 LS
📖 第 1 页 / 共 3 页
字号:
   1                     ; C Compiler for STM8 (COSMIC Software)
   2                     ; Generator V4.2.8 - 03 Dec 2008
   3                     ; Optimizer V4.2.8 - 03 Dec 2008
  65                     ; 63 void FLASH_Unlock(FLASH_MemType_TypeDef MemType)
  65                     ; 64 {
  67                     	switch	.text
  68  0000               _FLASH_Unlock:
  72                     ; 66     assert_param(IS_MEMORY_TYPE_OK(MemType));
  74                     ; 69     if (MemType == FLASH_MEMTYPE_PROG)
  76  0000 4d            	tnz	a
  77  0001 2609          	jrne	L73
  78                     ; 71         FLASH->PUKR = FLASH_RASS_KEY1;
  80  0003 35565062      	mov	20578,#86
  81                     ; 72         FLASH->PUKR = FLASH_RASS_KEY2;
  83  0007 35ae5062      	mov	20578,#174
  86  000b 81            	ret	
  87  000c               L73:
  88                     ; 78         FLASH->DUKR = FLASH_RASS_KEY2; /* Warning: keys are reversed on data memory !!! */
  90  000c 35ae5064      	mov	20580,#174
  91                     ; 79         FLASH->DUKR = FLASH_RASS_KEY1;
  93  0010 35565064      	mov	20580,#86
  94                     ; 82 }
  97  0014 81            	ret	
 132                     ; 98 void FLASH_Lock(FLASH_MemType_TypeDef MemType)
 132                     ; 99 {
 133                     	switch	.text
 134  0015               _FLASH_Lock:
 138                     ; 101     assert_param(IS_MEMORY_TYPE_OK(MemType));
 140                     ; 104     if (MemType == FLASH_MEMTYPE_PROG)
 142  0015 4d            	tnz	a
 143  0016 2605          	jrne	L16
 144                     ; 106         FLASH->IAPSR = (u8)(~FLASH_IAPSR_PUL);
 146  0018 35fd505f      	mov	20575,#253
 149  001c 81            	ret	
 150  001d               L16:
 151                     ; 112         FLASH->IAPSR = (u8)(~FLASH_IAPSR_DUL);
 153  001d 35f7505f      	mov	20575,#247
 154                     ; 114 }
 157  0021 81            	ret	
 191                     ; 130 void FLASH_DeInit(void)
 191                     ; 131 {
 192                     	switch	.text
 193  0022               _FLASH_DeInit:
 195  0022 88            	push	a
 196       00000001      OFST:	set	1
 199                     ; 132     u8 temp = 0;
 201  0023 0f01          	clr	(OFST+0,sp)
 202                     ; 133     FLASH->CR1 = FLASH_CR1_RESET_VALUE;
 204  0025 725f505a      	clr	20570
 205                     ; 134     FLASH->CR2 = FLASH_CR2_RESET_VALUE;
 207  0029 725f505b      	clr	20571
 208                     ; 135     FLASH->NCR2 = FLASH_NCR2_RESET_VALUE;
 210  002d 35ff505c      	mov	20572,#255
 211                     ; 136     FLASH->IAPSR &= (u8)(~FLASH_IAPSR_DUL);
 213  0031 7217505f      	bres	20575,#3
 214                     ; 137     FLASH->IAPSR &= (u8)(~FLASH_IAPSR_PUL);
 216  0035 7213505f      	bres	20575,#1
 217                     ; 138     temp = FLASH->IAPSR; /* Reading of this register causes the clearing of status flags */
 219  0039 c6505f        	ld	a,20575
 220                     ; 139 }
 223  003c 84            	pop	a
 224  003d 81            	ret	
 279                     ; 154 void FLASH_ITConfig(FunctionalState NewState)
 279                     ; 155 {
 280                     	switch	.text
 281  003e               _FLASH_ITConfig:
 285                     ; 156     if (NewState != DISABLE)
 287  003e 4d            	tnz	a
 288  003f 2705          	jreq	L131
 289                     ; 158         FLASH->CR1 |= FLASH_CR1_IE; /* Enables the interrupt sources */
 291  0041 7212505a      	bset	20570,#1
 294  0045 81            	ret	
 295  0046               L131:
 296                     ; 162         FLASH->CR1 &= (u8)(~FLASH_CR1_IE); /* Disables the interrupt sources */
 298  0046 7213505a      	bres	20570,#1
 299                     ; 164 }
 302  004a 81            	ret	
 355                     ; 184 void FLASH_EraseBlock(u16 BlockNum, FLASH_MemType_TypeDef MemType)
 355                     ; 185 {
 356                     	switch	.text
 357  004b               _FLASH_EraseBlock:
 359  004b 89            	pushw	x
 360  004c 5204          	subw	sp,#4
 361       00000004      OFST:	set	4
 364                     ; 186     u32 StartAddress = 0;
 366  004e 5f            	clrw	x
 367  004f 1f03          	ldw	(OFST-1,sp),x
 368  0051 1f01          	ldw	(OFST-3,sp),x
 369                     ; 189     assert_param(IS_MEMORY_TYPE_OK(MemType));
 371                     ; 190     if (MemType == FLASH_MEMTYPE_PROG)
 373  0053 7b09          	ld	a,(OFST+5,sp)
 374  0055 2605          	jrne	L361
 375                     ; 192         assert_param(IS_FLASH_PROG_BLOCK_NUMBER_OK(BlockNum));
 377                     ; 193         StartAddress = FLASH_PROG_START_PHYSICAL_ADDRESS;
 379  0057 ae8000        	ldw	x,#32768
 381  005a 2003          	jra	L561
 382  005c               L361:
 383                     ; 197         assert_param(IS_FLASH_DATA_BLOCK_NUMBER_OK(BlockNum));
 385                     ; 198         StartAddress = FLASH_DATA_START_PHYSICAL_ADDRESS;
 387  005c ae4000        	ldw	x,#16384
 388  005f               L561:
 389  005f 1f03          	ldw	(OFST-1,sp),x
 390  0061 5f            	clrw	x
 391  0062 1f01          	ldw	(OFST-3,sp),x
 392                     ; 202     StartAddress = StartAddress + ((u32)BlockNum * FLASH_BLOCK_SIZE);
 394  0064 a680          	ld	a,#128
 395  0066 1e05          	ldw	x,(OFST+1,sp)
 396  0068 cd0000        	call	c_cmulx
 398  006b 96            	ldw	x,sp
 399  006c 5c            	incw	x
 400  006d cd0000        	call	c_lgadd
 402                     ; 205     FLASH->CR2 |= FLASH_CR2_ERASE;
 404  0070 721a505b      	bset	20571,#5
 405                     ; 206     FLASH->NCR2 &= (u8)(~FLASH_NCR2_NERASE);
 407  0074 721b505c      	bres	20572,#5
 408                     ; 209     *((@far u8*) StartAddress) = FLASH_CLEAR_BYTE;
 410  0078 7b02          	ld	a,(OFST-2,sp)
 411  007a b700          	ld	c_x,a
 412  007c 1e03          	ldw	x,(OFST-1,sp)
 413  007e bf01          	ldw	c_x+1,x
 414  0080 4f            	clr	a
 415  0081 92bd0000      	ldf	[c_x.e],a
 416                     ; 210     *((@far u8*) StartAddress + 1) = FLASH_CLEAR_BYTE;
 419  0085 90ae0001      	ldw	y,#1
 420  0089 93            	ldw	x,y
 421  008a 92a70000      	ldf	([c_x.e],x),a
 422                     ; 211     *((@far u8*) StartAddress + 2) = FLASH_CLEAR_BYTE;
 425  008e 905c          	incw	y
 426  0090 93            	ldw	x,y
 427  0091 92a70000      	ldf	([c_x.e],x),a
 428                     ; 212     *((@far u8*) StartAddress + 3) = FLASH_CLEAR_BYTE;
 431  0095 905c          	incw	y
 432  0097 93            	ldw	x,y
 433  0098 92a70000      	ldf	([c_x.e],x),a
 434                     ; 219 }
 438  009c 5b06          	addw	sp,#6
 439  009e 81            	ret	
 473                     ; 238 void FLASH_EraseByte(u32 Address)
 473                     ; 239 {
 474                     	switch	.text
 475  009f               _FLASH_EraseByte:
 477       00000000      OFST:	set	0
 480                     ; 241     assert_param(IS_FLASH_ADDRESS_OK(Address));
 482                     ; 244     *((@far u8*) Address) = FLASH_CLEAR_BYTE; /* Erase byte */
 484  009f 7b04          	ld	a,(OFST+4,sp)
 485  00a1 b700          	ld	c_x,a
 486  00a3 1e05          	ldw	x,(OFST+5,sp)
 487  00a5 bf01          	ldw	c_x+1,x
 488  00a7 4f            	clr	a
 489  00a8 92bd0000      	ldf	[c_x.e],a
 490                     ; 248 }
 494  00ac 81            	ret	
 530                     ; 267 void FLASH_EraseOptionByte(u32 Address)
 530                     ; 268 {
 531                     	switch	.text
 532  00ad               _FLASH_EraseOptionByte:
 534       00000000      OFST:	set	0
 537                     ; 270     assert_param(IS_OPTION_BYTE_ADDRESS_OK(Address));
 539                     ; 273     FLASH->CR2 |= FLASH_CR2_OPT;
 541  00ad 721e505b      	bset	20571,#7
 542                     ; 274     FLASH->NCR2 &= (u8)(~FLASH_NCR2_NOPT);
 544  00b1 721f505c      	bres	20572,#7
 545                     ; 278     *((@far u8*)Address) = FLASH_CLEAR_BYTE;
 547  00b5 7b04          	ld	a,(OFST+4,sp)
 548  00b7 b700          	ld	c_x,a
 549  00b9 1e05          	ldw	x,(OFST+5,sp)
 550  00bb bf01          	ldw	c_x+1,x
 551  00bd 4f            	clr	a
 552  00be 92bd0000      	ldf	[c_x.e],a
 553                     ; 279     *((@far u8*)(Address + 1 )) = FLASH_SET_BYTE;
 556  00c2 96            	ldw	x,sp
 557  00c3 1c0003        	addw	x,#OFST+3
 558  00c6 cd0000        	call	c_ltor
 560  00c9 4c            	inc	a
 561  00ca cd0000        	call	c_ladc
 563  00cd 450100        	mov	c_x,c_lreg+1
 564  00d0 be02          	ldw	x,c_lreg+2
 565  00d2 bf01          	ldw	c_x+1,x
 566  00d4 a6ff          	ld	a,#255
 567  00d6 92bd0000      	ldf	[c_x.e],a
 568                     ; 285     FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
 571  00da a601          	ld	a,#1
 572  00dc cd0294        	call	_FLASH_WaitForLastOperation
 574                     ; 288     FLASH->CR2 &= (u8)(~FLASH_CR2_OPT);
 576  00df 721f505b      	bres	20571,#7
 577                     ; 289     FLASH->NCR2 |= FLASH_NCR2_NOPT;
 579  00e3 721e505c      	bset	20572,#7
 580                     ; 290 }
 583  00e7 81            	ret	
 687                     ; 318 void FLASH_ProgramBlock(u16 BlockNum, FLASH_MemType_TypeDef MemType, FLASH_ProgramMode_TypeDef ProgMode, u8 *Buffer)
 687                     ; 319 {
 688                     	switch	.text
 689  00e8               _FLASH_ProgramBlock:
 691  00e8 89            	pushw	x
 692  00e9 5206          	subw	sp,#6
 693       00000006      OFST:	set	6
 696                     ; 320     u16 Count = 0;
 698                     ; 321     u32 StartAddress = 0;
 700  00eb 96            	ldw	x,sp
 701  00ec 5c            	incw	x
 702  00ed cd0000        	call	c_ltor
 704                     ; 324     assert_param(IS_MEMORY_TYPE_OK(MemType));
 706                     ; 325     assert_param(IS_FLASH_PROGRAM_MODE_OK(ProgMode));
 708                     ; 326     if (MemType == FLASH_MEMTYPE_PROG)
 710  00f0 7b0b          	ld	a,(OFST+5,sp)
 711  00f2 2605          	jrne	L572
 712                     ; 328         assert_param(IS_FLASH_PROG_BLOCK_NUMBER_OK(BlockNum));
 714                     ; 329         StartAddress = FLASH_PROG_START_PHYSICAL_ADDRESS;
 716  00f4 ae8000        	ldw	x,#32768
 718  00f7 2003          	jra	L772
 719  00f9               L572:
 720                     ; 333         assert_param(IS_FLASH_DATA_BLOCK_NUMBER_OK(BlockNum));

⌨️ 快捷键说明

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