📄 main.c
字号:
#include "g723_5410cfg.h"
#define mcbsp_init 0x71 /* if *mcbsp_init==0xaa55, then transmit INT for init 'AC01 */
#define mcbsp_reg 0x72
#define dxr10 0x23 /* McBSP0' transmit REG */
#define drr10 0x21 /* McBSP0' receive REG */
int Input_pipe_size; /* save PIP_input 's data frame size ! */
int *Input_pipe_addr; /* save PIP_input 's data address */
int Output_pipe_size; /* save PIP_output 's data frame size ! */
int *Output_pipe_addr; /* save PIP_output 's data address */
int *ptr_drr,*ptr_dxr;
void init_des();
main()
{
LOG_printf(&trace,"Program start ......\n");
ptr_drr=(int *)drr10; // 串口接收寄存器
ptr_dxr=(int *)dxr10; // 串口发送寄存器
if(PIP_getWriterNumFrames(&PIP_input) > 0) // 检查输入管道有空帧吗?
PIP_alloc(&PIP_input); // 有则分配一个帧
else
{ LOG_printf(&trace,"PIP_input have not free frame !\n");exit(0); }
Input_pipe_addr = PIP_getWriterAddr(&PIP_input); // 返回数据帧的起始地址
Input_pipe_size = PIP_getWriterSize(&PIP_input); // 返回数据帧的大小
Output_pipe_size = 0;
init_des();
}
void reader() // PIP_input object 's NoticeReader function !
{
SWI_post(&SWI0); // start processing function !
}
void processing()
{
Uns *src, *dst;
Uns size;
/* 从一个数据管道获得输入数据,并在另外一个数据管道中分配空帧 */
PIP_get(&PIP_input);
PIP_alloc(&PIP_output);
/* 复制输入数据到输出管道中 */
src = PIP_getReaderAddr(&PIP_input);
dst = PIP_getWriterAddr(&PIP_output);
size = PIP_getReaderSize(&PIP_input);
PIP_setWriterSize(&PIP_output,size);
for (; size > 0; size--)
*dst++ = *src++;
/* 输出数据,释放输入的数据帧 */
PIP_put(&PIP_output);
PIP_free(&PIP_input);
}
void receive()
{
if(Input_pipe_size == 0) // 当输入通道的数据帧被写满时
{
PIP_put(&PIP_input); // 将数据帧返还数据管道,并调用读通知函数
if(PIP_getWriterNumFrames(&PIP_input) > 0)
PIP_alloc(&PIP_input); // 再分配一个空帧,为下一次数据输入作准备
else
{ LOG_printf(&trace,"PIP_input have not free frame (in receive ISR)!\n");
exit(-1);
}
Input_pipe_addr = PIP_getWriterAddr(&PIP_input);
Input_pipe_size = PIP_getWriterSize(&PIP_input);
}
*Input_pipe_addr++ = *ptr_drr; // 直接从串口接收寄存器读入
Input_pipe_size--; // 数据帧的容量减1
}
void transmit()
{
int *ptr, *ptr_dxr,*in;
ptr=(int *)mcbsp_init;
ptr_dxr=(int *)dxr10;
if(*ptr == 0xaa55) // if *mcbsp_init==0xaa55, this INT for init of AC01
{
in=(int *)mcbsp_reg;
*ptr_dxr = *in; // when init AC01, the transmit data is put into A
if( *ptr_dxr == 0x800) // when a=0x800, the last init data !
*ptr=0;
return;
}
else
{
if(Output_pipe_size == 0)
{
if(PIP_getReaderNumFrames(&PIP_output) > 0) // 是否输出管道中有数据?
{ PIP_get(&PIP_output); // 若有,则从数据管道读出数据帧
Output_pipe_addr = PIP_getReaderAddr(&PIP_output);
Output_pipe_size = PIP_getReaderSize(&PIP_output);
*ptr_dxr = *Output_pipe_addr++ ;
Output_pipe_size--;
return;
}
else
{ *ptr_dxr = 0; return; }
}
else
{
*ptr_dxr = *Output_pipe_addr++ ; // 数据帧没有读完时继续使用
Output_pipe_size--;
if(Output_pipe_size == 0)
PIP_free(&PIP_output); // 释放数据帧
return;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -