}
void WrVs1003Cmd (unsigned char addr,unsigned int cmd) { }
void SoftRstVs1003(void) {
//WrVs1003Cmd(0,0x0804); //具体功能见官方数据手册第28页(软DelayUs(5);
ReleaseCmdVs1003();
//释放
SPIsendByte(0x02); SPIsendByte(addr);
SPIsendByte((unsigned char)(cmd>>8)); SPIsendByte((unsigned char)cmd); WaitVs1003();
SelectCmdVs1003(); //片选 DelayUs(5);
SPCR = 0xdf; //打开SPI DelayUs(5);
ReleaseCmdVs1003();
//释放
SPIsendByte2(0x02); SPIsendByte2(addr);
SPIsendByte2((unsigned char)(cmd>>8)); SPIsendByte2((unsigned char)cmd);
件复位)
}
SoftWrVs1003Cmd(0,0x0804); DelayMs(10);
SoftWrVs1003Cmd(2,0x00f6); //低音 DelayMs(1);
SoftWrVs1003Cmd(3,0x9800); //倍频 DelayMs(10);
SoftWrVs1003Cmd(5,0xbb81); //采样率和通道数 DelayMs(1);
SoftWrVs1003Cmd(0x0b,0x2020); //音量 DelayMs(1);
void RstVs1003(void) { }
SoftRstVs1003();
WrVs1003Cmd(0x0b,0xffff); //音量 DelayMs(1); SelectRstVs1003(); DelayMs(10); SPIsendByte(0xff); ReleaseRstVs1003(); DelayMs(10);
//硬件复位
/*
void Sintest(void) { } */
void PlaySector(void) {
UINT16 i ;
SelectDatVs1003();
for (i=0; i<512;) {//连续发32个字节(VS1003有32字节的缓冲区)
WaitVs1003(); // 查忙 SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SelectDatVs1003(); DelayUs(5); SPIsendByte(0x53); SPIsendByte(0xef); SPIsendByte(0x6e); SPIsendByte(0x30); SPIsendByte(0); SPIsendByte(0); SPIsendByte(0); SPIsendByte(0); DelayUs(5);
ReleaseDatVs1003(); WaitVs1003();
WrVs1003Cmd(0,0x0820); //进入正弦测试
}
}
SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]); SPIsendByte(SectorBuf[i++]);
ReleaseDatVs1003();
#include \ #include
//#include
/* 定义CH375命令代码及返回状态 */ #include \/* CH375特性 */
#define CH375_BLOCK_SIZE size */
#define CH375_BLK_PER_SEC
8
/* CH375 block per sector,
64
/* CH375 maximum data block
定义CH375.c
SECTOR_SIZE/CH375_BLOCK_SIZE */
/* 以下定义适用于MCS-51单片机,其它单片机参照修改,为了提供C语言的速度需要对本程序进行优化 */ #include
DATA_BUFFER[512] _at_ 0x0000; /* CH375_DAT_PORT _at_ 0xfe04; /* CH375CH375_CMD_PORT _at_ 0xff04; /* CH375
外部RAM数据缓冲区的起始地址,长度不少于一次读写的数据长度 */
sbit CH375_INT_WIRE = 0xA0^5; /* P3.2, INT0, 连接CH375的INT#引脚,用于查询中断状态 */
/* 在P1.4连接一个LED用于监控演示程序的进度,低电平LED亮,当U盘插入后亮 */
sbit P1_4 = P1^4; #define LED_OUT_ACT( ) */
{ P1_4 = 0; }
/* P1.4 低电平驱动LED显示