機電之家資源網(wǎng)
單片機首頁|單片機基礎(chǔ)|單片機應(yīng)用|單片機開發(fā)|單片機文案|軟件資料下載|音響制作|電路圖下載 |嵌入式開發(fā)
培訓(xùn)信息
贊助商
ISD4000系列語音芯片的C51程序
ISD4000系列語音芯片的C51程序
 更新時間:2010-1-29 16:01:08  點擊數(shù):0
【字體: 字體顏色
//ISD4004 DRIVER

#include"mcu-define.h"
#include"delay.h"
#include"isd4004.h"

sbit ISD4XXX_SCLK=P3^6;
sbit ISD4XXX_MISO =P3^4;
sbit ISD4XXX_MOSI =P3^5;
sbit ISD4XXX_SS =P3^7;


//ISD4004 命令碼
/*
指令 8位控制碼,16位地址碼 操作摘要
POWERUP 00100xxx(xxxxxxxxxxxxxxxx) 上電:等待TPUD后器件可以工作
SET PLAY 11100xxx(A15~A0) 從指令地址開始放音,須后跟PLAY指令,使放音繼續(xù)
PLAY 11110xxx(xxxxxxxxxxxxxxx) 從當前地址開始放音(直至EOM或OVF)
SET REC 10110xxx(A15~A0) 從指定地址開始錄音,須后跟REC指令,使錄音繼續(xù)
REC 110110(xxxxxxxxxxxxxxx) 從當前地址開始錄音(直至OVF或停止)
SET MC 11101xxx(A15~A0) 從指定地址開始快進,須后跟MC指令,使快進繼續(xù)
MC 11111xxx(xxxxxxxxxxxxxxx) 執(zhí)行快進,直到EOM,若再無信息,則進入OVF狀態(tài)
STOP 0x110xxx(xxxxxxxxxxxxxxx) 停止當前操作
STOP PWRDN 0X01Xxxx(xxxxxxxxxxxxxxx) 停止當前的操作并掉電
RINT 0X110xxx(xxxxxxxxxxxxxxxx) 讀狀態(tài);OVF和EOM

*/
#define ISD4XXX_POWER_UP 0x20
#define ISD4XXX_SET_PLAY 0xe0
#define ISD4XXX_PLAY 0xf0
#define ISD4XXX_SET_REC 0xb0
#define ISD4XXX_REC 0xd8
#define ISD4XXX_SET_MC 0xe8
#define ISD4XXX_MC 0xf8
#define ISD4XXX_STOP 0x30
#define ISD4XXX_STOP_PWRDN 0x10

#define ISD4XXX_RINT 0x30



unsigned char isd_spi(ISD_COMMAND * isdcommand)
{
unsigned char i;
unsigned long miso;
unsigned long mosi=(unsigned long *)isdcommand;
ISD4XXX_MISO=1;
ISD4XXX_SCLK=0;
ISD4XXX_SS=0;
miso=0;
for (i=0;i<24;i++)
{
miso<<=1;
miso |=(unsigned long )ISD4XXX_MISO;

if (mosi & 0x800000 ==0x1) ISD4XXX_MOSI =1;
else ISD4XXX_MOSI = 0;

ISD4XXX_SCLK=1;
mosi <<= 1;
ISD4XXX_SCLK=0;
}
ISD4XXX_SCLK=1;

return (char *)(miso+1);
}

void ISD4XXX_Record(unsigned int address)
{
// 1. power up
// 2. TPUD(25ms) *2;
// 3. power up;
// 4. set record address = 00;
// 5. rec command .
ISD_COMMAND isd_command;
isd_command.command_code=ISD4XXX_POWER_UP;
// isd_command.int_address=0;
isd_spi(&isd_command);
soft_delay_10ms(3);
soft_delay_10ms(3);

isd_spi(&isd_command);

isd_command.command_code=ISD4XXX_SET_REC;
isd_command.int_address=address;
isd_spi(&isd_command);

isd_command.command_code=ISD4XXX_REC ;
// isd_command.int_address=0;
isd_spi(&isd_command);
}

void ISD4XXX_Play(unsigned int address)
{
// 1. POWER UP
// 2. Delay tpuid.
// 3. SET PLAY WITH ADDRESS 0;
// 4. SEND play command.
ISD_COMMAND isd_command;
isd_command.command_code=ISD4XXX_POWER_UP;
// isd_command.int_address=0;
isd_spi(&isd_command);
soft_delay_10ms(3);

isd_command.command_code=ISD4XXX_SET_PLAY;
isd_command.int_address=address;
isd_spi(&isd_command);

isd_command.command_code=ISD4XXX_PLAY;
// isd_command.int_address=0;
isd_spi(&isd_command);
}

void ISD4XXX_Stop(void)
{
ISD_COMMAND isd_command;
isd_command.command_code=ISD4XXX_STOP;
isd_spi(&isd_command);
}

void ISD4XXX_PowerOff(void)
{
ISD_COMMAND isd_command;
isd_command.command_code=0x08;
isd_spi(&isd_command);
}

void ISD4XXX_PowerOn(void)
{
ISD_COMMAND isd_command;
isd_command.command_code=0x04;
isd_spi(&isd_command);
}


static code unsigned int address_tab[22]=
{
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21
};

void PlaySound(unsigned char index)
{

ISD4XXX_Play(address_tab[index]);
}
//end of file
  • 上一篇: AT89C2051實現(xiàn)A/D轉(zhuǎn)換的C51程序
  • 下一篇: 沒有了
  • 發(fā)表評論   告訴好友   打印此文  收藏此頁  關(guān)閉窗口  返回頂部
    熱點文章
     
    推薦文章
     
    相關(guān)文章
    網(wǎng)友評論:(只顯示最新5條。)
    關(guān)于我們 | 聯(lián)系我們 | 廣告合作 | 付款方式 | 使用幫助 | 機電之家 | 會員助手 | 免費鏈接

    點擊這里給我發(fā)消息66821730(技術(shù)支持)點擊這里給我發(fā)消息66821730(廣告投放) 點擊這里給我發(fā)消息41031197(編輯) 點擊這里給我發(fā)消息58733127(審核)
    本站提供的機電設(shè)備,機電供求等信息由機電企業(yè)自行提供,該企業(yè)負責(zé)信息內(nèi)容的真實性、準確性和合法性。
    機電之家對此不承擔(dān)任何保證責(zé)任,有侵犯您利益的地方請聯(lián)系機電之家,機電之家將及時作出處理。
    Copyright 2007 機電之家 Inc All Rights Reserved.機電之家-由機電一體化網(wǎng)更名-聲明
    電話:0571-87774297 傳真:0571-87774298
    杭州濱興科技有限公司提供技術(shù)支持

    主辦:杭州市高新區(qū)(濱江)機電一體化學(xué)會
    中國行業(yè)電子商務(wù)100強網(wǎng)站

    網(wǎng)站經(jīng)營許可證:浙B2-20080178-1