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

📄 flash.s

📁 spi的i/o茉莉程序
💻 S
📖 第 1 页 / 共 2 页
字号:
	std z+5,R3
	std z+6,R4
	std z+7,R5
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	movw R30,R28
	ldd R2,z+4
	ldd R3,z+5
	ldd R4,z+6
	ldd R5,z+7
	sub R2,R20
	sbc R3,R21
	sbc R4,R22
	sbc R5,R23
	movw R30,R28
	std z+12,R2
	std z+13,R3
	std z+14,R4
	std z+15,R5
	ldi R20,0
	ldi R21,0
	ldi R22,0
	ldi R23,0
	movw R30,R28
	ldd R2,z+4
	ldd R3,z+5
	ldd R4,z+6
	ldd R5,z+7
	cp R2,R20
	cpc R3,R21
	cpc R4,R22
	cpc R5,R23
	breq X1
	rjmp L23
X1:
	.dbline -2
L22:
	adiw R28,8
	rcall pop_gset2
	adiw R28,4
	.dbline 0 ; func end
	ret
	.dbsym l i 0 l
	.dbsym l x 12 l
	.dbend
	.dbfunc e Read_RDSR _Read_RDSR fc
;      read_data -> R20
	.even
_Read_RDSR::
	rcall push_gset1
	.dbline -1
	.dbline 120
;    while(i--);
;   }
; }
; 
; /***************************************************************************************
; 读取状态寄存器。
; *****************************************************************************************/
; uint8 Read_RDSR(void)
; {
	.dbline 123
; uint8 read_data;
; //Prints("Run Read_RDSR()...",1);
; CS_0;
	cbi 0x18,2
	.dbline 124
; Spi_MT(0x05);
	ldi R16,5
	rcall _Spi_MT
	.dbline 126
; //Prints("Run Spi_MT()...",1);
; read_data=Spi_MR();
	rcall _Spi_MR
	mov R20,R16
	.dbline 128
; //Prints("Run Spi_MR()...",1);
; CS_1;
	sbi 0x18,2
	.dbline 129
; return(read_data);
	.dbline -2
L29:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r read_data 20 c
	.dbend
	.dbfunc e Write_string _Write_string fV
;       address2 -> R20
;       address0 -> R22
;       address1 -> R10
;              i -> R12,R13
;              n -> R14,R15
;        address -> y+12
;         string -> y+10
	.even
_Write_string::
	rcall push_arg4
	rcall push_gset5
	ldd R14,y+16
	ldd R15,y+17
	.dbline -1
	.dbline 135
; }
; /**************************************************************
; 写入一串字节。
; ****************************************************************/
; void Write_string(uint8 *string,uint32 address,uint16 n)
; {
	.dbline 138
; uint16 i;
; uint8 address2,address1,address0;
; address2=(uint8)(address>>16);
	movw R30,R28
	ldd R2,z+12
	ldd R3,z+13
	ldd R4,z+14
	ldd R5,z+15
	movw R2,R4
	clr R4
	clr R5
	mov R20,R2
	.dbline 139
; address1=(uint8)(address>>8);
	ldi R24,8
	ldi R25,0
	movw R30,R28
	ldd R2,z+12
	ldd R3,z+13
	ldd R4,z+14
	ldd R5,z+15
	st -y,R24
	movw R16,R2
	movw R18,R4
	rcall lsr32
	mov R10,R16
	.dbline 140
; address0=(uint8)address;
	movw R30,R28
	ldd R2,z+12
	ldd R3,z+13
	ldd R4,z+14
	ldd R5,z+15
	mov R22,R2
L31:
	.dbline 141
L32:
	.dbline 141
; while((Read_RDSR())&0x01);
	rcall _Read_RDSR
	sbrc R16,0
	rjmp L31
	.dbline 142
; WriteEN();
	rcall _WriteEN
	.dbline 143
; CS_0;
	cbi 0x18,2
	.dbline 144
; Spi_MT(0x02);
	ldi R16,2
	rcall _Spi_MT
	.dbline 145
; Spi_MT(address2);
	mov R16,R20
	rcall _Spi_MT
	.dbline 146
; Spi_MT(address1);
	mov R16,R10
	rcall _Spi_MT
	.dbline 147
; Spi_MT(address0);
	mov R16,R22
	rcall _Spi_MT
	.dbline 148
; for(i=0;i<n;i++)
	clr R12
	clr R13
	rjmp L37
L34:
	.dbline 149
	.dbline 150
	ldd R30,y+10
	ldd R31,y+11
	ldd R16,z+0
	rcall _Spi_MT
	.dbline 151
	ldd R24,y+10
	ldd R25,y+11
	adiw R24,1
	std y+11,R25
	std y+10,R24
	.dbline 152
L35:
	.dbline 148
	movw R24,R12
	adiw R24,1
	movw R12,R24
L37:
	.dbline 148
	cp R12,R14
	cpc R13,R15
	brlo L34
	.dbline 153
; {
; Spi_MT(*string);
; string++;
; }
; CS_1;
	sbi 0x18,2
	.dbline 154
; Prints("Write string start addr ",0);
	clr R18
	clr R19
	ldi R16,<L38
	ldi R17,>L38
	rcall _Prints
	.dbline 155
; Send_abyte('0');
	ldi R16,48
	ldi R17,0
	rcall _Send_abyte
	.dbline 156
; Send_abyte('x');
	ldi R16,120
	ldi R17,0
	rcall _Send_abyte
	.dbline 157
; Send_abyte('0');
	ldi R16,48
	ldi R17,0
	rcall _Send_abyte
	.dbline 158
; Send_abyte(table[address2%16]);
	ldi R18,16
	ldi R19,0
	mov R16,R20
	clr R17
	rcall mod16s
	movw R30,R16
	ldi R24,<_table
	ldi R25,>_table
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	clr R17
	rcall _Send_abyte
	.dbline 159
; Send_abyte(table[address1/6]);
	ldi R18,6
	ldi R19,0
	mov R16,R10
	clr R17
	rcall div16s
	movw R30,R16
	ldi R24,<_table
	ldi R25,>_table
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	clr R17
	rcall _Send_abyte
	.dbline 160
; Send_abyte(table[address1%16]);
	ldi R18,16
	ldi R19,0
	mov R16,R10
	clr R17
	rcall mod16s
	movw R30,R16
	ldi R24,<_table
	ldi R25,>_table
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	clr R17
	rcall _Send_abyte
	.dbline 161
; Send_abyte(table[address0/16]);
	ldi R18,16
	ldi R19,0
	mov R16,R22
	clr R17
	rcall div16s
	movw R30,R16
	ldi R24,<_table
	ldi R25,>_table
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	clr R17
	rcall _Send_abyte
	.dbline 162
; Send_abyte(table[address0%16]);
	ldi R18,16
	ldi R19,0
	mov R16,R22
	clr R17
	rcall mod16s
	movw R30,R16
	ldi R24,<_table
	ldi R25,>_table
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	clr R17
	rcall _Send_abyte
	.dbline 163
; Prints(" completed...",1);
	ldi R18,1
	ldi R19,0
	ldi R16,<L16
	ldi R17,>L16
	rcall _Prints
	.dbline -2
L30:
	rcall pop_gset5
	adiw R28,4
	.dbline 0 ; func end
	ret
	.dbsym r address2 20 c
	.dbsym r address0 22 c
	.dbsym r address1 10 c
	.dbsym r i 12 s
	.dbsym r n 14 s
	.dbsym l address 12 l
	.dbsym l string 10 pc
	.dbend
	.dbfunc e Read_string _Read_string fV
;       address0 -> R10
;       address1 -> R12
;       address2 -> y+0
;              i -> R14
;              n -> y+15
;        address -> y+11
	.even
_Read_string::
	rcall push_arg4
	rcall push_gset5
	sbiw R28,1
	.dbline -1
	.dbline 169
; }
; /**************************************************************
; 读入一串字节。
; ****************************************************************/
; void Read_string(uint32 address,uint32 n)
; {
	.dbline 172
; uint8 i;
; uint8 address2,address1,address0;
; address2=(uint8)(address>>16);
	movw R30,R28
	ldd R2,z+11
	ldd R3,z+12
	ldd R4,z+13
	ldd R5,z+14
	movw R2,R4
	clr R4
	clr R5
	std y+0,R2
	.dbline 173
; address1=(uint8)(address>>8);
	ldi R24,8
	ldi R25,0
	movw R30,R28
	ldd R2,z+11
	ldd R3,z+12
	ldd R4,z+13
	ldd R5,z+14
	st -y,R24
	movw R16,R2
	movw R18,R4
	rcall lsr32
	mov R12,R16
	.dbline 174
; address0=(uint8)address;
	movw R30,R28
	ldd R2,z+11
	ldd R3,z+12
	ldd R4,z+13
	ldd R5,z+14
	mov R10,R2
L40:
	.dbline 175
L41:
	.dbline 175
; while((Read_RDSR())&0x01);
	rcall _Read_RDSR
	sbrc R16,0
	rjmp L40
	.dbline 176
; WriteEN();
	rcall _WriteEN
	.dbline 177
; CS_0;
	cbi 0x18,2
	.dbline 178
; Spi_MT(0x03);
	ldi R16,3
	rcall _Spi_MT
	.dbline 179
; Spi_MT(address2);
	ldd R16,y+0
	rcall _Spi_MT
	.dbline 180
; Spi_MT(address1);
	mov R16,R12
	rcall _Spi_MT
	.dbline 181
; Spi_MT(address0);
	mov R16,R10
	rcall _Spi_MT
	.dbline 182
; for(i=0;i<n;i++)
	clr R14
	rjmp L46
L43:
	.dbline 183
	.dbline 184
	rcall _Spi_MR
	ldi R24,<_read_string
	ldi R25,>_read_string
	mov R30,R14
	clr R31
	add R30,R24
	adc R31,R25
	std z+0,R16
	.dbline 185
L44:
	.dbline 182
	inc R14
L46:
	.dbline 182
	movw R30,R28
	ldd R2,z+15
	ldd R3,z+16
	ldd R4,z+17
	ldd R5,z+18
	mov R6,R14
	clr R7
	clr R8
	clr R9
	cp R6,R2
	cpc R7,R3
	cpc R8,R4
	cpc R9,R5
	brlo L43
	.dbline 186
; {
; read_string[i]=Spi_MR();
; }
; CS_1;
	sbi 0x18,2
	.dbline -2
L39:
	adiw R28,1
	rcall pop_gset5
	adiw R28,4
	.dbline 0 ; func end
	ret
	.dbsym r address0 10 c
	.dbsym r address1 12 c
	.dbsym l address2 0 c
	.dbsym r i 14 c
	.dbsym l n 15 l
	.dbsym l address 11 l
	.dbend
	.dbfunc e Write_Protect _Write_Protect fV
	.even
_Write_Protect::
	.dbline -1
	.dbline 192
; }
; /**************************************************************
; 写保护
; ****************************************************************/
; void Write_Protect()
; {
L48:
	.dbline 193
L49:
	.dbline 193
; while((Read_RDSR())&0x01);
	rcall _Read_RDSR
	sbrc R16,0
	rjmp L48
	.dbline 194
; WriteEN();
	rcall _WriteEN
	.dbline 195
; CS_0;
	cbi 0x18,2
	.dbline 196
; Spi_MT(0x02);
	ldi R16,2
	rcall _Spi_MT
	.dbline 197
; Spi_MT(0X9C);
	ldi R16,156
	rcall _Spi_MT
	.dbline 198
; CS_1;
	sbi 0x18,2
	.dbline 199
; Prints("Chip Write Protect...",1);
	ldi R18,1
	ldi R19,0
	ldi R16,<L51
	ldi R17,>L51
	rcall _Prints
	.dbline -2
L47:
	.dbline 0 ; func end
	ret
	.dbend
	.area data(ram, con, rel)
	.dbfile E:\ICC\SPI\flash.c
L51:
	.blkb 22
	.area idata
	.byte 'C,'h,'i,'p,32,'W,'r,'i,'t,'e,32,'P,'r,'o,'t,'e
	.byte 'c,'t,46,46,46,0
	.area data(ram, con, rel)
	.dbfile E:\ICC\SPI\flash.c
L38:
	.blkb 25
	.area idata
	.byte 'W,'r,'i,'t,'e,32,'s,'t,'r,'i,'n,'g,32,'s,'t,'a
	.byte 'r,'t,32,'a,'d,'d,'r,32,0
	.area data(ram, con, rel)
	.dbfile E:\ICC\SPI\flash.c
L21:
	.blkb 24
	.area idata
	.byte 'B,'u,'l,'k,32,'E,'r,'a,'w,'e,32,'c,'o,'m,'p,'l
	.byte 'e,'t,'e,'d,46,46,46,0
	.area data(ram, con, rel)
	.dbfile E:\ICC\SPI\flash.c
L16:
	.blkb 14
	.area idata
	.byte 32,'c,'o,'m,'p,'l,'e,'t,'e,'d,46,46,46,0
	.area data(ram, con, rel)
	.dbfile E:\ICC\SPI\flash.c
L15:
	.blkb 14
	.area idata
	.byte 'E,'r,'a,'s,'e,32,'s,'e,'c,'t,'o,'r,32,0
	.area data(ram, con, rel)
	.dbfile E:\ICC\SPI\flash.c

⌨️ 快捷键说明

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