📄 cs5532.c
字号:
/****************************************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)
{
uint08 i;
for(i=0;i<8;i++)
{
if(dat&0x80)
SET_SDI();
else
CLR_SDI();
NOP();NOP();
SET_SCK();
NOP();NOP();
CLR_SCK();
dat<<=1;
NOP();
}
SET_SDI();
}
/**********************************************************************
functionName:uint08 cs5532_rd_byte(void)
description:
**********************************************************************/
uint08 cs5532_rd_byte(void)
{
uint08 i;
uint08 temp=0;
for(i=0;i<8;i++)
{
temp<<=1;
SET_SCK();
NOP();NOP();
if(STU_SDO)
temp|=1;
CLR_SCK();
NOP();NOP();NOP();
}
return temp;
}
/**********************************************************************
functionName:void cs5532_soft_rst(void)
description:
**********************************************************************/
void cs5532_soft_rst(void)
{
uint08 i;
for(i=0;i<15;i++)
{
cs5532_wr_byte(0xFF);
}
cs5532_wr_byte(0xFE);
}
/**********************************************************************
functionName:
description:
**********************************************************************/
void cs5532_wr_reg(uint08 cmd,uint32 dat)
{
uint08 temp[4];
temp[0]=dat>>24;
temp[1]=dat>>16;
temp[2]=dat>>8;
temp[3]=dat;
cs5532_wr_byte(cmd);
cs5532_wr_byte(temp[0]);
cs5532_wr_byte(temp[1]);
cs5532_wr_byte(temp[2]);
cs5532_wr_byte(temp[3]);
}
/**********************************************************************
functionName:void cs5532_rd_reg(uint08 cmd)
description:
**********************************************************************/
void cs5532_rd_reg(uint08 cmd)
{
cs5532_wr_byte(cmd);
cs5532_buf[0]=cs5532_rd_byte();
cs5532_buf[1]=cs5532_rd_byte();
cs5532_buf[2]=cs5532_rd_byte();
cs5532_buf[3]=cs5532_rd_byte();
}
/**********************************************************************
functionName:
description:
**********************************************************************/
void cs5532_init(void)
{
ms_delay(50); //等待电源稳定
cs5532_soft_rst(); //软件复位
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -