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

📄 stm8s_flash.ls

📁 STM8s
💻 LS
📖 第 1 页 / 共 3 页
字号:
1576                     ; 457 void FLASH_EraseBlock(u16 BlockNum, FLASH_MemType_TypeDef MemType)
1576                     ; 458 {
1577                     	switch	.text
1578  01fd               _FLASH_EraseBlock:
1580  01fd 89            	pushw	x
1581  01fe 5206          	subw	sp,#6
1582       00000006      OFST:	set	6
1585                     ; 459     u16 timeout = OPERATION_TIMEOUT;
1587  0200 ae1000        	ldw	x,#4096
1588  0203 1f01          	ldw	(OFST-5,sp),x
1589                     ; 461     u32 StartAddress = 0;
1591                     ; 468     assert_param(IS_MEMORY_TYPE_OK(MemType));
1593                     ; 469     if (MemType == FLASH_MEMTYPE_PROG)
1595  0205 0d0b          	tnz	(OFST+5,sp)
1596  0207 260c          	jrne	L156
1597                     ; 471         assert_param(IS_FLASH_PROG_BLOCK_NUMBER_OK(BlockNum));
1599                     ; 472         StartAddress = FLASH_PROG_START_PHYSICAL_ADDRESS;
1601  0209 ae8000        	ldw	x,#32768
1602  020c 1f05          	ldw	(OFST-1,sp),x
1603  020e ae0000        	ldw	x,#0
1604  0211 1f03          	ldw	(OFST-3,sp),x
1606  0213 200a          	jra	L356
1607  0215               L156:
1608                     ; 476         assert_param(IS_FLASH_DATA_BLOCK_NUMBER_OK(BlockNum));
1610                     ; 477         StartAddress = FLASH_DATA_START_PHYSICAL_ADDRESS;
1612  0215 ae4000        	ldw	x,#16384
1613  0218 1f05          	ldw	(OFST-1,sp),x
1614  021a ae0000        	ldw	x,#0
1615  021d 1f03          	ldw	(OFST-3,sp),x
1616  021f               L356:
1617                     ; 481     StartAddress = StartAddress + ((u32)BlockNum * FLASH_BLOCK_SIZE);
1619  021f 1e07          	ldw	x,(OFST+1,sp)
1620  0221 a680          	ld	a,#128
1621  0223 cd0000        	call	c_cmulx
1623  0226 96            	ldw	x,sp
1624  0227 1c0003        	addw	x,#OFST-3
1625  022a cd0000        	call	c_lgadd
1627                     ; 484     FLASH->CR2 |= FLASH_CR2_ERASE;
1629  022d 721a505b      	bset	20571,#5
1630                     ; 485     FLASH->NCR2 &= (u8)(~FLASH_NCR2_NERASE);
1632  0231 721b505c      	bres	20572,#5
1633                     ; 487     *((PointerAttr u8*) StartAddress) = FLASH_CLEAR_BYTE;
1635  0235 7b04          	ld	a,(OFST-2,sp)
1636  0237 b700          	ld	c_x,a
1637  0239 1e05          	ldw	x,(OFST-1,sp)
1638  023b bf01          	ldw	c_x+1,x
1639  023d 4f            	clr	a
1640  023e 92bd0000      	ldf	[c_x.e],a
1641                     ; 488     *((PointerAttr u8*) StartAddress + 1) = FLASH_CLEAR_BYTE;
1644  0242 7b04          	ld	a,(OFST-2,sp)
1645  0244 b700          	ld	c_x,a
1646  0246 1e05          	ldw	x,(OFST-1,sp)
1647  0248 90ae0001      	ldw	y,#1
1648  024c bf01          	ldw	c_x+1,x
1649  024e 93            	ldw	x,y
1650  024f 4f            	clr	a
1651  0250 92a70000      	ldf	([c_x.e],x),a
1652                     ; 489     *((PointerAttr u8*) StartAddress + 2) = FLASH_CLEAR_BYTE;
1655  0254 7b04          	ld	a,(OFST-2,sp)
1656  0256 b700          	ld	c_x,a
1657  0258 1e05          	ldw	x,(OFST-1,sp)
1658  025a 90ae0002      	ldw	y,#2
1659  025e bf01          	ldw	c_x+1,x
1660  0260 93            	ldw	x,y
1661  0261 4f            	clr	a
1662  0262 92a70000      	ldf	([c_x.e],x),a
1663                     ; 490     *((PointerAttr u8*) StartAddress + 3) = FLASH_CLEAR_BYTE;
1666  0266 7b04          	ld	a,(OFST-2,sp)
1667  0268 b700          	ld	c_x,a
1668  026a 1e05          	ldw	x,(OFST-1,sp)
1669  026c 90ae0003      	ldw	y,#3
1670  0270 bf01          	ldw	c_x+1,x
1671  0272 93            	ldw	x,y
1672  0273 4f            	clr	a
1673  0274 92a70000      	ldf	([c_x.e],x),a
1676  0278 2007          	jra	L756
1677  027a               L556:
1678                     ; 507         timeout--;
1680  027a 1e01          	ldw	x,(OFST-5,sp)
1681  027c 1d0001        	subw	x,#1
1682  027f 1f01          	ldw	(OFST-5,sp),x
1683  0281               L756:
1684                     ; 505     while ((FLASH->IAPSR & FLASH_IAPSR_HVOFF) != 0x00 || (timeout == 0x00))
1686  0281 c6505f        	ld	a,20575
1687  0284 a540          	bcp	a,#64
1688  0286 26f2          	jrne	L556
1690  0288 1e01          	ldw	x,(OFST-5,sp)
1691  028a 27ee          	jreq	L556
1692                     ; 510 }
1695  028c 5b08          	addw	sp,#8
1696  028e 81            	ret
1809                     ; 525 void FLASH_ProgramBlock(u16 BlockNum, FLASH_MemType_TypeDef MemType, FLASH_ProgramMode_TypeDef ProgMode, u8 *Buffer)
1809                     ; 526 {
1810                     	switch	.text
1811  028f               _FLASH_ProgramBlock:
1813  028f 89            	pushw	x
1814  0290 5208          	subw	sp,#8
1815       00000008      OFST:	set	8
1818                     ; 527     u16 Count = 0;
1820                     ; 528     u32 StartAddress = 0;
1822                     ; 529     u16 timeout = OPERATION_TIMEOUT;
1824  0292 ae1000        	ldw	x,#4096
1825  0295 1f01          	ldw	(OFST-7,sp),x
1826                     ; 531     assert_param(IS_MEMORY_TYPE_OK(MemType));
1828                     ; 532     assert_param(IS_FLASH_PROGRAM_MODE_OK(ProgMode));
1830                     ; 533     if (MemType == FLASH_MEMTYPE_PROG)
1832  0297 0d0d          	tnz	(OFST+5,sp)
1833  0299 260c          	jrne	L147
1834                     ; 535         assert_param(IS_FLASH_PROG_BLOCK_NUMBER_OK(BlockNum));
1836                     ; 536         StartAddress = FLASH_PROG_START_PHYSICAL_ADDRESS;
1838  029b ae8000        	ldw	x,#32768
1839  029e 1f05          	ldw	(OFST-3,sp),x
1840  02a0 ae0000        	ldw	x,#0
1841  02a3 1f03          	ldw	(OFST-5,sp),x
1843  02a5 200a          	jra	L347
1844  02a7               L147:
1845                     ; 540         assert_param(IS_FLASH_DATA_BLOCK_NUMBER_OK(BlockNum));
1847                     ; 541         StartAddress = FLASH_DATA_START_PHYSICAL_ADDRESS;
1849  02a7 ae4000        	ldw	x,#16384
1850  02aa 1f05          	ldw	(OFST-3,sp),x
1851  02ac ae0000        	ldw	x,#0
1852  02af 1f03          	ldw	(OFST-5,sp),x
1853  02b1               L347:
1854                     ; 545     StartAddress = StartAddress + ((u32)BlockNum * FLASH_BLOCK_SIZE);
1856  02b1 1e09          	ldw	x,(OFST+1,sp)
1857  02b3 a680          	ld	a,#128
1858  02b5 cd0000        	call	c_cmulx
1860  02b8 96            	ldw	x,sp
1861  02b9 1c0003        	addw	x,#OFST-5
1862  02bc cd0000        	call	c_lgadd
1864                     ; 548     if (ProgMode == FLASH_PROGRAMMODE_STANDARD)
1866  02bf 0d0e          	tnz	(OFST+6,sp)
1867  02c1 260a          	jrne	L547
1868                     ; 551         FLASH->CR2 |= FLASH_CR2_PRG;
1870  02c3 7210505b      	bset	20571,#0
1871                     ; 552         FLASH->NCR2 &= (u8)(~FLASH_NCR2_NPRG);
1873  02c7 7211505c      	bres	20572,#0
1875  02cb 2008          	jra	L747
1876  02cd               L547:
1877                     ; 557         FLASH->CR2 |= FLASH_CR2_FPRG;
1879  02cd 7218505b      	bset	20571,#4
1880                     ; 558         FLASH->NCR2 &= (u8)(~FLASH_NCR2_NFPRG);
1882  02d1 7219505c      	bres	20572,#4
1883  02d5               L747:
1884                     ; 562     for (Count = 0; Count < FLASH_BLOCK_SIZE; Count++)
1886  02d5 5f            	clrw	x
1887  02d6 1f07          	ldw	(OFST-1,sp),x
1888  02d8               L157:
1889                     ; 564         *((PointerAttr u8*)StartAddress + Count) = ((u8)(Buffer[Count]));
1891  02d8 1e0f          	ldw	x,(OFST+7,sp)
1892  02da 72fb07        	addw	x,(OFST-1,sp)
1893  02dd f6            	ld	a,(x)
1894  02de 88            	push	a
1895  02df 7b05          	ld	a,(OFST-3,sp)
1896  02e1 b700          	ld	c_x,a
1897  02e3 1e06          	ldw	x,(OFST-2,sp)
1898  02e5 84            	pop	a
1899  02e6 1607          	ldw	y,(OFST-1,sp)
1900  02e8 bf01          	ldw	c_x+1,x
1901  02ea 93            	ldw	x,y
1902  02eb 92a70000      	ldf	([c_x.e],x),a
1903                     ; 562     for (Count = 0; Count < FLASH_BLOCK_SIZE; Count++)
1905  02ef 1e07          	ldw	x,(OFST-1,sp)
1906  02f1 1c0001        	addw	x,#1
1907  02f4 1f07          	ldw	(OFST-1,sp),x
1910  02f6 1e07          	ldw	x,(OFST-1,sp)
1911  02f8 a30080        	cpw	x,#128
1912  02fb 25db          	jrult	L157
1913                     ; 568     if (MemType == FLASH_MEMTYPE_DATA)
1915  02fd 7b0d          	ld	a,(OFST+5,sp)
1916  02ff a101          	cp	a,#1
1917  0301 2614          	jrne	L757
1919  0303 2007          	jra	L367
1920  0305               L167:
1921                     ; 573             timeout--;
1923  0305 1e01          	ldw	x,(OFST-7,sp)
1924  0307 1d0001        	subw	x,#1
1925  030a 1f01          	ldw	(OFST-7,sp),x
1926  030c               L367:
1927                     ; 571         while ((FLASH->IAPSR & FLASH_IAPSR_HVOFF) != 0x00 || (timeout == 0x00))
1929  030c c6505f        	ld	a,20575
1930  030f a540          	bcp	a,#64
1931  0311 26f2          	jrne	L167
1933  0313 1e01          	ldw	x,(OFST-7,sp)
1934  0315 27ee          	jreq	L167
1935  0317               L757:
1936                     ; 577 }
1939  0317 5b0a          	addw	sp,#10
1940  0319 81            	ret
1953                     	xdef	_FLASH_WaitForLastOperation
1954                     	xdef	_FLASH_ProgramBlock
1955                     	xdef	_FLASH_EraseBlock
1956                     	xdef	_FLASH_GetFlagStatus
1957                     	xdef	_FLASH_GetBootSize
1958                     	xdef	_FLASH_GetProgrammingTime
1959                     	xdef	_FLASH_GetLowPowerMode
1960                     	xdef	_FLASH_SetProgrammingTime
1961                     	xdef	_FLASH_SetLowPowerMode
1962                     	xdef	_FLASH_EraseOptionByte
1963                     	xdef	_FLASH_ProgramOptionByte
1964                     	xdef	_FLASH_ReadOptionByte
1965                     	xdef	_FLASH_ProgramWord
1966                     	xdef	_FLASH_ReadByte
1967                     	xdef	_FLASH_ProgramByte
1968                     	xdef	_FLASH_EraseByte
1969                     	xdef	_FLASH_ITConfig
1970                     	xdef	_FLASH_DeInit
1971                     	xdef	_FLASH_Lock
1972                     	xdef	_FLASH_Unlock
1973                     	xref.b	c_lreg
1974                     	xref.b	c_x
1975                     	xref.b	c_y
1994                     	xref	c_cmulx
1995                     	xref	c_ltor
1996                     	xref	c_lgadd
1997                     	xref	c_rtol
1998                     	xref	c_umul
1999                     	end

⌨️ 快捷键说明

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