|
查看: 1033|回复: 3
|
请问各位高手知道这是什么程序编码吗?
[复制链接]
|
|
|
请问各位高手知道这是什么程序编码(在网上找到的)吗?我是要用C programming. 看起来很像,但是有些 command在C 找不到。我的C compiler 是CCS C Compiler.。有些像 uchar, sbit, uint, 是什么?谢谢!以下是那个程序的一部分:
发一个ISD1760的录放音程序。
/**************************************************************************
* SPI操作ISD1760
* SPI操作ISD1760
**************************************************************************/
#include<SPI.H>
uchar bdata SR0_L;
uchar bdata SR0_H;
uchar bdata SR1;
uchar ID,APCL=0,APCH=0;
/**************************************************************************
* 函数原型: void ISD_Init(void);
* 功 能: 初始化
**************************************************************************/
void ISD_Init(void){
ISD_Reset();
do{
ISD_PU();
RdStatus();
DogReset();
}while((SR0_L&0x01)||(!(SR1&0x01))); //if(SR0_L^0==1){system Err}<CMD_Err==1>
SBUF=RD_DevID();//读取芯片ID,----1760为0xa0
ClrInt();
ISD_WR_APC2(0xaf);
RdAPC();
}
/**************************************************************************
* 函数原型: void ClrInt(void);
* 功 能: 清除中断
**************************************************************************/
void ClrInt(void){
ISD_SendData(CLI_INT);
ISD_SendData(0x00);
SS=1;
delay_ms(10); //延迟10ms
}
/**************************************************************************
* 函数原型: void ISD_WR_APC2(uchar voiceValue);
* 功 能: 设置APC2
**************************************************************************/
void ISD_WR_APC2(uchar voiceValue){
ISD_SendData(WR_APC2);
ISD_SendData(0xa8|voiceValue); //0xa8声音最大,0xaf声音最小
ISD_SendData(0x0c); //D11=1,在SETPLAY模式下,执行到EOM自动结束。或者在连续两个SET_PLAY命令后,执行到第一个EOM自动跳到第二段开始
SS=1;
delay_ms(10); //延迟10ms
ISD_WR_NVCFG(); //永久写入寄存器
}
/**************************************************************************
* 函数原型: void ISD_WR_NVCFG(void);
* 功 能: 永久写入寄存器
**************************************************************************/
void ISD_WR_NVCFG(void){
ISD_SendData(WR_NVCFG);
ISD_SendData(0x00);
SS=1;
delay_ms(10); //延迟10ms
}
/**************************************************************************
* 函数原型: void GetToneAdd(uchar cNum, Uint * ipStartAdd, Uint * ipEndAdd);
* 功 能: 取出当前语音的首末地址
**************************************************************************/
/*
void GetToneAdd(uchar cNum, uint * ipStartAdd, uint * ipEndAdd){
*ipStartAdd=caToneAdd[cNum*2];
*ipEndAdd=caToneAdd[cNum*2+1];
}
/**************************************************************************
* 函数原型: void SetPLAY(uchar cNum);
* 功 能: 定点播放
**************************************************************************/
void SetPLAY(uchar cNum){
uint Add_ST, Add_ED;
uchar Add_ST_H, Add_ST_L, Add_ED_H, Add_ED_L;
do{
RdStatus();
DogReset();
}while((SR0_L&0x01)||(!(SR1&0x01))); //if(SR0_L^0==1){system Err}<CMD_Err==1>
ClrInt();
GetToneAdd(cNum, &Add_ST, &Add_ED);
Add_ST_L=(uchar)(Add_ST&0x00ff);
Add_ST_H=(uchar)((Add_ST>>8)&0x00ff);
Add_ED_L=(uchar)(Add_ED&0x00ff);
Add_ED_H=(uchar)((Add_ST>>8)&0x00ff);
/*
delay_ms(1);
SBUF=Add_ST_L;
delay_ms(1);
SBUF=Add_ST_H;
delay_ms(1);
SBUF=Add_ED_L;
delay_ms(1);
SBUF=Add_ED_H;
delay_ms(1);
*/
ISD_SendData(SET_PLAY);
ISD_SendData(0x00);
ISD_SendData(Add_ST_L); //S7:S0 开始地址
ISD_SendData(Add_ST_H); //S10:S8
ISD_SendData(Add_ED_L); //E7:E0 结束地址
ISD_SendData(Add_ED_H); //E10:E8
ISD_SendData(0x00);
SS=1;
delay_ms(10); //延迟10ms
do{
RdStatus();
DogReset();
}while((SR0_L&0x01)||((SR1&0x04))); //if(SR0_L^0==1){system Err}<CMD_Err==1>
}
/**************************************************************************
* 函数原型: void SetREC(uchar cNum);
* 功 能: 定点录音
**************************************************************************/
void SetREC(uchar cNum){
uint Add_ST, Add_ED;
uchar Add_ST_H, Add_ST_L, Add_ED_H, Add_ED_L;
do{
RdStatus();
DogReset();
}while((SR0_L&0x01)||(!(SR1&0x01))); //if(SR0_L^0==1){system Err}<CMD_Err==1>
ClrInt();
GetToneAdd(cNum, &Add_ST, &Add_ED);
Add_ST_L=(uchar)(Add_ST&0x00ff);
Add_ST_H=(uchar)((Add_ST>>8)&0x00ff);
Add_ED_L=(uchar)(Add_ED&0x00ff);
Add_ED_H=(uchar)((Add_ST>>8)&0x00ff);
ISD_SendData(SET_REC);
ISD_SendData(0x00);
ISD_SendData(Add_ST_L); //S7:S0 开始地址
ISD_SendData(Add_ST_H); //S10:S8
ISD_SendData(Add_ED_L); //E7:E0 结束地址
ISD_SendData(Add_ED_H); //E10:E8
ISD_SendData(0x00);
SS=1;
delay_ms(10); //延迟10ms
do{
RdStatus();
DogReset();
// }while((SR0_L&0x01)||((SR1&0x08))); //if(SR0_L^0==1){system Err}<CMD_Err==1>
}while((SR0_L&0x01)||(!(SR1&0x01))); //if(SR0_L^0==1){system Err}<CMD_Err==1>
}
/**************************************************************************
* 函数原型: void SetERASE(uchar cNum);
* 功 能: 定点删除,容易破坏存储结构(CMA),所以不用
**************************************************************************/
/*
void SetERASE(uchar cNum){
uchar Add_ST_H, Add_ST_L, Add_ED_H, Add_ED_L;
Add_ST_L=(uchar)(Add_ST&0xff);
Add_ST_H=(uchar)(Add_ST>>8);
Add_ED_L=(uchar)(Add_ED&0xff);
Add_ED_H=(uchar)(Add_ED>>8);
ISD_SendData(SET_ERASE);
ISD_SendData(0x00);
ISD_SendData(Add_ST_L); //S7:S0 开始地址
ISD_SendData(Add_ST_H); //S10:S8
ISD_SendData(Add_ED_L); //E7:E0 结束地址
ISD_SendData(Add_ED_H); //E10:E8
ISD_SendData(0x00);
// SS=1;
// delay_ms(120);
}
/**************************************************************************
* 函数原型: void Erase_All(void);
* 功 能: 全部删除
**************************************************************************/
void Erase_All(void){
ISD_SendData(G_ERASE);
ISD_SendData(0x00);
SS=1;
delay_ms(100); //延迟10ms
}
/**************************************************************************
* END
* END
**************************************************************************/
以下是SPI.H
#ifndef _SPIEX_
#define _SPIEX_
#include<STC89C58.h>
#include "typedef.h"
#define PU 0x01
#define STOP 0x02
#define RESET 0x03
#define CLI_INT 0x04
#define RD_STATUS 0x05
#define RD_PLAY_PTR 0x06
#define PD 0x07
#define RD_REC_PTR 0x08
#define RD_DEVID 0x09
#define G_ERASE 0x43
#define RD_APC 0x44
#define WR_APC1 0x45
#define WR_APC2 0x65
#define WR_NVCFG 0x46
#define CHK_MEM 0x49
#define SET_PLAY 0x80
#define SET_REC 0x81
#define SET_ERASE 0x82
#define HIGH 1
#define LOW 0
/*
#define RIGHT 1
#define ERROR 0
//#define SET_BIT(x,y) (x|=(1<<y)) //x的y位置1
//#define CLR_BIT(x,y) (x&=~(1<<y)) //清x的y位
//#define GET_BIT(x,y) (x&(1<<y)) //读x的y位
sbit INT_1700 = SR0_L^4;
sbit EOM = SR0_L^3;
sbit PU_1700 = SR0_L^2;
sbit FULL = SR0_L^1;
sbit CMD_ERR = SR0_L^0;
sbit REC_1700 = SR1^3;
sbit PLAY_1700 = SR1^2;
sbit ERASE_1700 = SR1^1;
sbit RDY = SR1^0;
|
|
|
|
|
|
|
|
|
|
|
发表于 14-3-2009 09:25 PM
|
显示全部楼层
uchar 不就是unsigned char咯。。
uint = unsigned int
你真的要一点都不懂还要抄吗?debug的时候你不就死定..
#include<STC89C58.h>
你应该没有这个header, 看样子是特定microcontroller的瓜
[ 本帖最后由 yeenfei 于 14-3-2009 09:28 PM 编辑 ] |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 15-3-2009 01:14 PM
|
显示全部楼层
回复 2# yeenfei 的帖子
嗨,谢谢你。没办法咯,我对写程序很差。应该不会抄,因为我用的microcontrolle 不一样,我用PIC,CCS C Compiler. 只是参考而已。因为找到资料,unchar = unicode char ,所以就不确定是不是unsigned char 咯!有什么办法能在短时间内明白那些程序? |
|
|
|
|
|
|
|
|
|
|
发表于 18-3-2009 08:00 PM
|
显示全部楼层
回复 3# cincailo 的帖子
没有捷径的。。。用眼睛看咯
你确定你的资料对吗?unicode都是double byte 的,就是说1 unicode = 2 byte = 16bit, 记得不要搞错哦 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|