1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#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;
}