📄 isd4002.c
字号:
#include "derivative.h" /* include peripheral declarations */
#include "ISD4002.h"
#define setReg8(RegName, val) (RegName = (byte)(val))
#define SETPLAY 0xE0
void powerUpISD()
{
while(!SPI1S_SPTEF)
SPI1D = 0x20;
}
void SPI1Init()
{
/* SPI1C1: SPIE=0,SPE=1,SPTIE=0,MSTR=1,CPOL=0,CPHA=1,SSOE=1,LSBFE=1 */
setReg8(SPI1C1, 0x53); /* Disable the SPI1 module clearing the SPRF flag */
/* SPI1C2: ??=0,??=0,??=0,MODFEN=1,BIDIROE=1,??=0,SPISWAI=1,SPC0=0 */
setReg8(SPI1C2, 0x1A);
/* SPI1BR: ??=0,SPPR2=1,SPPR1=1,SPPR0=1,??=0,SPR2=1,SPR1=1,SPR0=1 */
setReg8(SPI1BR, 0x77);
powerUpISD();
stopPlay();
}
void play(unsigned int addr)
{
unsigned int addrP;
addrP = addr;
while(!SPI1S_SPTEF);
SPI1D = (byte)(addrP%256);
while(!SPI1S_SPTEF);
SPI1D = ((byte)(addrP/256)&0x07)|(SETPLAY&0xF8);
}
void stopPlay()
{
while(!SPI1S_SPTEF);
SPI1D = 0x30;
}
void playCurrentAddr()
{
while(!SPI1S_SPTEF);
SPI1D = 0xF0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -