📄 stm8s_flash.ls
字号:
1003 ; 459 assert_param(IS_FLASH_ADDRESS_OK(Address));
1005 ; 462 FLASH->CR2 |= FLASH_CR2_WPRG;
1007 0182 721c505b bset 20571,#6
1008 ; 463 FLASH->NCR2 &= (u8)(~FLASH_NCR2_NWPRG);
1010 0186 721d505c bres 20572,#6
1011 ; 466 *((@far u8*)Address) = BYTE_0(Data); /* Write one byte */
1013 018a 7b0a ld a,(OFST+10,sp)
1014 018c 88 push a
1015 018d 7b05 ld a,(OFST+5,sp)
1016 018f b700 ld c_x,a
1017 0191 1e06 ldw x,(OFST+6,sp)
1018 0193 bf01 ldw c_x+1,x
1019 0195 84 pop a
1020 0196 92bd0000 ldf [c_x.e],a
1021 ; 467 *(((@far u8*)Address) + 1) = BYTE_1(Data); /* Write one byte */
1023 019a 7b09 ld a,(OFST+9,sp)
1024 019c 88 push a
1025 019d 7b05 ld a,(OFST+5,sp)
1026 019f b700 ld c_x,a
1027 01a1 1e06 ldw x,(OFST+6,sp)
1028 01a3 bf01 ldw c_x+1,x
1029 01a5 90ae0001 ldw y,#1
1030 01a9 93 ldw x,y
1031 01aa 84 pop a
1032 01ab 92a70000 ldf ([c_x.e],x),a
1033 ; 468 *(((@far u8*)Address) + 2) = BYTE_2(Data); /* Write one byte */
1035 01af 7b08 ld a,(OFST+8,sp)
1036 01b1 88 push a
1037 01b2 7b05 ld a,(OFST+5,sp)
1038 01b4 b700 ld c_x,a
1039 01b6 1e06 ldw x,(OFST+6,sp)
1040 01b8 bf01 ldw c_x+1,x
1041 01ba 905c incw y
1042 01bc 93 ldw x,y
1043 01bd 84 pop a
1044 01be 92a70000 ldf ([c_x.e],x),a
1045 ; 469 *(((@far u8*)Address) + 3) = BYTE_3(Data); /* Write one byte */
1047 01c2 7b07 ld a,(OFST+7,sp)
1048 01c4 88 push a
1049 01c5 7b05 ld a,(OFST+5,sp)
1050 01c7 b700 ld c_x,a
1051 01c9 1e06 ldw x,(OFST+6,sp)
1052 01cb bf01 ldw c_x+1,x
1053 01cd 905c incw y
1054 01cf 93 ldw x,y
1055 01d0 84 pop a
1056 01d1 92a70000 ldf ([c_x.e],x),a
1057 ; 476 }
1060 01d5 81 ret
1094 ; 492 u8 FLASH_ReadByte(u32 Address)
1094 ; 493 {
1095 switch .text
1096 01d6 _FLASH_ReadByte:
1098 00000000 OFST: set 0
1101 ; 495 assert_param(IS_FLASH_ADDRESS_OK(Address));
1103 ; 498 return(*((@far u8*) Address)); /* Read byte */
1105 01d6 7b04 ld a,(OFST+4,sp)
1106 01d8 b700 ld c_x,a
1107 01da 1e05 ldw x,(OFST+5,sp)
1108 01dc bf01 ldw c_x+1,x
1109 01de 92bc0000 ldf a,[c_x.e]
1112 01e2 81 ret
1175 ; 518 u16 FLASH_ReadOptionByte(u32 Address)
1175 ; 519 {
1176 switch .text
1177 01e3 _FLASH_ReadOptionByte:
1179 01e3 5204 subw sp,#4
1180 00000004 OFST: set 4
1183 ; 520 u8 value_optbyte, value_optbyte_complement = 0;
1185 ; 521 u16 res_value = 0;
1187 ; 524 assert_param(IS_OPTION_BYTE_ADDRESS_OK(Address));
1189 ; 527 value_optbyte = *((@far u8*)Address); /* Read option byte */
1191 01e5 7b08 ld a,(OFST+4,sp)
1192 01e7 b700 ld c_x,a
1193 01e9 1e09 ldw x,(OFST+5,sp)
1194 01eb bf01 ldw c_x+1,x
1195 01ed 92bc0000 ldf a,[c_x.e]
1196 01f1 6b01 ld (OFST-3,sp),a
1197 ; 528 value_optbyte_complement = *(((@far u8*)Address) + 1); /* Read option byte complement*/
1199 01f3 90ae0001 ldw y,#1
1200 01f7 93 ldw x,y
1201 01f8 92af0000 ldf a,([c_x.e],x)
1202 01fc 6b02 ld (OFST-2,sp),a
1203 ; 534 if (value_optbyte == (u8)(~value_optbyte_complement))
1205 01fe 43 cpl a
1206 01ff 1101 cp a,(OFST-3,sp)
1207 0201 2614 jrne L154
1208 ; 536 res_value = (u16)((u16)value_optbyte << 8);
1210 0203 7b01 ld a,(OFST-3,sp)
1211 0205 97 ld xl,a
1212 0206 4f clr a
1213 0207 02 rlwa x,a
1214 0208 1f03 ldw (OFST-1,sp),x
1215 ; 537 res_value = res_value | (u16)value_optbyte_complement;
1217 020a 5f clrw x
1218 020b 7b02 ld a,(OFST-2,sp)
1219 020d 97 ld xl,a
1220 020e 01 rrwa x,a
1221 020f 1a04 or a,(OFST+0,sp)
1222 0211 01 rrwa x,a
1223 0212 1a03 or a,(OFST-1,sp)
1224 0214 01 rrwa x,a
1226 0215 2003 jra L354
1227 0217 L154:
1228 ; 541 res_value = FLASH_OPTIONBYTE_ERROR;
1230 0217 ae5555 ldw x,#21845
1231 021a L354:
1232 ; 544 return(res_value);
1236 021a 5b04 addw sp,#4
1237 021c 81 ret
1311 ; 561 void FLASH_SetLowPowerMode(FLASH_LPMode_TypeDef LPMode)
1311 ; 562 {
1312 switch .text
1313 021d _FLASH_SetLowPowerMode:
1315 021d 88 push a
1316 00000000 OFST: set 0
1319 ; 564 assert_param(IS_FLASH_LOW_POWER_MODE_OK(LPMode));
1321 ; 566 FLASH->CR1 &= (u8)(~(FLASH_CR1_HALT | FLASH_CR1_AHALT)); /* Clears the two bits */
1323 021e c6505a ld a,20570
1324 0221 a4f3 and a,#243
1325 0223 c7505a ld 20570,a
1326 ; 567 FLASH->CR1 |= (u8)LPMode; /* Sets the new mode */
1328 0226 c6505a ld a,20570
1329 0229 1a01 or a,(OFST+1,sp)
1330 022b c7505a ld 20570,a
1331 ; 568 }
1334 022e 84 pop a
1335 022f 81 ret
1393 ; 584 void FLASH_SetProgrammingTime(FLASH_ProgramTime_TypeDef ProgTime)
1393 ; 585 {
1394 switch .text
1395 0230 _FLASH_SetProgrammingTime:
1399 ; 587 assert_param(IS_FLASH_PROGRAM_TIME_OK(ProgTime));
1401 ; 589 FLASH->CR1 &= (u8)(~FLASH_CR1_FIX);
1403 0230 7211505a bres 20570,#0
1404 ; 590 FLASH->CR1 |= (u8)ProgTime;
1406 0234 ca505a or a,20570
1407 0237 c7505a ld 20570,a
1408 ; 591 }
1411 023a 81 ret
1436 ; 608 FLASH_LPMode_TypeDef FLASH_GetLowPowerMode(void)
1436 ; 609 {
1437 switch .text
1438 023b _FLASH_GetLowPowerMode:
1442 ; 610 return((FLASH_LPMode_TypeDef)(FLASH->CR1 & (FLASH_CR1_HALT | FLASH_CR1_AHALT)));
1444 023b c6505a ld a,20570
1445 023e a40c and a,#12
1448 0240 81 ret
1473 ; 628 FLASH_ProgramTime_TypeDef FLASH_GetProgrammingTime(void)
1473 ; 629 {
1474 switch .text
1475 0241 _FLASH_GetProgrammingTime:
1479 ; 630 return((FLASH_ProgramTime_TypeDef)(FLASH->CR1 & FLASH_CR1_FIX));
1481 0241 c6505a ld a,20570
1482 0244 a401 and a,#1
1485 0246 81 ret
1519 ; 648 u32 FLASH_GetBootSize(void)
1519 ; 649 {
1520 switch .text
1521 0247 _FLASH_GetBootSize:
1523 0247 5204 subw sp,#4
1524 00000004 OFST: set 4
1527 ; 650 u32 temp = 0;
1529 ; 653 temp = (u32)((u32)FLASH->FPR * (u32)512);
1531 0249 c6505d ld a,20573
1532 024c 5f clrw x
1533 024d 97 ld xl,a
1534 024e 90ae0200 ldw y,#512
1535 0252 cd0000 call c_umul
1537 0255 96 ldw x,sp
1538 0256 5c incw x
1539 0257 cd0000 call c_rtol
1541 ; 656 if (FLASH->FPR == 0xFF)
1543 025a c6505d ld a,20573
1544 025d 4c inc a
1545 025e 260d jrne L375
1546 ; 658 temp += 512;
1548 0260 ae0200 ldw x,#512
1549 0263 bf02 ldw c_lreg+2,x
1550 0265 5f clrw x
1551 0266 bf00 ldw c_lreg,x
1552 0268 96 ldw x,sp
1553 0269 5c incw x
1554 026a cd0000 call c_lgadd
1556 026d L375:
1557 ; 662 return(temp);
1559 026d 96 ldw x,sp
1560 026e 5c incw x
1561 026f cd0000 call c_ltor
1565 0272 5b04 addw sp,#4
1566 0274 81 ret
1675 ; 682 FlagStatus FLASH_GetFlagStatus(FLASH_Flag_TypeDef FLASH_FLAG)
1675 ; 683 {
1676 switch .text
1677 0275 _FLASH_GetFlagStatus:
1679 0275 88 push a
1680 00000001 OFST: set 1
1683 ; 684 FlagStatus status = RESET;
1685 ; 686 assert_param(IS_FLASH_FLAGS_OK(FLASH_FLAG));
1687 ; 689 if ((FLASH->IAPSR & (u8)FLASH_FLAG) != (u8)RESET)
1689 0276 c4505f and a,20575
1690 0279 2702 jreq L546
1691 ; 691 status = SET; /* FLASH_FLAG is set */
1693 027b a601 ld a,#1
1695 027d L546:
1696 ; 695 status = RESET; /* FLASH_FLAG is reset*/
1698 ; 699 return status;
1702 027d 5b01 addw sp,#1
1703 027f 81 ret
1788 ; 717 FLASH_Status_TypeDef FLASH_WaitForLastOperation(FLASH_MemType_TypeDef MemType)
1788 ; 718 {
1789 switch .text
1790 0280 _FLASH_WaitForLastOperation:
1792 0280 5205 subw sp,#5
1793 00000005 OFST: set 5
1796 ; 719 u32 timeout = 2000;
1798 0282 ae07d0 ldw x,#2000
1799 0285 1f03 ldw (OFST-2,sp),x
1800 0287 5f clrw x
1801 0288 1f01 ldw (OFST-4,sp),x
1802 ; 720 u8 flagstatus = 0x00;
1804 028a 0f05 clr (OFST+0,sp)
1805 ; 722 if (MemType == FLASH_MEMTYPE_PROG)
1807 028c 4d tnz a
1808 028d 262b jrne L727
1810 028f 200e jra L517
1811 0291 L317:
1812 ; 726 flagstatus = (u8)(FLASH->IAPSR & (FLASH_IAPSR_EOP |
1812 ; 727 FLASH_IAPSR_WR_PG_DIS));
1814 0291 c6505f ld a,20575
1815 0294 a405 and a,#5
1816 0296 6b05 ld (OFST+0,sp),a
1817 ; 728 timeout--;
1819 0298 96 ldw x,sp
1820 0299 5c incw x
1821 029a a601 ld a,#1
1822 029c cd0000 call c_lgsbc
1824 029f L517:
1825 ; 724 while ((flagstatus == 0x00) && (timeout != 0x00))
1827 029f 7b05 ld a,(OFST+0,sp)
1828 02a1 2622 jrne L327
1830 02a3 96 ldw x,sp
1831 02a4 5c incw x
1832 02a5 cd0000 call c_lzmp
1834 02a8 26e7 jrne L317
1835 02aa 2019 jra L327
1836 02ac L527:
1837 ; 735 flagstatus = (u8)(FLASH->IAPSR & (FLASH_IAPSR_HVOFF |
1837 ; 736 FLASH_IAPSR_WR_PG_DIS));
1839 02ac c6505f ld a,20575
1840 02af a441 and a,#65
1841 02b1 6b05 ld (OFST+0,sp),a
1842 ; 737 timeout--;
1844 02b3 96 ldw x,sp
1845 02b4 5c incw x
1846 02b5 a601 ld a,#1
1847 02b7 cd0000 call c_lgsbc
1849 02ba L727:
1850 ; 733 while ((flagstatus == 0x00) && (timeout != 0x00))
1852 02ba 7b05 ld a,(OFST+0,sp)
1853 02bc 2607 jrne L327
1855 02be 96 ldw x,sp
1856 02bf 5c incw x
1857 02c0 cd0000 call c_lzmp
1859 02c3 26e7 jrne L527
1860 02c5 L327:
1861 ; 740 if (timeout == 0x00 )
1863 02c5 96 ldw x,sp
1864 02c6 5c incw x
1865 02c7 cd0000 call c_lzmp
1867 02ca 2604 jrne L537
1868 ; 742 flagstatus = FLASH_STATUS_TIMEOUT;
1870 02cc a602 ld a,#2
1871 02ce 6b05 ld (OFST+0,sp),a
1872 02d0 L537:
1873 ; 745 return((FLASH_Status_TypeDef)flagstatus);
1875 02d0 7b05 ld a,(OFST+0,sp)
1878 02d2 5b05 addw sp,#5
1879 02d4 81 ret
1892 xdef _FLASH_WaitForLastOperation
1893 xdef _FLASH_GetFlagStatus
1894 xdef _FLASH_GetBootSize
1895 xdef _FLASH_GetProgrammingTime
1896 xdef _FLASH_GetLowPowerMode
1897 xdef _FLASH_SetProgrammingTime
1898 xdef _FLASH_SetLowPowerMode
1899 xdef _FLASH_ReadOptionByte
1900 xdef _FLASH_ReadByte
1901 xdef _FLASH_ProgramWord
1902 xdef _FLASH_ProgramOptionByte
1903 xdef _FLASH_ProgramByte
1904 xdef _FLASH_ProgramBlock
1905 xdef _FLASH_EraseOptionByte
1906 xdef _FLASH_EraseByte
1907 xdef _FLASH_EraseBlock
1908 xdef _FLASH_ITConfig
1909 xdef _FLASH_DeInit
1910 xdef _FLASH_Lock
1911 xdef _FLASH_Unlock
1912 xref.b c_lreg
1913 xref.b c_x
1914 xref.b c_y
1933 xref c_lzmp
1934 xref c_lgsbc
1935 xref c_rtol
1936 xref c_umul
1937 xref c_ladc
1938 xref c_ltor
1939 xref c_lgadd
1940 xref c_cmulx
1941 end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -