📄 getinput.c
字号:
#include <21020.h>
#include "rtdsp.h"
/* c-code to support circular input FIFO 5-4-94 PME */
/* getinput - function to get one input sample from A/D */
extern void int_enable(int);
extern int int_flag;
float getinput()
{
float x;
static int in_int_flag = 0; /* input flag to start interupts */
static int flag = 0; /* 2 samples ready flag */
static int k;
register int j;
int pout;
if(flag) {
x = (float) (k >> 16);
flag = 0;
}
else {
/* if this routine has never been called then start up interupts */
if(!in_int_flag) {
int_enable(0);
/* record/play mode FLAG1 and FLAG3 */
set_flag(SET_FLAG1,SET_FLAG);
set_flag(SET_FLAG3,SET_FLAG);
in_int_flag = 1;
}
/* keep checking the out pointer until there are some samples in FIFO */
/* find number of samples in FIFO, take care of circular buffer problems */
do {
asm volatile("bit set mode1 0x18; nop; \
r0 = i4; /* -out pointer */
r0 = -r0, i2 = i3; /* in pointer */
m2 = r0;
modify(i2,m2); /* in-out */
%0 = i2;
bit clr mode1 0x18; nop;" : "=d" (pout) : );
} while(pout < 10);
/* get 2 consecutive samples from FIFO (circular buffer) */
asm volatile("bit set mode1 0x18; nop;
%0 = dm(i4,m1);
bit clr mode1 0x18; nop;" : "=d" (j) : );
k = j;
j = j << 16; /* get sign bit */
x = (float) (j >> 16);
flag = 1;
}
return(x);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -