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

📄 at45db041d.s

📁 用ATMEGA16的硬件SPI驱动AT45DB041D
💻 S
📖 第 1 页 / 共 5 页
字号:
	.dbline 198
;   if(Test_Buf[0]!=0x1F) return 0;       //产家ID不为0x1F则返回0
	ldd R24,y+0
	cpi R24,31
	breq L54
X12:
	.dbline 198
	clr R16
	xjmp L53
L54:
	.dbline 200
; 
;   return 1;//正确返回 1
	ldi R16,1
	.dbline -2
L53:
	.dbline 0 ; func end
	adiw R28,4
	ret
	.dbsym l Test_Buf 0 A[4:4]c
	.dbend
	.dbfunc e DF_Deep_Power_Down _DF_Deep_Power_Down fV
	.even
_DF_Deep_Power_Down::
	.dbline -1
	.dbline 206
; }
; /************************************************************
; *使FLASH进入Deep_Power_Down
; ************************************************************/
; void DF_Deep_Power_Down(void)
; {
	.dbline 207
;   DF_Check_Busy_State();
	xcall _DF_Check_Busy_State
	.dbline 208
;   Enable_DFLASH();
	xcall _Enable_DFLASH
	.dbline 209
;   SPI_Write_Byte(0xB9);//写Deep Power-down操作码
	ldi R16,185
	xcall _SPI_Write_Byte
	.dbline 210
;   Disable_DFLASH();
	xcall _Disable_DFLASH
	.dbline -2
L56:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e DF_Resume_from_Deep_Power_Down _DF_Resume_from_Deep_Power_Down fV
	.even
_DF_Resume_from_Deep_Power_Down::
	.dbline -1
	.dbline 216
; }
; /************************************************************
; *使FLASH退出Deep_Power_Down
; ************************************************************/
; void DF_Resume_from_Deep_Power_Down(void)
; {
	.dbline 217
;   DF_Check_Busy_State();
	xcall _DF_Check_Busy_State
	.dbline 218
;   Enable_DFLASH();
	xcall _Enable_DFLASH
	.dbline 219
;   SPI_Write_Byte(0xAB);//写Resume from Deep Power-down操作码
	ldi R16,171
	xcall _SPI_Write_Byte
	.dbline 220
;   Disable_DFLASH();
	xcall _Disable_DFLASH
	.dbline -2
L57:
	.dbline 0 ; func end
	ret
	.dbend
	.area lit(rom, con, rel)
L59:
	.byte 61,42
	.byte 127,169
	.area text(rom, con, rel)
	.dbfile E:\item\car\AT45DB041D\AT45DB041D.c
	.dbfunc e DF_Enable_Sector_Protection _DF_Enable_Sector_Protection fV
; Enable_Sector_Protection_Command -> y+0
;              i -> R20
	.even
_DF_Enable_Sector_Protection::
	st -y,R20
	sbiw R28,4
	.dbline -1
	.dbline 226
; }
; /************************************************************
; *使能扇区保护
; ************************************************************/
; void DF_Enable_Sector_Protection(void)
; {
	.dbline 227
;   unsigned char Enable_Sector_Protection_Command[4]={0x3D,0x2A,0x7F,0xA9}; //使能扇区保护操作码
	ldi R24,<L59
	ldi R25,>L59
	movw R30,R28
	ldi R16,4
	ldi R17,0
	st -y,R31
	st -y,R30
	st -y,R25
	st -y,R24
	xcall asgncblk
	.dbline 230
;   unsigned char i;
; 
;   DF_Check_Busy_State();
	xcall _DF_Check_Busy_State
	.dbline 231
;   Enable_DFLASH();
	xcall _Enable_DFLASH
	.dbline 232
;   for(i=0;i<4;i++)
	clr R20
	xjmp L63
L60:
	.dbline 233
;   {
	.dbline 234
; 	  SPI_Write_Byte(Enable_Sector_Protection_Command[i]);//写使能扇区保护操作码
	movw R24,R28
	mov R30,R20
	clr R31
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	xcall _SPI_Write_Byte
	.dbline 235
;   }
L61:
	.dbline 232
	inc R20
L63:
	.dbline 232
	cpi R20,4
	brlo L60
X13:
	.dbline 236
;   Disable_DFLASH();
	xcall _Disable_DFLASH
	.dbline -2
L58:
	.dbline 0 ; func end
	adiw R28,4
	ld R20,y+
	ret
	.dbsym l Enable_Sector_Protection_Command 0 A[4:4]c
	.dbsym r i 20 c
	.dbend
	.area lit(rom, con, rel)
L65:
	.byte 61,42
	.byte 127,154
	.area text(rom, con, rel)
	.dbfile E:\item\car\AT45DB041D\AT45DB041D.c
	.dbfunc e DF_Disable_Sector_Protection _DF_Disable_Sector_Protection fV
; Disable_Sector_Protection_Command -> y+0
;              i -> R20
	.even
_DF_Disable_Sector_Protection::
	st -y,R20
	sbiw R28,4
	.dbline -1
	.dbline 242
; }
; /************************************************************
; *禁止扇区保护
; ************************************************************/
; void DF_Disable_Sector_Protection(void)
; {
	.dbline 243
;   unsigned char Disable_Sector_Protection_Command[4]={0x3D,0x2A,0x7F,0x9A};//禁止扇区保护操作码
	ldi R24,<L65
	ldi R25,>L65
	movw R30,R28
	ldi R16,4
	ldi R17,0
	st -y,R31
	st -y,R30
	st -y,R25
	st -y,R24
	xcall asgncblk
	.dbline 246
;   unsigned char i;
; 
;   DF_Check_Busy_State();
	xcall _DF_Check_Busy_State
	.dbline 247
;   Enable_DFLASH();
	xcall _Enable_DFLASH
	.dbline 248
;   for(i=0;i<4;i++)
	clr R20
	xjmp L69
L66:
	.dbline 249
;   {
	.dbline 250
;       SPI_Write_Byte(Disable_Sector_Protection_Command[i]);//写禁止扇区保护操作码
	movw R24,R28
	mov R30,R20
	clr R31
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	xcall _SPI_Write_Byte
	.dbline 251
;   }
L67:
	.dbline 248
	inc R20
L69:
	.dbline 248
	cpi R20,4
	brlo L66
X14:
	.dbline 252
;   Disable_DFLASH();
	xcall _Disable_DFLASH
	.dbline -2
L64:
	.dbline 0 ; func end
	adiw R28,4
	ld R20,y+
	ret
	.dbsym l Disable_Sector_Protection_Command 0 A[4:4]c
	.dbsym r i 20 c
	.dbend
	.area lit(rom, con, rel)
L71:
	.byte 61,42
	.byte 127,207
	.area text(rom, con, rel)
	.dbfile E:\item\car\AT45DB041D\AT45DB041D.c
	.dbfunc e DF_Erase_Sector_Protection_Register _DF_Erase_Sector_Protection_Register fV
; Erase_Sector_Protection_Command -> y+0
;              i -> R20
	.even
_DF_Erase_Sector_Protection_Register::
	st -y,R20
	sbiw R28,4
	.dbline -1
	.dbline 258
; }
; /************************************************************
; *擦除扇区保护
; ************************************************************/
; void DF_Erase_Sector_Protection_Register(void)
; {
	.dbline 259
;   unsigned char Erase_Sector_Protection_Command[4]={0x3D,0x2A,0x7F,0xCF};//擦除扇区保护操作码
	ldi R24,<L71
	ldi R25,>L71
	movw R30,R28
	ldi R16,4
	ldi R17,0
	st -y,R31
	st -y,R30
	st -y,R25
	st -y,R24
	xcall asgncblk
	.dbline 262
;   unsigned char i;
; 
;   DF_Check_Busy_State();
	xcall _DF_Check_Busy_State
	.dbline 263
;   Enable_DFLASH();
	xcall _Enable_DFLASH
	.dbline 264
;   for(i=0;i<4;i++)
	clr R20
	xjmp L75
L72:
	.dbline 265
;   {
	.dbline 266
;       SPI_Write_Byte(Erase_Sector_Protection_Command[i]);//写擦除扇区保护操作码
	movw R24,R28
	mov R30,R20
	clr R31
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	xcall _SPI_Write_Byte
	.dbline 267
;   }
L73:
	.dbline 264
	inc R20
L75:
	.dbline 264
	cpi R20,4
	brlo L72
X15:
	.dbline 268
;   Disable_DFLASH();
	xcall _Disable_DFLASH
	.dbline -2
L70:
	.dbline 0 ; func end
	adiw R28,4
	ld R20,y+
	ret
	.dbsym l Erase_Sector_Protection_Command 0 A[4:4]c
	.dbsym r i 20 c
	.dbend
	.area lit(rom, con, rel)
L77:
	.byte 61,42
	.byte 127,252
	.area text(rom, con, rel)
	.dbfile E:\item\car\AT45DB041D\AT45DB041D.c
	.dbfunc e DF_Program_Sector_Protection_Register _DF_Program_Sector_Protection_Register fV
; Program_Sector_Protection_Command -> y+0
;              i -> R20
; Sector_Protection_Register -> R10,R11
	.even
_DF_Program_Sector_Protection_Register::
	xcall push_xgset300C
	movw R10,R16
	sbiw R28,4
	.dbline -1
	.dbline 281
; }
; /************************************************************
; *设置扇区保护
; *注意:会改变BUFFER1中的内容
; *Sector_Protection_Register:数组中的0~7字节对对应0~7个扇区(0xFF:写保护)(0x00:擦除保护)
; 
; The Sector Protection Register can be reprogrammed while the sector protection enabled or dis-
; abled. Being able to reprogram the Sector Protection Register with the sector protection enabled
; allows the user to temporarily disable the sector protection to an individual sector rather than
; disabling sector protection completely
; ************************************************************/
; void DF_Program_Sector_Protection_Register(unsigned char *Sector_Protection_Register)
; {
	.dbline 282
;   unsigned char Program_Sector_Protection_Command[4]={0x3D,0x2A,0x7F,0xFC};//设置扇区保护操作码
	ldi R24,<L77
	ldi R25,>L77
	movw R30,R28
	ldi R16,4
	ldi R17,0
	st -y,R31
	st -y,R30
	st -y,R25
	st -y,R24
	xcall asgncblk
	.dbline 285
;   unsigned char i;
; 
;   DF_Check_Busy_State();
	xcall _DF_Check_Busy_State
	.dbline 286
;   Enable_DFLASH();
	xcall _Enable_DFLASH
	.dbline 287
;   for(i=0;i<4;i++)
	clr R20
	xjmp L81
L78:
	.dbline 288
;   {
	.dbline 289
;       SPI_Write_Byte(Program_Sector_Protection_Command[i]);//写设置扇区保护操作码
	movw R24,R28
	mov R30,R20
	clr R31
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	xcall _SPI_Write_Byte
	.dbline 290
;   }
L79:
	.dbline 287
	inc R20
L81:
	.dbline 287
	cpi R20,4
	brlo L78
X16:
	.dbline 291
;   for(i=0;i<8;i++)
	clr R20
	xjmp L85
L82:
	.dbline 292
;   {
	.dbline 293
;       SPI_Write_Byte(Sector_Protection_Register[i]);//写设置扇区保护数据
	mov R30,R20
	clr R31
	add R30,R10
	adc R31,R11
	ldd R16,z+0
	xcall _SPI_Write_Byte
	.dbline 294
;   }
L83:
	.dbline 291
	inc R20
L85:
	.dbline 291
	cpi R20,8
	brlo L82
X17:
	.dbline 295
;   Disable_DFLASH();
	xcall _Disable_DFLASH
	.dbline -2
L76:
	.dbline 0 ; func end
	adiw R28,4
	xjmp pop_xgset300C
	.dbsym l Program_Sector_Protection_Command 0 A[4:4]c
	.dbsym r i 20 c
	.dbsym r Sector_Protection_Register 10 pc
	.dbend
	.area lit(rom, con, rel)
L87:
	.byte 50,0
	.byte 0,0
	.area text(rom, con, rel)
	.dbfile E:\item\car\AT45DB041D\AT45DB041D.c
	.dbfunc e DF_Read_Sector_Protection_Register _DF_Read_Sector_Protection_Register fV
; Read_Sector_Protection_Register_Command -> y+0
;              i -> R20
; Sector_Protection_Register -> R10,R11
	.even
_DF_Read_Sector_Protection_Register::
	xcall push_xgset300C
	movw R10,R16
	sbiw R28,4
	.dbline -1
	.dbline 308
; }
; /************************************************************
; *读取扇区保护寄存器内容(返回8个字节,对应8个扇区的情况)
; ---------------------------------------
; |Sector Number |0 (0a, 0b)  |1 to 7   |
; ---------------------------------------
; |Protected	   |            | FFH     |
; ----------------   See PDF  -----------
; |Unprotected   |            | 00H	  |
; ---------------------------------------
; ************************************************************/
; void DF_Read_Sector_Protection_Register(unsigned char *Sector_Protection_Register)
; {
	.dbline 309
;   unsigned char Read_Sector_Protection_Register_Command[4]={0x32,0,0,0};
	ldi R24,<L87
	ldi R25,>L87
	movw R30,R28
	ldi R16,4
	ldi R17,0
	st -y,R31
	st -y,R30
	st -y,R25
	st -y,R24
	xcall asgncblk
	.dbline 312
;   unsigned char i;
; 
;   DF_Check_Busy_State();
	xcall _DF_Check_Busy_State
	.dbline 313
;   Enable_DFLASH();
	xcall _Enable_DFLASH
	.dbline 315
; 
;   for(i=0;i<4;i++)//write
	clr R20
	xjmp L91
L88:
	.dbline 316
;   {
	.dbline 317
;     SPI_Write_Byte(Read_Sector_Protection_Register_Command[i]);
	movw R24,R28
	mov R30,R20
	clr R31
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	xcall _SPI_Write_Byte
	.dbline 318
;   }
L89:
	.dbline 315
	inc R20
L91:
	.dbline 315
	cpi R20,4
	brlo L88
X18:
	.dbline 319
;   for(i=0;i<8;i++)//read
	clr R20
	xjmp L95
L92:
	.dbline 320
;   {
	.dbline 321
;     Sector_Protection_Register[i] = SPI_Read_Byte(0);
	clr R16
	xcall _SPI_Read_Byte
	mov R30,R20
	clr R31
	add R30,R10
	adc R31,R11
	std z+0,R16
	.dbline 322
;   }
L93:
	.dbline 319
	inc R20
L95:
	.dbline 319
	cpi R20,8
	brlo L92
X19:
	.dbline 323
;   Disable_DFLASH();
	xcall _Disable_DFLASH
	.dbline -2
L86:
	.dbline 0 ; func end
	adiw R28,4
	xjmp pop_xgset300C
	.dbsym l Read_Sector_Protection_Register_Command 0 A[4:4]c
	.dbsym r i 20 c
	.dbsym r Sector_Protection_Register 10 pc
	.dbend
	.area lit(rom, con, rel)
L97:
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
L98:
	.byte 1,1
	.byte 1,1
	.byte 1,1
	.byte 1,1
	.area text(rom, con, rel)
	.dbfile E:\item\car\AT45DB041D\AT45DB041D.c
	.dbfunc e DF_Cancel_Sector_Protection _DF_Cancel_Sector_Protection fc
; Sector_Protection_Register_for_Write -> y+8
;              j -> R20
; Sector_Protection_Register_for_Read -> y+0
;              i -> R22,R23
	.even
_DF_Cancel_Sector_Protection::
	xcall push_xgsetF000
	sbiw R28,16
	.dbline -1
	.dbline 330
; }
; /************************************************************
; *取消所有扇区保护
; *返回1表示成功取消扇区所以保护
; ************************************************************/
; unsigned char DF_Cancel_Sector_Protection(void)
; {
	.dbline 331
;   unsigned char Sector_Protection_Register_for_Write[8]={0,0,0,0,0,0,0,0};//写入0为去保护
	ldi R24,<L97
	ldi R25,>L97
	movw R30,R28
	adiw R30,8
	ldi R16,8
	ldi R17,0
	st -y,R31
	st -y,R30
	st -y,R25
	st -y,R24
	xcall asgncblk
	.dbline 332
;   unsigned char Sector_Protection_Register_for_Read[8]={1,1,1,1,1,1,1,1};//防止默认值为0
	ldi R24,<L98
	ldi R25,>L98
	movw R30,R28
	ldi R16,8
	ldi R17,0
	st -y,R31
	st -y,R30
	st -y,R25
	st -y,R24
	xcall asgncblk
	.dbline 334
;   unsigned int i;
;   unsigned char j=1;
	ldi R20,1
	.dbline 336
;   //使能扇区保护
;   DF_Enable_Sector_Protection();
	xcall _DF_Enable_Sector_Protection
	.dbline 339
;   //设置扇区保护
; 
;   DF_Program_Sector_Protection_Register(Sector_Protection_Register_for_Write);
	movw R16,R28
	subi R16,248  ; offset = 8
	sbci R17,255
	xcall _DF_Program_Sector_Protection_Register
	.dbline 341
;   //读取扇区保护寄存器内容
;   DF_Read_Sector_Protection_Register(Sector_Protection_Register_for_Read);
	movw R16,R28
	xcall _DF_Read_Sector_Protection_Register
	.dbline 343

⌨️ 快捷键说明

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