📄 defaultisr_nonbios.c
字号:
/**********************************************************************
* File: DefaultIsr_nonBIOS.c
* Devices: TMS320F2812
* Author:
* History:
*
**********************************************************************/
#include "DSP281x_Device.h"
extern int IntCounter;
extern int SAMPLE[6][132];
extern int samp_buff[6][64];
extern int CAL_FINISH;
extern int HAR_FINISH;
extern int DATA_RDY;
extern int BUFF_RDY;
/*********************************************************************/
SCI_A_P()
{
static int i = 0;
static int scia_buffer[8];
while (SciaRegs.SCIFFRX.bit.RXFIFST >0)
{
scia_buffer[i] = SciaRegs.SCIRXBUF.all;
i++;
if (i==8)
{
for (i=0;i<8;i++) SciaRegs.SCITXBUF = scia_buffer[i] + 1;
i = 0;
}
}
}
/*********************************************************************/
SCI_B_P()
{
static int i = 0;
static int scib_buffer[8];
if(TR_485 ==0) // Receive enabled
{
while (ScibRegs.SCIFFRX.bit.RXFIFST >0)
{
scib_buffer[i] = ScibRegs.SCIRXBUF.all;
i++;
if (i==8)
{
TR_485 = 1; // Enable transmit
for (i=0;i<8;i++) ScibRegs.SCITXBUF = scib_buffer[i] + 1;
i = 0;
}
}
}
else // Transmit enabled
{
if (ScibRegs.SCICTL2.bit.TXEMPTY ==1) TR_485 = 0; // Enable receive
}
}
/*********************************************************************/
void CAL_VEC(int N)
{
int i;
static int j=0;
long int temp;
static long int VecR[6] = {0,0,0,0,0,0};
static long int VecI[6] = {0,0,0,0,0,0};
for (i=0;i<6;i++)
{
temp = SAMPLE[i][N+66] - SAMPLE[i][N+2];
VecR[i] += temp * SINTAB[j];
VecI[i] += temp * COSTAB[j];
}
if (CAL_FINISH == 1)
{
vr[0] = (int)((VecR[0] >>10) *901 >>16);
vi[0] = (int)((VecI[0] >>10) *901 >>16);
vr[1] = (int)((VecR[1] >>10) *901 >>16);
vi[1] = (int)((VecI[1] >>10) *901 >>16);
vr[2] = (int)((VecR[2] >>10) *901 >>16);
vi[2] = (int)((VecI[2] >>10) *901 >>16);
vr[3] = (int)(VecR[3] >>15);
vi[3] = (int)(VecI[3] >>15);
vr[4] = (int)(VecR[4] >>15);
vi[4] = (int)(VecI[4] >>15);
vr[5] = (int)(VecR[5] >>15);
vi[5] = (int)(VecI[5] >>15);
DATA_RDY = 1;
}
if (j<62) j += 2;
else j = 0;
}
/*********************************************************************//*********************************************************************/
interrupt void ADCINT_ISR(void) // 0x000D4A ADCINT (ADC)
{
static int sample_no = 0;
int i,j;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Must acknowledge the PIE group
/*** Manage the ADC registers ***/
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reset SEQ1 to CONV00 state
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; // Clear ADC SEQ1 interrupt flag
/*** Read the ADC result ***/
SAMPLE[0][sample_no] = (AdcRegs.ADCRESULT0 >> 4) - 2048;
SAMPLE[0][sample_no + 66] = SAMPLE[0][sample_no];
SAMPLE[1][sample_no] = (AdcRegs.ADCRESULT1 >> 4) - 2048;
SAMPLE[1][sample_no + 66] = SAMPLE[1][sample_no];
SAMPLE[2][sample_no] = (AdcRegs.ADCRESULT2 >> 4) - 2048;
SAMPLE[2][sample_no + 66] = SAMPLE[2][sample_no];
SAMPLE[3][sample_no] = (AdcRegs.ADCRESULT3 >> 4) - 2048;
SAMPLE[3][sample_no + 66] = SAMPLE[3][sample_no];
SAMPLE[4][sample_no] = (AdcRegs.ADCRESULT4 >> 4) - 2048;
SAMPLE[4][sample_no + 66] = SAMPLE[4][sample_no];
SAMPLE[5][sample_no] = (AdcRegs.ADCRESULT5 >> 4) - 2048;
SAMPLE[5][sample_no + 66] = SAMPLE[5][sample_no];
if ((sample_no & 0x01) ==0) CAL_VEC(sample_no);
else
{
if (HAR_FINISH == 1)
{
for (i=0;i<6;i++)
{
for (j=0;j<64;j++)
{
samp_buff[i][j] = SAMPLE[i][sample_no+3+j];
}
}
BUFF_RDY = 1;
}
i = sample_no >>1;
j = i - (i>>2)*4;
switch(j)
{
case 0: SCI_A_P(); break; //本地232口
case 1: SCI_B_P(); break; //本地485口
case 2: UART_A_P(); break; //电台接口232
case 3: UART_B_P(); break; //扩展485
default: break;
}
}
if (sample_no<65) sample_no++;
else sample_no = 0;
if (IntCounter<3199) IntCounter++;
else IntCounter = 0;
} // end ADCINT_ISR()
/*********************************************************************/
interrupt void ECAN0INT_ISR(void) // 0x000DC8 ECAN0INT (CAN)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP9; // Must acknowledge the PIE group
// Next two lines for debug only - remove after inserting your ISR
asm (" ESTOP0"); // Emulator Halt instruction
while(1);
}
/*********************************************************************/
interrupt void ECAN1INT_ISR(void) // 0x000DCA ECAN1INT (CAN)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP9; // Must acknowledge the PIE group
// Next two lines for debug only - remove after inserting your ISR
asm (" ESTOP0"); // Emulator Halt instruction
while(1);
}
/**********************************************************************
* Reserved ISRs
**********************************************************************/
/*********************************************************************/
interrupt void ILLEGAL_ISR(void) // 0x000D26 ILLEGAL - illegal operation trap
{
return;
}
/*********************************************************************/
interrupt void PIE_RESERVED(void) // Reserved PIE base vector.
{
return;
}
/*********************************************************************/
interrupt void rsvd_ISR(void) // Reserved vector
{
return;
}
/*********************************************************************/
interrupt void NOT_USE_ISR(void) // Not-used vector
{
return;
}
interrupt void PDPINTA_ISR(void) // Not-used vector
{
return;
}
interrupt void XINT1_ISR(void) //XINT1 //TLC2578转换完提请中断,读入数据
{
AD_TEMP[AD_chan_idx]=McbspaRegs.DRR1.all; //读入转换结果
AD_chan_idx++;
if(AD_chan_idx==8) AD_chan_idx=0;
mcbsp_xmit(AD_chan_idx); //发送
return;
}
/*** end of file *****************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -