ISD2360.c 3.84 KB

#include    "ISD2360.h"

/******************************************************************************
函数名:ISD_Init
功  能:初始化ISD语音芯片
参  数:无
返回值:无
******************************************************************************/
void ISD_Init(void)
{
  Sim_SPI_Master_Start(SIM_SPI_MODE_3, SIM_SPI_MSB_FIRST);
  
  AUDIO_nCS = 0;
  Sim_SPI_Master_Byte_Write(ISD_RESET_CODE);
  AUDIO_nCS = 1;
}

/******************************************************************************
函数名:ISD_Power_Up
功  能:启动ISD语音芯片电源
参  数:无
返回值:无
******************************************************************************/
void ISD_Power_Up(void)
{
  AUDIO_nCS = 0;
  Sim_SPI_Master_Byte_Write(ISD_PWR_UP_CODE);
  AUDIO_nCS = 1;
}

/******************************************************************************
函数名:ISD_Power_Down
功  能:关闭ISD语音芯片电源
参  数:无
返回值:无
******************************************************************************/
void ISD_Power_Down(void)
{
  AUDIO_nCS = 0;
  Sim_SPI_Master_Byte_Write(ISD_PWR_DN_CODE);
  AUDIO_nCS = 1;
}

/******************************************************************************
函数名:ISD_Play_Vp
功  能:播放指定的音源
参  数:Index:音源编号
返回值:无
******************************************************************************/
void ISD_Play_Vp(uint16_t Index)
{
  AUDIO_nCS = 0;
  Sim_SPI_Master_Byte_Write(ISD_PLAY_VP_CODE);
  Sim_SPI_Master_Byte_Write((uint8_t)(Index >> 8));
  Sim_SPI_Master_Byte_Write((uint8_t)Index);
  AUDIO_nCS = 1;
}

/******************************************************************************
函数名:ISD_Stop
功  能:停止声音播放
参  数:无
返回值:无
******************************************************************************/
void ISD_Stop(void)
{
  AUDIO_nCS = 0;
  Sim_SPI_Master_Byte_Write(ISD_STOP_CODE);
  AUDIO_nCS = 1;
}

/******************************************************************************
函数名:ISD_Play_Vp_Loop
功  能:循环播放指定的音源
参  数:Index  :音源编号
        LoopCnt:循环播放的次数,0表示无限循环播放
返回值:无
******************************************************************************/
void ISD_Play_Vp_Loop(uint16_t Index, uint16_t LoopCnt)
{
  AUDIO_nCS = 0;
  Sim_SPI_Master_Byte_Write(ISD_PLAY_VP_LP_CODE);
  Sim_SPI_Master_Byte_Write((uint8_t)(Index >> 8));
  Sim_SPI_Master_Byte_Write((uint8_t)Index);
  Sim_SPI_Master_Byte_Write((uint8_t)(LoopCnt >> 8));
  Sim_SPI_Master_Byte_Write((uint8_t)LoopCnt);
  AUDIO_nCS = 1;
}

/******************************************************************************
函数名:ISD_Stop_Loop
功  能:停止循环播放
参  数:无
返回值:无
******************************************************************************/
void ISD_Stop_Loop(void)
{
  AUDIO_nCS = 0;
  Sim_SPI_Master_Byte_Write(ISD_STOP_LP_CODE);
  AUDIO_nCS = 1;
}

/******************************************************************************
函数名:ISD_Set_Volume
功  能:设置播放音量
参  数:Volume:音量(衰减)值,设为0x00(默认)时音量最大,设为0xFF时音量最小
返回值:无
******************************************************************************/
void ISD_Set_Volume(uint8_t Volume)
{
  AUDIO_nCS = 0;
  Sim_SPI_Master_Byte_Write(ISD_WR_CFG_REG_CODE);
  Sim_SPI_Master_Byte_Write(0x03);
  Sim_SPI_Master_Byte_Write(Volume);
  AUDIO_nCS = 1;
}

/******************************************************************************
函数名:ISD_Select_Channel
功  能:选择播放通道
参  数:ChNum:选择的通道:ISD_CHANNEL_0(默认)
                           ISD_CHANNEL_1
                           ISD_CHANNEL_2
                           ISD_CHANNEL_ALL
返回值:无
******************************************************************************/
void ISD_Select_Channel(uint8_t ChNum)
{
  AUDIO_nCS = 0;
  Sim_SPI_Master_Byte_Write(ISD_WR_CFG_REG_CODE);
  Sim_SPI_Master_Byte_Write(0x0C);
  Sim_SPI_Master_Byte_Write(ChNum);
  AUDIO_nCS = 1;
}