Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
buf.cpp
Package: se06.rar [view]
Upload User: kepeng103
Upload Date: 2022-07-27
Package Size: 2653k
Code Size: 1k
Category:
DSP program
Development Platform:
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;
- }