- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
buf.cpp
资源名称:se06.rar [点击查看]
上传用户:kepeng103
上传日期:2022-07-27
资源大小:2653k
文件大小:1k
源码类别:
DSP编程
开发平台:
C/C++
- #include "..commonhal.h"
- #include "buf.h"
- #include <stdio.h>
- int16 in[2][FRAME_LENGTH];
- int16 out[2][FRAME_LENGTH];
- volatile int i,j;
- volatile int m,n;
- int last_read = 0;
- int last_write = 0;
- void buf_init(void)
- {
- i = 0;
- j = 0;
- m = 0;
- n = 0;
- last_read = 0;
- last_write = 0;
- }
- void data_in(int16 data)
- {
- static int k = 0;
- in[i][j] = data;
- if(++j == FRAME_LENGTH) {
- j = 0;
- i ^= 0x1;
- if(++k == 4) {
- k = 0;
- REG32(MCASP1_PDOUT) ^= 0x10;
- }
- }
- }
- int16 data_out(void)
- {
- static int k = 0;
- int16 data = out[m][n];
- if(++n == FRAME_LENGTH) {
- n = 0;
- m ^= 0x1;
- if(++k == 4) {
- k = 0;
- REG32(MCASP1_PDOUT) ^= 0x8;
- }
- }
- return data;
- }
- int16 *read_data(void)
- {
- int16 *data;
- while(last_read == i)
- data = in[last_read];
- last_read = i;
- return data;
- }
- void write_data(int16 *data)
- {
- while(last_write == m);
- for(int k=0; k<FRAME_LENGTH; k++)
- {out[last_write][k] = data[k];}
- last_write = m;
- }