📄 sub_main.c
字号:
#include "iom16.h"
#include "ioavr.h"
#include "inavr.h"
#include "avr_macros.h"
#include "userdef.h"
#include "userfun.h"
#include "userram.h"
#include "usertype.h"
#include "disdata.h"
void ClearTimer1(void)
{
TCNT1L = 0x00;
TCNT1H = 0x00;
TCCR1B = 0x00;
}
void CheckWendu(void)
{
write_error=0;
wendu_lm77=ReadLM77();
if(wendu_lm77&0x0200)
{
disbuf[0]=BCDSEG_TAB[FuHao];
wendu_lm77 = 0x1ff-wendu_lm77&0x1ff;
}
else
{
disbuf[0]=NoDisplay;
}
wendu_lm77 *= 5;
disbuf[1]=BCDSEG_TAB[wendu_lm77/1000];
wendu_lm77=wendu_lm77%1000;
disbuf[2]=BCDSEG_TAB[wendu_lm77/100];
wendu_lm77=wendu_lm77%100;
disbuf[3]=BCDSEGDOT_TAB[wendu_lm77/10];
wendu_lm77=wendu_lm77%10;
disbuf[4]=BCDSEG_TAB[wendu_lm77];
disbuf[5]=NoDisplay;
disbcd(disbuf);
if(write_error!=0)
{
disbuf[0]=BCDSEG_TAB[14];
disbuf[1]=BCDSEG_TAB[14];
disbuf[2]=BCDSEG_TAB[14];
disbuf[3]=BCDSEG_TAB[14];
disbuf[4]=BCDSEG_TAB[14];
disbuf[5]=BCDSEG_TAB[14];
disbcd(disbuf);
}
}
void GainChannel(void)
{
if(gain_F)
{
gain_F=0;
Display_RX_Gain();
}
else
{
gain_F=1;
Display_TX_Gain();
}
}
void AddGain(void)
{
if(gain_F)
{
if(tx_gain>=31)
tx_gain=0;
else
tx_gain++;
Display_TX_Gain();
}
else
{
if(rx_gain>=31)
rx_gain=0;
else
rx_gain++;
Display_RX_Gain();
}
Write_PCF8575();
}
void DecGain(void)
{
if(gain_F)
{
if(tx_gain==0)
tx_gain=31;
else
tx_gain--;
Display_TX_Gain();
}
else
{
if(rx_gain==0)
rx_gain=31;
else
rx_gain--;
Display_RX_Gain();
}
Write_PCF8575();
}
void ChannelCheck(void) //屏蔽检测
{
DisableInt1;
ClearTimer1();
sofakey_count=0;
sokey_count=0;
fakey_count=0;
SY0_S0_T0_R0; //输出0;
delay(8); //delay 8 us
PORTD += pingbicount;
if((pingbicount==0)||(pingbicount==1)||(pingbicount==6))
{
disbuf[0]=BCDSEG_TAB[12]; //display C
}
else
{
disbuf[0]=BCDSEG_TAB[14]; //display E
}
disbuf[1]=NoDisplay;
disbuf[2]=NoDisplay;
disbuf[3]=(pingbicount&0x04)?BCDSEG_TAB[1]:BCDSEG_TAB[0];
disbuf[4]=(pingbicount&0x02)?BCDSEG_TAB[1]:BCDSEG_TAB[0];
disbuf[5]=BCDSEG_TAB[pingbicount&0x01];
disbcd(disbuf);
if(pingbicount>=7)
pingbicount=0;
else
pingbicount++;
}
void ShouFa(void) //收发
{
sokey_count=0;
fakey_count=0;
sofakey_count++;
if(sofakey_count==1)
{
SY0_S0_T0_R0; //PORTD = 输出0;
delay(5); //delay 5us
SY1_S1_T1_R0; //发;
// delay(400); //delay 400 us
}
disbuf[0]=BCDSEG_TAB[5]; //so--fa
disbuf[1]=BCDSEG_TAB[0];
disbuf[2]=BCDSEG_TAB[20];
disbuf[3]=BCDSEG_TAB[20];
disbuf[4]=BCDSEG_TAB[15];
disbuf[5]=BCDSEG_TAB[10];
disbcd(disbuf);
EnableInt1;
}
void Shou(void) //只收不发
{
DisableInt1;
ClearTimer1();
sofakey_count=0;
fakey_count=0;
sokey_count++;
if(sokey_count==1)
{
SY0_S0_T0_R0; //输出0;
delay(5); //delay us
SY0_S0_T0_R1; //收;
}
disbuf[0]=BCDSEG_TAB[12]; //ch--so
disbuf[1]=BCDSEG_TAB[17];
disbuf[2]=BCDSEG_TAB[20];
disbuf[3]=BCDSEG_TAB[20];
disbuf[4]=BCDSEG_TAB[5];
disbuf[5]=BCDSEG_TAB[0];
disbcd(disbuf);
}
void Fa(void) //只发不收
{
DisableInt1;
ClearTimer1();
sofakey_count=0;
sokey_count=0;
fakey_count++;
if(fakey_count==1)
{
SY0_S0_T0_R0; //输出0;
delay(5); //delay us
SY1_S1_T1_R0; //发;
}
disbuf[0]=BCDSEG_TAB[12]; //display ch--fa
disbuf[1]=BCDSEG_TAB[17];
disbuf[2]=BCDSEG_TAB[28];
disbuf[3]=BCDSEG_TAB[28];
disbuf[4]=BCDSEG_TAB[15];
disbuf[5]=BCDSEG_TAB[10];
disbcd(disbuf);
}
void CheckOPD(void)
{
CLR_PD_CNT;
SET_PD_CNT;
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
CLR_PD_CNT;
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
SPDR=0x00;
while((SPSR BIT7)==0x00);
OPD2=SPDR;
SPDR=0X00;
while((SPSR BIT7)==0x00);
OPD1=SPDR;
//根据公式计算OPD
//显示
}
void CheckVSWR(void)
{
CLR_PD_CNT;
SET_PD_CNT;
__no_operation();
CLR_PD_CNT;
__no_operation();
SET_PD_CNT;
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
CLR_PD_CNT;
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
SPDR=0x00;
while((SPSR BIT7)==0x00);
VSWR2=SPDR;
SPDR=0X00;
while((SPSR BIT7)==0x00);
VSWR1=SPDR;
//根据公式计算VSWR
//显示
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -