⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 北京航空航天大学2006年嵌入式系统课件及试验.适合嵌入式初级学者!
💻 C
字号:
/***************************************************************************\
	Copyright (c) 2004-2007 threewater@up-tech.com, All rights reserved.
	by threewter	2004.5.12
\***************************************************************************/
/***************************************************************************\
    #说明: C  main 函数,ucos-ii初始化等定义
	----------------------------------  Bug  --------------------------------------

	----------------------------------  TODO list  --------------------------------------

	----------------------------------修正--------------------------------------
	2004-5-12	创建

\***************************************************************************/

//#include"../ucos-ii/includes.h"               /* uC/OS interface */
//#include "../ucos-ii/add/osaddition.h"
#include "../inc/drivers.h"

//#include "../inc/sys/lib.h"
//#include "../src/gui/gui.h"
#define U8 unsigned char
#include <string.h>
#include <stdio.h>
#define TRUE 	1
#define FALSE 	0
#pragma import(__use_no_semihosting_swi)  // ensure no functions that use semihosting 

#define rUTRSTAT0	(*(volatile unsigned *)0x50000010)
#define rUTRSTAT1	(*(volatile unsigned *)0x50004010)
#define WrUTXH0(ch)	(*(volatile unsigned char *)0x50000020)=(unsigned char)(ch)
#define WrUTXH1(ch)	(*(volatile unsigned char *)0x50004020)=(unsigned char)(ch)
#define RdURXH0()	(*(volatile unsigned char *)0x50000024)
#define RdURXH1()	(*(volatile unsigned char *)0x50004024)
//void Uart_SendByten(int Uartnum, U8 data);
extern  serial_driver_t s3c2410_serial0_driver, s3c2410_serial1_driver, 
		s3c2410_serial2_driver;


void Uart_SendByten(int,U8);
char Uart_Getchn(char* Revdata, int Uartnum, int timeout);

void ARMTargetInit(void);
void hudelay(int time);
int main(void)
{   //int ndev; 
    char c1[1];
    char err0,err1;
   
    serial_init(0,115200);
  //  serial_init(1,115200);     //by wj
	
	ARMTargetInit();        // do target (uHAL based ARM system) initialisation //
   
   
	
	while(1)
	{
       	Uart_SendByten(0,0xa);//换行
		Uart_SendByten(0,0xd);//回车
        err0=Uart_Getchn(c1,0,0);	//从串口采集数据
		Uart_SendByten(0,c1[0]);	//显示采集的数据	
             
       /*	Uart_SendByten(1,0xa);//换行
		Uart_SendByten(1,0xd);//回车
        err1=Uart_Getchn(c1,1,0);	//从串口采集数据
		Uart_SendByten(1,c1[0]);	//显示采集的数据
		*/
	
	}
	
	
	
}
	
	void Uart_SendByten(int Uartnum, U8 data)//ok eric rong
{   //int i;
	if(Uartnum==0)
    {
		while(!(rUTRSTAT0 & 0x4)); //Wait until THR is empty.
		
		hudelay(10);
		WrUTXH0(data);
   	}
	else
    {
		while(!(rUTRSTAT1 & 0x4));  //Wait until THR is empty.
		
		hudelay(10);
		WrUTXH1(data);
    }	
}		

   char Uart_Getchn(char* Revdata, int Uartnum, int timeout)
{
	
	if(Uartnum==0){
		while(!(rUTRSTAT0 & 0x1)); //Receive data read
		*Revdata=RdURXH0();
		return TRUE;
	}
	else{
		while(!(rUTRSTAT1 & 0x1));//Receive data read
		*Revdata=RdURXH1();
		return TRUE;
	}
}	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -