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

📄 stm8s_flash.ls

📁 STM8全部资料
💻 LS
📖 第 1 页 / 共 3 页
字号:
 721  0119 1f03          	ldw	(OFST-3,sp),x
 722  011b ae0000        	ldw	x,#0
 723  011e 1f01          	ldw	(OFST-5,sp),x
 725  0120 200a          	jra	L752
 726  0122               L552:
 727                     ; 333         assert_param(IS_FLASH_DATA_BLOCK_NUMBER_OK(BlockNum));
 729                     ; 334         StartAddress = FLASH_DATA_START_PHYSICAL_ADDRESS;
 731  0122 ae4000        	ldw	x,#16384
 732  0125 1f03          	ldw	(OFST-3,sp),x
 733  0127 ae0000        	ldw	x,#0
 734  012a 1f01          	ldw	(OFST-5,sp),x
 735  012c               L752:
 736                     ; 338     StartAddress = StartAddress + ((u32)BlockNum * FLASH_BLOCK_SIZE);
 738  012c 1e07          	ldw	x,(OFST+1,sp)
 739  012e a680          	ld	a,#128
 740  0130 cd0000        	call	c_cmulx
 742  0133 96            	ldw	x,sp
 743  0134 1c0001        	addw	x,#OFST-5
 744  0137 cd0000        	call	c_lgadd
 746                     ; 341     if (ProgMode == FLASH_PROGRAMMODE_STANDARD)
 748  013a 0d0c          	tnz	(OFST+6,sp)
 749  013c 260a          	jrne	L162
 750                     ; 344         FLASH->CR2 |= FLASH_CR2_PRG;
 752  013e 7210505b      	bset	20571,#0
 753                     ; 345         FLASH->NCR2 &= (u8)(~FLASH_NCR2_NPRG);
 755  0142 7211505c      	bres	20572,#0
 757  0146 2008          	jra	L362
 758  0148               L162:
 759                     ; 350         FLASH->CR2 |= FLASH_CR2_FPRG;
 761  0148 7218505b      	bset	20571,#4
 762                     ; 351         FLASH->NCR2 &= (u8)(~FLASH_NCR2_NFPRG);
 764  014c 7219505c      	bres	20572,#4
 765  0150               L362:
 766                     ; 355     for (Count = 0; Count < FLASH_BLOCK_SIZE; Count++)
 768  0150 5f            	clrw	x
 769  0151 1f05          	ldw	(OFST-1,sp),x
 770  0153               L562:
 771                     ; 357         *((u8*)StartAddress + Count) = ((u8)(Buffer[Count]));
 773  0153 1e0d          	ldw	x,(OFST+7,sp)
 774  0155 72fb05        	addw	x,(OFST-1,sp)
 775  0158 f6            	ld	a,(x)
 776  0159 1e03          	ldw	x,(OFST-3,sp)
 777  015b 72fb05        	addw	x,(OFST-1,sp)
 778  015e f7            	ld	(x),a
 779                     ; 355     for (Count = 0; Count < FLASH_BLOCK_SIZE; Count++)
 781  015f 1e05          	ldw	x,(OFST-1,sp)
 782  0161 1c0001        	addw	x,#1
 783  0164 1f05          	ldw	(OFST-1,sp),x
 786  0166 1e05          	ldw	x,(OFST-1,sp)
 787  0168 a30080        	cpw	x,#128
 788  016b 25e6          	jrult	L562
 789                     ; 359 }
 792  016d 5b08          	addw	sp,#8
 793  016f 81            	ret
 832                     ; 381 void FLASH_ProgramByte(u32 Address, u8 Data)
 832                     ; 382 {
 833                     	switch	.text
 834  0170               _FLASH_ProgramByte:
 836       00000000      OFST:	set	0
 839                     ; 384     assert_param(IS_FLASH_ADDRESS_OK(Address));
 841                     ; 387     *((@far u8*) Address) = Data;
 843  0170 7b07          	ld	a,(OFST+7,sp)
 844  0172 88            	push	a
 845  0173 7b05          	ld	a,(OFST+5,sp)
 846  0175 b700          	ld	c_x,a
 847  0177 1e06          	ldw	x,(OFST+6,sp)
 848  0179 84            	pop	a
 849  017a bf01          	ldw	c_x+1,x
 850  017c 92bd0000      	ldf	[c_x.e],a
 851                     ; 391 }
 854  0180 81            	ret
 895                     ; 411 void FLASH_ProgramOptionByte(u32 Address, u8 Data)
 895                     ; 412 {
 896                     	switch	.text
 897  0181               _FLASH_ProgramOptionByte:
 899       00000000      OFST:	set	0
 902                     ; 414     assert_param(IS_OPTION_BYTE_ADDRESS_OK(Address));
 904                     ; 417     FLASH->CR2 |= FLASH_CR2_OPT;
 906  0181 721e505b      	bset	20571,#7
 907                     ; 418     FLASH->NCR2 &= (u8)(~FLASH_NCR2_NOPT);
 909  0185 721f505c      	bres	20572,#7
 910                     ; 422     *((@far u8*)Address) = Data;
 912  0189 7b07          	ld	a,(OFST+7,sp)
 913  018b 88            	push	a
 914  018c 7b05          	ld	a,(OFST+5,sp)
 915  018e b700          	ld	c_x,a
 916  0190 1e06          	ldw	x,(OFST+6,sp)
 917  0192 84            	pop	a
 918  0193 bf01          	ldw	c_x+1,x
 919  0195 92bd0000      	ldf	[c_x.e],a
 920                     ; 423     *((@far u8*)(Address + 1)) = (u8)(~Data);
 922  0199 96            	ldw	x,sp
 923  019a 1c0003        	addw	x,#OFST+3
 924  019d cd0000        	call	c_ltor
 926  01a0 a601          	ld	a,#1
 927  01a2 cd0000        	call	c_ladc
 929  01a5 450100        	mov	c_x,c_lreg+1
 930  01a8 be02          	ldw	x,c_lreg+2
 931  01aa 7b07          	ld	a,(OFST+7,sp)
 932  01ac 43            	cpl	a
 933  01ad bf01          	ldw	c_x+1,x
 934  01af 92bd0000      	ldf	[c_x.e],a
 935                     ; 429     FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
 937  01b3 a601          	ld	a,#1
 938  01b5 cd02eb        	call	_FLASH_WaitForLastOperation
 940                     ; 432     FLASH->CR2 &= (u8)(~FLASH_CR2_OPT);
 942  01b8 721f505b      	bres	20571,#7
 943                     ; 433     FLASH->NCR2 |= FLASH_NCR2_NOPT;
 945  01bc 721e505c      	bset	20572,#7
 946                     ; 434 }
 949  01c0 81            	ret
 988                     ; 456 void FLASH_ProgramWord(u32 Address, u32 Data)
 988                     ; 457 {
 989                     	switch	.text
 990  01c1               _FLASH_ProgramWord:
 992       00000000      OFST:	set	0
 995                     ; 459     assert_param(IS_FLASH_ADDRESS_OK(Address));
 997                     ; 462     FLASH->CR2 |= FLASH_CR2_WPRG;
 999  01c1 721c505b      	bset	20571,#6
1000                     ; 463     FLASH->NCR2 &= (u8)(~FLASH_NCR2_NWPRG);
1002  01c5 721d505c      	bres	20572,#6
1003                     ; 466     *((@far u8*)Address) = BYTE_0(Data); /* Write one byte */
1005  01c9 7b0a          	ld	a,(OFST+10,sp)
1006  01cb a4ff          	and	a,#255
1007  01cd 88            	push	a
1008  01ce 7b05          	ld	a,(OFST+5,sp)
1009  01d0 b700          	ld	c_x,a
1010  01d2 1e06          	ldw	x,(OFST+6,sp)
1011  01d4 84            	pop	a
1012  01d5 bf01          	ldw	c_x+1,x
1013  01d7 92bd0000      	ldf	[c_x.e],a
1014                     ; 467     *(((@far u8*)Address) + 1) = BYTE_1(Data); /* Write one byte */
1016  01db 7b09          	ld	a,(OFST+9,sp)
1017  01dd a4ff          	and	a,#255
1018  01df 88            	push	a
1019  01e0 7b05          	ld	a,(OFST+5,sp)
1020  01e2 b700          	ld	c_x,a
1021  01e4 1e06          	ldw	x,(OFST+6,sp)
1022  01e6 84            	pop	a
1023  01e7 90ae0001      	ldw	y,#1
1024  01eb bf01          	ldw	c_x+1,x
1025  01ed 93            	ldw	x,y
1026  01ee 92a70000      	ldf	([c_x.e],x),a
1027                     ; 468     *(((@far u8*)Address) + 2) = BYTE_2(Data); /* Write one byte */
1029  01f2 7b08          	ld	a,(OFST+8,sp)
1030  01f4 a4ff          	and	a,#255
1031  01f6 88            	push	a
1032  01f7 7b05          	ld	a,(OFST+5,sp)
1033  01f9 b700          	ld	c_x,a
1034  01fb 1e06          	ldw	x,(OFST+6,sp)
1035  01fd 84            	pop	a
1036  01fe 90ae0002      	ldw	y,#2
1037  0202 bf01          	ldw	c_x+1,x
1038  0204 93            	ldw	x,y
1039  0205 92a70000      	ldf	([c_x.e],x),a
1040                     ; 469     *(((@far u8*)Address) + 3) = BYTE_3(Data); /* Write one byte */
1042  0209 7b07          	ld	a,(OFST+7,sp)
1043  020b 88            	push	a
1044  020c 7b05          	ld	a,(OFST+5,sp)
1045  020e b700          	ld	c_x,a
1046  0210 1e06          	ldw	x,(OFST+6,sp)
1047  0212 84            	pop	a
1048  0213 90ae0003      	ldw	y,#3
1049  0217 bf01          	ldw	c_x+1,x
1050  0219 93            	ldw	x,y
1051  021a 92a70000      	ldf	([c_x.e],x),a
1052                     ; 476 }
1055  021e 81            	ret
1087                     ; 492 u8 FLASH_ReadByte(u32 Address)
1087                     ; 493 {
1088                     	switch	.text
1089  021f               _FLASH_ReadByte:
1091       00000000      OFST:	set	0
1094                     ; 495     assert_param(IS_FLASH_ADDRESS_OK(Address));
1096                     ; 498     return(*((@far u8*) Address)); /* Read byte */
1098  021f 7b04          	ld	a,(OFST+4,sp)
1099  0221 b700          	ld	c_x,a
1100  0223 1e05          	ldw	x,(OFST+5,sp)
1101  0225 bf01          	ldw	c_x+1,x
1102  0227 92bc0000      	ldf	a,[c_x.e]
1105  022b 81            	ret
1160                     ; 518 u16 FLASH_ReadOptionByte(u32 Address)
1160                     ; 519 {
1161                     	switch	.text
1162  022c               _FLASH_ReadOptionByte:
1164  022c 5204          	subw	sp,#4
1165       00000004      OFST:	set	4
1168                     ; 520     u8 value_optbyte, value_optbyte_complement = 0;
1170                     ; 521     u16 res_value = 0;
1172                     ; 524     assert_param(IS_OPTION_BYTE_ADDRESS_OK(Address));
1174                     ; 527     value_optbyte = *((@far u8*)Address); /* Read option byte */
1176  022e 7b08          	ld	a,(OFST+4,sp)
1177  0230 b700          	ld	c_x,a
1178  0232 1e09          	ldw	x,(OFST+5,sp)
1179  0234 bf01          	ldw	c_x+1,x
1180  0236 92bc0000      	ldf	a,[c_x.e]
1181  023a 6b01          	ld	(OFST-3,sp),a
1182                     ; 528     value_optbyte_complement = *(((@far u8*)Address) + 1); /* Read option byte complement*/
1184  023c 7b08          	ld	a,(OFST+4,sp)
1185  023e b700          	ld	c_x,a
1186  0240 1e09          	ldw	x,(OFST+5,sp)
1187  0242 90ae0001      	ldw	y,#1
1188  0246 bf01          	ldw	c_x+1,x
1189  0248 93            	ldw	x,y
1190  0249 92af0000      	ldf	a,([c_x.e],x)
1191  024d 6b02          	ld	(OFST-2,sp),a
1192                     ; 534     if (value_optbyte == (u8)(~value_optbyte_complement))
1194  024f 7b02          	ld	a,(OFST-2,sp)
1195  0251 43            	cpl	a
1196  0252 1101          	cp	a,(OFST-3,sp)
1197  0254 2617          	jrne	L304
1198                     ; 536         res_value = (u16)((u16)value_optbyte << 8);
1200  0256 7b01          	ld	a,(OFST-3,sp)
1201  0258 5f            	clrw	x
1202  0259 97            	ld	xl,a
1203  025a 4f            	clr	a
1204  025b 02            	rlwa	x,a
1205  025c 1f03          	ldw	(OFST-1,sp),x
1206                     ; 537         res_value = res_value | (u16)value_optbyte_complement;
1208  025e 7b02          	ld	a,(OFST-2,sp)
1209  0260 5f            	clrw	x
1210  0261 97            	ld	xl,a
1211  0262 01            	rrwa	x,a

⌨️ 快捷键说明

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