📄 main.c
字号:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "44b.h"
#include "option.h"
#include "44blib.h"
#include "system.h"
#include "9xtend.h"
#include "timesyn.h"
void __irq Timer3Isr(void);
//void __irq Uart1_RxInt(void);
char str[10] = {0};
char strdBm[5] = {0};
int dBmval = 0;
int i,ptuartrxBuf = 0;
unsigned char uartrxBuf[lenSYNPKT];
unsigned short selfadd = 0x2;
unsigned long ts;
void Main(void)
{
rSYSCFG=CACHECFG;
Port_Init();
Timer_Init();
Int_Init();
//pISR_URXD1 = (int)Uart1_RxInt; //Register the ISR
pISR_TIMER3 = (int)Timer3Isr; //Register the ISR
Uart_Init(0,9600); //Initial uart0 and uart1
Uart_Select(0);
Delay(0); //calibrate Delay()
Uart_Printf("\nS3C44B0X Test rSYSCFG=0x%x MCLK=%d\n",rSYSCFG,MCLK);
//Initialize 9xtend,word in streaming mode, MY=1;
Init_9xtend();
//Get the synpacket
Uart_Select(1);
while(Uart_Getch() != 0x0F) ;
T2 = us;
synpktBuf[ptpktBuf++] = 0x0F;
while(1)
{
synpktBuf[ptpktBuf++] = Uart_Getch();
if(ptpktBuf==lenSYNPKT)
{
Uart_Select(0);
Uart_Sendbuf(synpktBuf,lenSYNPKT);
ptpktBuf=0;
break;
}
}
Delayms(10);
//Send T2 and T3
Uart_Select(1);
PackT2T3(selfadd,0x1,T2);
Uart_Sendbuf(synackpktBuf,lenSYNPKT);
Uart_Select(0);
Uart_Sendbuf(synackpktBuf,lenSYNPKT);
//Output the indtcator
Uart_Select(0);
rPDATG &= ~(0x40);
while(1)
{
if((ts=us)%1000000 == 0)
{
Uart_Printf("%d,%d,%d\n",ts,ts%1000000,ts/1000000);
rPDATG |= 0x40;
Delayus(200);
rPDATG &= ~(0x40);
Delayus(200);
}
}
}
void __irq Uart1_RxInt(void)
{
rI_ISPC=BIT_URXD1;
uartrxBuf[ptuartrxBuf++]=RdURXH1();
redLedBlk();
if(ptuartrxBuf==lenSYNPKT)
{
Uart_Select(1);
Uart_Sendbuf(uartrxBuf,lenSYNPKT);
ptuartrxBuf=0;
}
}
void __irq Timer3Isr(void)
{
rI_ISPC=BIT_TIMER3;
us++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -