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

📄 cs5532.s

📁 CS5532的驱动程序
💻 S
字号:
	.module cs5532.c
	.area text(rom, con, rel)
	.dbfile G:\CS5532\firmware\cs5532.c
	.dbfunc e cs5532_wr_byte _cs5532_wr_byte fV
;              i -> R20
;            dat -> R16
	.even
_cs5532_wr_byte::
	xcall push_gset1
	.dbline -1
	.dbline 27
; /****************************************Copyright (c)**************************************************
; **                               	
; **                                     
; **                                 	
; ** 文   件   名: ca5532.c
; ** 最后修改日期: 2007-10-8 9:40
; ** 描        述: cs5532驱动程序
; ** 版	     本: V1.0
; ** 主  控  芯 片:M16  晶振频率:7.37MHZ, 
; ** IDE:ICCAVR 6.31
; **********************************************************************************************************/
; #include <iom16v.h>
; #include <macros.h>
; 
; #include "DEFINE.H"
; #include "CS5532.H"
; #include "DELAY.H"
; 
; uint08 cs5532_buf[4];
; 
; 
; /**********************************************************************
; functionName:void cs5532_wr_byte(uint08 dat)
; description:
; **********************************************************************/
; void cs5532_wr_byte(uint08 dat)
; {
	.dbline 30
; 	uint08 i;
; 	
; 	for(i=0;i<8;i++)
	clr R20
	xjmp L5
L2:
	.dbline 31
; 	{
	.dbline 32
; 		if(dat&0x80)
	sbrs R16,7
	rjmp L6
	.dbline 33
; 		SET_SDI();
	sbi 0x1b,0
	xjmp L7
L6:
	.dbline 35
; 		else
; 		CLR_SDI();
	cbi 0x1b,0
L7:
	.dbline 36
	nop
	.dbline 36
	nop
	.dbline 37
	sbi 0x1b,1
	.dbline 38
	nop
	.dbline 38
	nop
	.dbline 39
	cbi 0x1b,1
	.dbline 40
	lsl R16
	.dbline 41
	nop
	.dbline 42
L3:
	.dbline 30
	inc R20
L5:
	.dbline 30
	cpi R20,8
	brlo L2
	.dbline 43
; 		NOP();NOP();
; 		SET_SCK();
; 		NOP();NOP();
; 		CLR_SCK();
; 		dat<<=1;
; 		NOP();
; 	}
; 	SET_SDI();
	sbi 0x1b,0
	.dbline -2
L1:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbsym r dat 16 c
	.dbend
	.dbfunc e cs5532_rd_byte _cs5532_rd_byte fc
;           temp -> R16
;              i -> R18
	.even
_cs5532_rd_byte::
	.dbline -1
	.dbline 55
; }
; 
; 
; 
; 
; 
; /**********************************************************************
; functionName:uint08 cs5532_rd_byte(void)
; description:
; **********************************************************************/
; uint08 cs5532_rd_byte(void)
; {
	.dbline 57
; 	uint08 i;
; 	uint08 temp=0;
	clr R16
	.dbline 59
; 	
; 	for(i=0;i<8;i++)
	clr R18
	xjmp L12
L9:
	.dbline 60
; 	{
	.dbline 61
; 		temp<<=1;
	lsl R16
	.dbline 62
; 		SET_SCK();
	sbi 0x1b,1
	.dbline 63
; 		NOP();NOP();
	nop
	.dbline 63
	nop
	.dbline 64
; 		if(STU_SDO)
	.dbline 65
; 		temp|=1;
	ori R16,1
L13:
	.dbline 66
	cbi 0x1b,1
	.dbline 67
	nop
	.dbline 67
	nop
	.dbline 67
	nop
	.dbline 68
L10:
	.dbline 59
	inc R18
L12:
	.dbline 59
	cpi R18,8
	brlo L9
	.dbline 69
; 		CLR_SCK();
; 		NOP();NOP();NOP();
; 	}
; 	return temp;
	.dbline -2
L8:
	.dbline 0 ; func end
	ret
	.dbsym r temp 16 c
	.dbsym r i 18 c
	.dbend
	.dbfunc e cs5532_soft_rst _cs5532_soft_rst fV
;              i -> R20
	.even
_cs5532_soft_rst::
	xcall push_gset1
	.dbline -1
	.dbline 78
; }
; 
; 
; /**********************************************************************
; functionName:void cs5532_soft_rst(void)
; description:
; **********************************************************************/
; void cs5532_soft_rst(void)
; {
	.dbline 80
; 	uint08 i;
; 	for(i=0;i<15;i++)
	clr R20
	xjmp L19
L16:
	.dbline 81
	.dbline 82
	ldi R16,255
	xcall _cs5532_wr_byte
	.dbline 83
L17:
	.dbline 80
	inc R20
L19:
	.dbline 80
	cpi R20,15
	brlo L16
	.dbline 84
; 	{
; 		cs5532_wr_byte(0xFF);
; 	}
; 	cs5532_wr_byte(0xFE);
	ldi R16,254
	xcall _cs5532_wr_byte
	.dbline -2
L15:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbend
	.dbfunc e cs5532_wr_reg _cs5532_wr_reg fV
;           temp -> y+0
;            dat -> y+6
;            cmd -> R20
	.even
_cs5532_wr_reg::
	st -y,r19
	st -y,r18
	xcall push_gset1
	mov R20,R16
	sbiw R28,4
	.dbline -1
	.dbline 93
; }
; 
; 
; /**********************************************************************
; functionName:
; description:
; **********************************************************************/
; void cs5532_wr_reg(uint08 cmd,uint32 dat)
; {
	.dbline 95
; 	uint08 temp[4];
; 	temp[0]=dat>>24;
	ldi R24,24
	ldi R25,0
	movw R30,R28
	ldd R2,z+6
	ldd R3,z+7
	ldd R4,z+8
	ldd R5,z+9
	st -y,R24
	movw R16,R2
	movw R18,R4
	xcall lsr32
	std y+0,R16
	.dbline 96
; 	temp[1]=dat>>16;
	movw R30,R28
	ldd R2,z+6
	ldd R3,z+7
	ldd R4,z+8
	ldd R5,z+9
	movw R2,R4
	clr R4
	clr R5
	std y+1,R2
	.dbline 97
; 	temp[2]=dat>>8;
	ldi R24,8
	ldi R25,0
	movw R30,R28
	ldd R2,z+6
	ldd R3,z+7
	ldd R4,z+8
	ldd R5,z+9
	st -y,R24
	movw R16,R2
	movw R18,R4
	xcall lsr32
	std y+2,R16
	.dbline 98
; 	temp[3]=dat;
	movw R30,R28
	ldd R2,z+6
	ldd R3,z+7
	ldd R4,z+8
	ldd R5,z+9
	std y+3,R2
	.dbline 99
; 	cs5532_wr_byte(cmd);
	mov R16,R20
	xcall _cs5532_wr_byte
	.dbline 100
; 	cs5532_wr_byte(temp[0]);
	ldd R16,y+0
	xcall _cs5532_wr_byte
	.dbline 101
; 	cs5532_wr_byte(temp[1]);
	ldd R16,y+1
	xcall _cs5532_wr_byte
	.dbline 102
; 	cs5532_wr_byte(temp[2]);
	ldd R16,y+2
	xcall _cs5532_wr_byte
	.dbline 103
; 	cs5532_wr_byte(temp[3]);	 
	ldd R16,y+3
	xcall _cs5532_wr_byte
	.dbline -2
L20:
	adiw R28,4
	xcall pop_gset1
	adiw R28,2
	.dbline 0 ; func end
	ret
	.dbsym l temp 0 A[4:4]c
	.dbsym l dat 6 l
	.dbsym r cmd 20 c
	.dbend
	.dbfunc e cs5532_rd_reg _cs5532_rd_reg fV
;            cmd -> R20
	.even
_cs5532_rd_reg::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 113
; }
; 
; 
; 
; /**********************************************************************
; functionName:void cs5532_rd_reg(uint08 cmd)
; description:
; **********************************************************************/
; void cs5532_rd_reg(uint08 cmd)
; {
	.dbline 114
; 	cs5532_wr_byte(cmd);
	mov R16,R20
	xcall _cs5532_wr_byte
	.dbline 115
; 	cs5532_buf[0]=cs5532_rd_byte();
	xcall _cs5532_rd_byte
	sts _cs5532_buf,R16
	.dbline 116
; 	cs5532_buf[1]=cs5532_rd_byte();
	xcall _cs5532_rd_byte
	sts _cs5532_buf+1,R16
	.dbline 117
; 	cs5532_buf[2]=cs5532_rd_byte();
	xcall _cs5532_rd_byte
	sts _cs5532_buf+2,R16
	.dbline 118
; 	cs5532_buf[3]=cs5532_rd_byte();
	xcall _cs5532_rd_byte
	sts _cs5532_buf+3,R16
	.dbline -2
L27:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r cmd 20 c
	.dbend
	.dbfunc e cs5532_init _cs5532_init fV
	.even
_cs5532_init::
	.dbline -1
	.dbline 127
; }
; 
; 
; /**********************************************************************
; functionName:
; description:
; **********************************************************************/
; void cs5532_init(void)
; {
	.dbline 128
; 	ms_delay(50);			//等待电源稳定	
	ldi R16,50
	xcall _ms_delay
	.dbline 129
; 	cs5532_soft_rst();		//软件复位
	xcall _cs5532_soft_rst
	.dbline -2
L31:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile G:\CS5532\firmware\cs5532.c
_cs5532_buf::
	.blkb 4
	.dbsym e cs5532_buf _cs5532_buf A[4:4]c

⌨️ 快捷键说明

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