附:MAIN.C
void ISD_Reset(void)
{
ISD_SendByte(CMD_1760_RESET);
ISD_SendByte(0x00);
sbnISD_SS=1;
// DelayX1ms(10);
}
void ISD_PU(void)
{
ISD_SendByte(CMD_1760_PU|0x10);
ISD_SendByte(0x00);
sbnISD_SS=1;
DelayX1ms(50);
}
void ISD_Rd_Status(void)
{
ISD_SendByte(CMD_1760_RD_STATUS);
ISD_SendByte(0x00);
ISD_SendByte(0x00);
sbnISD_SS=1;
// DelayX1ms(10);
SR0_L =ISD_SendByte(CMD_1760_RD_STATUS);
SR0_H =ISD_SendByte(0x00);
SR1 =ISD_SendByte(0x00);
sbnISD_SS=1;
// DelayX1ms(10);
}
void ISD_ClrInt(void)
{
ISD_SendByte(CMD_1760_CLI_INT);
ISD_SendByte(0x00);
sbnISD_SS=1;
// DelayX1ms(10);
}
void ISD_CHK_MEM(void)
{
ISD_SendByte(CMD_1760_CHK_MEM);
ISD_SendByte(0x00);
sbnISD_SS=1;
// DelayX1ms(10);
}
void ISD_WR_APC2(BYTE Volume)
{
ISD_SendByte(CMD_1760_WR_APC2);
ISD_SendByte(Volume); //后3位为音量
ISD_SendByte(0x04); //0x04 EOM="0",VALERT=1 ,0x 0C EOM="1"
sbnISD_SS=1;
DelayX1ms(10);
ISD_WR_NVCFG(); //永久写入寄存器 //此程序正在放音要调整音量时不要添加!!
}
void ISD_WR_NVCFG(void)
{
ISD_SendByte(CMD_1760_WR_NVCFG);
ISD_SendByte(0x00);
sbnISD_SS=1;
DelayX1ms(10);
}
void ISD_RDAPC(void)
{
ISD_SendByte(CMD_1760_RD_APC);
ISD_SendByte(0x00);
ISD_SendByte(0x00);
ISD_SendByte(0x00);
sbnISD_SS=1;
DelayX1ms(10);
SR0_L =ISD_SendByte(CMD_1760_RD_APC);
SR0_H =ISD_SendByte(0x00);
APCL =ISD_SendByte(0x00);
APCH =ISD_SendByte(0x00);
sbnISD_SS=1;
DelayX1ms(10);
}
void ISD_PD(void)
{
ISD_SendByte(CMD_1760_PD);
ISD_SendByte(0x00);
sbnISD_SS=1;
// DelayX1ms(5);
}
BYTE ISD_SendByte(BYTE BUF_ISD)
{
BYTE i;
BYTE dat="BUF"_ISD;
sbISD_SCLK=1;
sbnISD_SS=0;
for(i=0;i<8;i++)
{
sbISD_SCLK=0;
_nop_();
_nop_();
if(dat&0x01)
{
sbISD_MOSI=1;
}
else
{
sbISD_MOSI=0;
}
dat>>=1;
if(sbISD_MISO==1)
{
dat|=0x80;
}
sbISD_SCLK=1;
_nop_();
_nop_();
}
sbISD_MOSI=0;
_nop_();
return(dat);
}
BYTE ISD_RDDevID(void)
{
ISD_SendByte(CMD_1760_RD_DEVID);
ISD_SendByte(0x00);
ISD_SendByte(0x00);
sbnISD_SS=1;
DelayX1ms(10);
SR0_L =ISD_SendByte(CMD_1760_RD_DEVID);
SR0_H =ISD_SendByte(0x00);
ID =ISD_SendByte(0x00);
sbnISD_SS=1;
DelayX1ms(10);
return(ID);
}
void ISD_Init(void)
{
ISD_Reset();
ISD_PU(); //上电指令
DelayX1ms(50);
// SBUF="ISD"_RDDevID(); //读取芯片ID,----1760为0xA0
ISD_ClrInt();
ISD_CHK_MEM(); //检查环状存储器存储地址是否首尾相连
//改变1700内部存储单元或是内部寄存器的指令前,
//都要加上这个指令。
ISD_WR_APC2(Volume);//写APC寄存器,后3位为音量,此设为最大,0xA7为最小 F0
DelayX1ms(50);
// ISD_RDAPC(); //读APC寄存器
// DelayX1ms(25);
}
void ISD_GetToneAdd(BYTE cNum, WORD * ipStartAdd, WORD * ipEndAdd)
{
*ipStartAdd=aSpeech_Addr[cNum * 2];
*ipEndAdd=aSpeech_Addr[cNum * 2 + 1];
}
void ISD_SetPLAY(BYTE cNum)
{
WORD Add_ST, Add_ED;
BYTE Add_ST_H, Add_ST_L, Add_ED_H, Add_ED_L;
// ISD_Init(); //初始化
// ISD_PU();
// ISD_ClrInt(); //清中断
ISD_GetToneAdd(cNum, &Add_ST, &Add_ED); //取出当前语音的首末地址
Add_ST_L=(BYTE)(Add_ST&0x00ff);
Add_ST_H=(BYTE)((Add_ST>>8)&0x00ff);
Add_ED_L=(BYTE)(Add_ED&0x00ff);
Add_ED_H=(BYTE)((Add_ED>>8)&0x00ff);
ISD_SendByte(CMD_1760_SET_PLAY); //发送放音指令
ISD_SendByte(0x00);
ISD_SendByte(Add_ST_L); //S7:S0 开始地址
ISD_SendByte(Add_ST_H); //S10:S8
ISD_SendByte(Add_ED_L); //E7:E0 结束地址
ISD_SendByte(Add_ED_H); //E10:E8
ISD_SendByte(0x00);
sbnISD_SS=1;
}
文章评论(0条评论)
登录后参与讨论