📄 test.c
字号:
/************************************************
* NAME : 2440loader.c
* DESC :
* History : 2002.02.25 ver 0.0
* rev0.1 : 2003. 05.xx modified for 2440
* rev0.2 : 2004. 02.xx modified for 2440A(xtal 16.9344MHz)
************************************************/
#include <stdlib.h>
#include <string.h>
#include "def.h"
#include "option.h"
#include "2440addr.h"
#include "2440slib.h"
#include "2440lib.h"//by xh
#include "mmu.h"
#include "IRQServer.h"
#include "subFunc.h"
char temp[10];
int j;
U16 i;
unsigned int base;
void Main(void)
{
//register page, block, blockcopy_count;
// int i, j;
S8 tempcount = 0;
// int c;
U32 dAddr;
U16 rLength,
wLength,
buffer[50],
buffer2[50];
// MMU_EnableICache();
MMU_Init();
// ChangeClockDivider(12,12); // 1:2:4
// ChangeClockDivider(13,12); // 1:3:6
// ChangeClockDivider(14,12); // 1:4:8
// ChangeMPllValue(88, 1, 1); // FCLK=192MHz
// ChangeMPllValue(246, 13, 0); // FCLK=203.2MHz
// ChangeMPllValue(92, 1, 0); // FCLK=400MHz
// ChangeMPllValue(214, 3, 0); // FCLK=532MHz
Port_Init();//
//**********************************ADDED
Led_Display(0x01);
//**********************************
Isr_Init();
Uart_Init(PCLK, 115200);
Uart_TxEmpty(0);
Uart_TxEmpty(1);
Uart_TxEmpty(2);
//Uart_Select(1);
Uart_Select(0);// by xh
base = 0x08000000;
dAddr = 0x08000000;
rLength = 50;
wLength = 100;
//Uart_Select(0);
// Uart_SendByte('0');
// Uart0SendByte('0');
//Uart0SendByte('1');
//Uart0SendByte(0x2D);//0d
// Uart0SendByte(0x2A);//0aggg,,,,
Uart_Printf("\nData before write:\n");
/* for(i=0; i<10; i++)
{
c = ((volatile unsigned char *)base)[i];
Uart_SendString(hex2char(c));
}*/
GetFpgaData(dAddr, rLength, buffer);
for(i=0; i<rLength; i++)
{
Uart_Printf(hex2char(buffer[i] / 0x100));
Uart_Printf(hex2char(buffer[i] % 0x100));
Uart_Printf("\n");
}
/*for(i=0; i<100; i++)
{
((volatile unsigned short *)base)[i*2] = i;
}*/
for(i=0; i<rLength; i++)
{
buffer[i] = i;
}
SendFpgaData(dAddr, rLength, buffer);
Uart_Printf("\nData after write:\n");
/*for(i=0; i<10; i++)
{
c = ((volatile unsigned char *)base)[i];
Uart_SendString(hex2char(c));
}*/
Uart_Printf("\nTest read function!\n");
GetFpgaData(dAddr, rLength, buffer2);
for(i=0; i<rLength; i++)
{
Uart_Printf(hex2char(buffer2[i] / 0x100));
Uart_Printf(hex2char(buffer2[i] % 0x100));
Uart_Printf("\n");
}
Uart_Printf("\nCount:%xh\n", tempcount);
Uart_Select(1);// by xh
base = 0x08000000;
dAddr = 0x08000000;
rLength = 50;
wLength = 100;
Uart_Select(0);
Uart_SendByte('0');
//Uart1SendByte('1');
// Uart1SendByte(0x0D);
// Uart1SendByte(0x0A);
Uart_Printf("\nData before write:\n");
/* for(i=0; i<10; i++)
{
c = ((volatile unsigned char *)base)[i];
Uart_SendString(hex2char(c));
}*/
GetFpgaData(dAddr, rLength, buffer);
for(i=0; i<rLength; i++)
{
Uart_Printf(hex2char(buffer[i] / 0x100));
Uart_Printf(hex2char(buffer[i] % 0x100));
Uart_Printf("\n");
}
/*for(i=0; i<100; i++)
{
((volatile unsigned short *)base)[i*2] = i;
}*/
for(i=0; i<rLength; i++)
{
buffer[i] = i;
}
SendFpgaData(dAddr, rLength, buffer);
Uart_Printf("\nData after write:\n");
/*for(i=0; i<10; i++)
{
c = ((volatile unsigned char *)base)[i];
Uart_SendString(hex2char(c));
}*/
Uart_Printf("\nTest read function!\n");
GetFpgaData(dAddr, rLength, buffer2);
for(i=0; i<rLength; i++)
{
Uart_Printf(hex2char(buffer2[i] / 0x100));
Uart_Printf(hex2char(buffer2[i] % 0x100));
Uart_Printf("\n");
}
Uart_Printf("\nCount:%xh\n", tempcount);
uart_select(1);
while(1)
{
for(int i =0 ;i<20;i++)
{
if(flag == 1)
{
改波特率;
flag = 0;
}
uart_sendByte('d');
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -