📄 stm8s_flash.ls
字号:
1 ; C Compiler for STM8 (COSMIC Software)
2 ; Parser V4.9.10 - 10 Feb 2011
3 ; Generator (Limited) V4.3.6 - 15 Feb 2011
4 ; Optimizer V4.3.5 - 15 Feb 2011
79 ; 63 void FLASH_Unlock(FLASH_MemType_TypeDef MemType)
79 ; 64 {
81 switch .text
82 0000 _FLASH_Unlock:
86 ; 66 assert_param(IS_MEMORY_TYPE_OK(MemType));
88 ; 69 if (MemType == FLASH_MEMTYPE_PROG)
90 0000 4d tnz a
91 0001 2609 jrne L73
92 ; 71 FLASH->PUKR = FLASH_RASS_KEY1;
94 0003 35565062 mov 20578,#86
95 ; 72 FLASH->PUKR = FLASH_RASS_KEY2;
97 0007 35ae5062 mov 20578,#174
100 000b 81 ret
101 000c L73:
102 ; 78 FLASH->DUKR = FLASH_RASS_KEY2; /* Warning: keys are reversed on data memory !!! */
104 000c 35ae5064 mov 20580,#174
105 ; 79 FLASH->DUKR = FLASH_RASS_KEY1;
107 0010 35565064 mov 20580,#86
108 ; 82 }
111 0014 81 ret
146 ; 98 void FLASH_Lock(FLASH_MemType_TypeDef MemType)
146 ; 99 {
147 switch .text
148 0015 _FLASH_Lock:
152 ; 101 assert_param(IS_MEMORY_TYPE_OK(MemType));
154 ; 104 if (MemType == FLASH_MEMTYPE_PROG)
156 0015 4d tnz a
157 0016 2605 jrne L16
158 ; 106 FLASH->IAPSR = (u8)(~FLASH_IAPSR_PUL);
160 0018 35fd505f mov 20575,#253
163 001c 81 ret
164 001d L16:
165 ; 112 FLASH->IAPSR = (u8)(~FLASH_IAPSR_DUL);
167 001d 35f7505f mov 20575,#247
168 ; 114 }
171 0021 81 ret
205 ; 130 void FLASH_DeInit(void)
205 ; 131 {
206 switch .text
207 0022 _FLASH_DeInit:
209 00000001 OFST: set 1
212 ; 132 u8 temp = 0;
214 ; 133 FLASH->CR1 = FLASH_CR1_RESET_VALUE;
216 0022 725f505a clr 20570
217 ; 134 FLASH->CR2 = FLASH_CR2_RESET_VALUE;
219 0026 725f505b clr 20571
220 ; 135 FLASH->NCR2 = FLASH_NCR2_RESET_VALUE;
222 002a 35ff505c mov 20572,#255
223 ; 136 FLASH->IAPSR &= (u8)(~FLASH_IAPSR_DUL);
225 002e 7217505f bres 20575,#3
226 ; 137 FLASH->IAPSR &= (u8)(~FLASH_IAPSR_PUL);
228 0032 7213505f bres 20575,#1
229 ; 138 temp = FLASH->IAPSR; /* Reading of this register causes the clearing of status flags */
231 0036 c6505f ld a,20575
232 ; 139 }
235 0039 81 ret
290 ; 154 void FLASH_ITConfig(FunctionalState NewState)
290 ; 155 {
291 switch .text
292 003a _FLASH_ITConfig:
296 ; 156 if (NewState != DISABLE)
298 003a 4d tnz a
299 003b 2705 jreq L131
300 ; 158 FLASH->CR1 |= FLASH_CR1_IE; /* Enables the interrupt sources */
302 003d 7212505a bset 20570,#1
305 0041 81 ret
306 0042 L131:
307 ; 162 FLASH->CR1 &= (u8)(~FLASH_CR1_IE); /* Disables the interrupt sources */
309 0042 7213505a bres 20570,#1
310 ; 164 }
313 0046 81 ret
366 ; 184 void FLASH_EraseBlock(u16 BlockNum, FLASH_MemType_TypeDef MemType)
366 ; 185 {
367 switch .text
368 0047 _FLASH_EraseBlock:
370 0047 89 pushw x
371 0048 5204 subw sp,#4
372 00000004 OFST: set 4
375 ; 186 u32 StartAddress = 0;
377 ; 189 assert_param(IS_MEMORY_TYPE_OK(MemType));
379 ; 190 if (MemType == FLASH_MEMTYPE_PROG)
381 004a 7b09 ld a,(OFST+5,sp)
382 004c 2605 jrne L361
383 ; 192 assert_param(IS_FLASH_PROG_BLOCK_NUMBER_OK(BlockNum));
385 ; 193 StartAddress = FLASH_PROG_START_PHYSICAL_ADDRESS;
387 004e ae8000 ldw x,#32768
389 0051 2003 jra L561
390 0053 L361:
391 ; 197 assert_param(IS_FLASH_DATA_BLOCK_NUMBER_OK(BlockNum));
393 ; 198 StartAddress = FLASH_DATA_START_PHYSICAL_ADDRESS;
395 0053 ae4000 ldw x,#16384
396 0056 L561:
397 0056 1f03 ldw (OFST-1,sp),x
398 0058 5f clrw x
399 0059 1f01 ldw (OFST-3,sp),x
400 ; 202 StartAddress = StartAddress + ((u32)BlockNum * FLASH_BLOCK_SIZE);
402 005b a680 ld a,#128
403 005d 1e05 ldw x,(OFST+1,sp)
404 005f cd0000 call c_cmulx
406 0062 96 ldw x,sp
407 0063 5c incw x
408 0064 cd0000 call c_lgadd
410 ; 205 FLASH->CR2 |= FLASH_CR2_ERASE;
412 0067 721a505b bset 20571,#5
413 ; 206 FLASH->NCR2 &= (u8)(~FLASH_NCR2_NERASE);
415 006b 721b505c bres 20572,#5
416 ; 209 *((@far u8*) StartAddress) = FLASH_CLEAR_BYTE;
418 006f 7b02 ld a,(OFST-2,sp)
419 0071 b700 ld c_x,a
420 0073 1e03 ldw x,(OFST-1,sp)
421 0075 bf01 ldw c_x+1,x
422 0077 4f clr a
423 0078 92bd0000 ldf [c_x.e],a
424 ; 210 *((@far u8*) StartAddress + 1) = FLASH_CLEAR_BYTE;
427 007c 90ae0001 ldw y,#1
428 0080 93 ldw x,y
429 0081 92a70000 ldf ([c_x.e],x),a
430 ; 211 *((@far u8*) StartAddress + 2) = FLASH_CLEAR_BYTE;
433 0085 905c incw y
434 0087 93 ldw x,y
435 0088 92a70000 ldf ([c_x.e],x),a
436 ; 212 *((@far u8*) StartAddress + 3) = FLASH_CLEAR_BYTE;
439 008c 905c incw y
440 008e 93 ldw x,y
441 008f 92a70000 ldf ([c_x.e],x),a
442 ; 219 }
446 0093 5b06 addw sp,#6
447 0095 81 ret
481 ; 238 void FLASH_EraseByte(u32 Address)
481 ; 239 {
482 switch .text
483 0096 _FLASH_EraseByte:
485 00000000 OFST: set 0
488 ; 241 assert_param(IS_FLASH_ADDRESS_OK(Address));
490 ; 244 *((@far u8*) Address) = FLASH_CLEAR_BYTE; /* Erase byte */
492 0096 7b04 ld a,(OFST+4,sp)
493 0098 b700 ld c_x,a
494 009a 1e05 ldw x,(OFST+5,sp)
495 009c bf01 ldw c_x+1,x
496 009e 4f clr a
497 009f 92bd0000 ldf [c_x.e],a
498 ; 248 }
502 00a3 81 ret
538 ; 267 void FLASH_EraseOptionByte(u32 Address)
538 ; 268 {
539 switch .text
540 00a4 _FLASH_EraseOptionByte:
542 00000000 OFST: set 0
545 ; 270 assert_param(IS_OPTION_BYTE_ADDRESS_OK(Address));
547 ; 273 FLASH->CR2 |= FLASH_CR2_OPT;
549 00a4 721e505b bset 20571,#7
550 ; 274 FLASH->NCR2 &= (u8)(~FLASH_NCR2_NOPT);
552 00a8 721f505c bres 20572,#7
553 ; 278 *((@far u8*)Address) = FLASH_CLEAR_BYTE;
555 00ac 7b04 ld a,(OFST+4,sp)
556 00ae b700 ld c_x,a
557 00b0 1e05 ldw x,(OFST+5,sp)
558 00b2 bf01 ldw c_x+1,x
559 00b4 4f clr a
560 00b5 92bd0000 ldf [c_x.e],a
561 ; 279 *((@far u8*)(Address + 1 )) = FLASH_SET_BYTE;
564 00b9 96 ldw x,sp
565 00ba 1c0003 addw x,#OFST+3
566 00bd cd0000 call c_ltor
568 00c0 4c inc a
569 00c1 cd0000 call c_ladc
571 00c4 450100 mov c_x,c_lreg+1
572 00c7 be02 ldw x,c_lreg+2
573 00c9 bf01 ldw c_x+1,x
574 00cb a6ff ld a,#255
575 00cd 92bd0000 ldf [c_x.e],a
576 ; 285 FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
579 00d1 a601 ld a,#1
580 00d3 cd0280 call _FLASH_WaitForLastOperation
582 ; 288 FLASH->CR2 &= (u8)(~FLASH_CR2_OPT);
584 00d6 721f505b bres 20571,#7
585 ; 289 FLASH->NCR2 |= FLASH_NCR2_NOPT;
587 00da 721e505c bset 20572,#7
588 ; 290 }
591 00de 81 ret
695 ; 318 void FLASH_ProgramBlock(u16 BlockNum, FLASH_MemType_TypeDef MemType, FLASH_ProgramMode_TypeDef ProgMode, u8 *Buffer)
695 ; 319 {
696 switch .text
697 00df _FLASH_ProgramBlock:
699 00df 89 pushw x
700 00e0 5206 subw sp,#6
701 00000006 OFST: set 6
704 ; 320 u16 Count = 0;
706 ; 321 u32 StartAddress = 0;
708 ; 324 assert_param(IS_MEMORY_TYPE_OK(MemType));
710 ; 325 assert_param(IS_FLASH_PROGRAM_MODE_OK(ProgMode));
712 ; 326 if (MemType == FLASH_MEMTYPE_PROG)
714 00e2 7b0b ld a,(OFST+5,sp)
715 00e4 2605 jrne L572
716 ; 328 assert_param(IS_FLASH_PROG_BLOCK_NUMBER_OK(BlockNum));
718 ; 329 StartAddress = FLASH_PROG_START_PHYSICAL_ADDRESS;
720 00e6 ae8000 ldw x,#32768
722 00e9 2003 jra L772
723 00eb L572:
724 ; 333 assert_param(IS_FLASH_DATA_BLOCK_NUMBER_OK(BlockNum));
726 ; 334 StartAddress = FLASH_DATA_START_PHYSICAL_ADDRESS;
728 00eb ae4000 ldw x,#16384
729 00ee L772:
730 00ee 1f03 ldw (OFST-3,sp),x
731 00f0 5f clrw x
732 00f1 1f01 ldw (OFST-5,sp),x
733 ; 338 StartAddress = StartAddress + ((u32)BlockNum * FLASH_BLOCK_SIZE);
735 00f3 a680 ld a,#128
736 00f5 1e07 ldw x,(OFST+1,sp)
737 00f7 cd0000 call c_cmulx
739 00fa 96 ldw x,sp
740 00fb 5c incw x
741 00fc cd0000 call c_lgadd
743 ; 341 if (ProgMode == FLASH_PROGRAMMODE_STANDARD)
745 00ff 7b0c ld a,(OFST+6,sp)
746 0101 260a jrne L103
747 ; 344 FLASH->CR2 |= FLASH_CR2_PRG;
749 0103 7210505b bset 20571,#0
750 ; 345 FLASH->NCR2 &= (u8)(~FLASH_NCR2_NPRG);
752 0107 7211505c bres 20572,#0
754 010b 2008 jra L303
755 010d L103:
756 ; 350 FLASH->CR2 |= FLASH_CR2_FPRG;
758 010d 7218505b bset 20571,#4
759 ; 351 FLASH->NCR2 &= (u8)(~FLASH_NCR2_NFPRG);
761 0111 7219505c bres 20572,#4
762 0115 L303:
763 ; 355 for (Count = 0; Count < FLASH_BLOCK_SIZE; Count++)
765 0115 5f clrw x
766 0116 1f05 ldw (OFST-1,sp),x
767 0118 L503:
768 ; 357 *((u8*)StartAddress + Count) = ((u8)(Buffer[Count]));
770 0118 1e0d ldw x,(OFST+7,sp)
771 011a 72fb05 addw x,(OFST-1,sp)
772 011d f6 ld a,(x)
773 011e 1e03 ldw x,(OFST-3,sp)
774 0120 72fb05 addw x,(OFST-1,sp)
775 0123 f7 ld (x),a
776 ; 355 for (Count = 0; Count < FLASH_BLOCK_SIZE; Count++)
778 0124 1e05 ldw x,(OFST-1,sp)
779 0126 5c incw x
780 0127 1f05 ldw (OFST-1,sp),x
783 0129 a30080 cpw x,#128
784 012c 25ea jrult L503
785 ; 359 }
788 012e 5b08 addw sp,#8
789 0130 81 ret
832 ; 381 void FLASH_ProgramByte(u32 Address, u8 Data)
832 ; 382 {
833 switch .text
834 0131 _FLASH_ProgramByte:
836 00000000 OFST: set 0
839 ; 384 assert_param(IS_FLASH_ADDRESS_OK(Address));
841 ; 387 *((@far u8*) Address) = Data;
843 0131 7b07 ld a,(OFST+7,sp)
844 0133 88 push a
845 0134 7b05 ld a,(OFST+5,sp)
846 0136 b700 ld c_x,a
847 0138 1e06 ldw x,(OFST+6,sp)
848 013a bf01 ldw c_x+1,x
849 013c 84 pop a
850 013d 92bd0000 ldf [c_x.e],a
851 ; 391 }
854 0141 81 ret
899 ; 411 void FLASH_ProgramOptionByte(u32 Address, u8 Data)
899 ; 412 {
900 switch .text
901 0142 _FLASH_ProgramOptionByte:
903 00000000 OFST: set 0
906 ; 414 assert_param(IS_OPTION_BYTE_ADDRESS_OK(Address));
908 ; 417 FLASH->CR2 |= FLASH_CR2_OPT;
910 0142 721e505b bset 20571,#7
911 ; 418 FLASH->NCR2 &= (u8)(~FLASH_NCR2_NOPT);
913 0146 721f505c bres 20572,#7
914 ; 422 *((@far u8*)Address) = Data;
916 014a 7b07 ld a,(OFST+7,sp)
917 014c 88 push a
918 014d 7b05 ld a,(OFST+5,sp)
919 014f b700 ld c_x,a
920 0151 1e06 ldw x,(OFST+6,sp)
921 0153 bf01 ldw c_x+1,x
922 0155 84 pop a
923 0156 92bd0000 ldf [c_x.e],a
924 ; 423 *((@far u8*)(Address + 1)) = (u8)(~Data);
926 015a 96 ldw x,sp
927 015b 1c0003 addw x,#OFST+3
928 015e cd0000 call c_ltor
930 0161 a601 ld a,#1
931 0163 cd0000 call c_ladc
933 0166 450100 mov c_x,c_lreg+1
934 0169 be02 ldw x,c_lreg+2
935 016b bf01 ldw c_x+1,x
936 016d 7b07 ld a,(OFST+7,sp)
937 016f 43 cpl a
938 0170 92bd0000 ldf [c_x.e],a
939 ; 429 FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
941 0174 a601 ld a,#1
942 0176 cd0280 call _FLASH_WaitForLastOperation
944 ; 432 FLASH->CR2 &= (u8)(~FLASH_CR2_OPT);
946 0179 721f505b bres 20571,#7
947 ; 433 FLASH->NCR2 |= FLASH_NCR2_NOPT;
949 017d 721e505c bset 20572,#7
950 ; 434 }
953 0181 81 ret
996 ; 456 void FLASH_ProgramWord(u32 Address, u32 Data)
996 ; 457 {
997 switch .text
998 0182 _FLASH_ProgramWord:
1000 00000000 OFST: set 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -