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

📄 main_io.c

📁 嵌入式实验s3c2440实验接口实验
💻 C
字号:
/*
*********************************************************
* Copyright (c)
* All rights reserved.				            
*
* 文件名称:main_sdram.c
* 文件标识:程序实现体
* 摘    要:本文件是对IO编程的实现
*
* 当前版本:1.0
* 作    者:孙高鑫
* 完成日期:2006.6.26
*
* 取代版本:
* 作    者:
* 完成日期:
*********************************************************
*/
#define	GLOBAL_CLK		1
/*
*********************************************************
*  					 头文件
*********************************************************
*/
#include <stdlib.h>
#include <string.h>

#include "def.h"
#include "option.h"
#include "2440addr.h"
#include "2440lib.h"

/*
*********************************************************
*  					  常量
*********************************************************
*/

/*
*********************************************************
*  					  变量
*********************************************************
*/
void Led_Test1(void)
{
	
	Uart_Printf( "LED Test, press Enter key to exit !\n" ) ;
	while(Uart_GetKey() != '\r')
	{		
		Delay(1000);
		Led_Display(0x8);
		Delay(1000);
		Led_Display(0x4);
		Delay(1000);
		Led_Display(0x2);
		Delay(1000);
		Led_Display(0x1);
		Delay(1000);
		Led_Display(0xF);
		Delay(1000);
		Led_Display(0x0);
	}
}


/*
*********************************************************
* 函数介绍:本函数被使用来做IO编程的功能。
* 输入参数:无
* 输出参数:无
* 返回值  :无
*********************************************************
*/
void Main(void)
{	    
    int i;
    U8 key;
	U32 mpll_val = 0 ;

    Port_Init();  //端口初始化
    Isr_Init();   //中断初始化
    
    i = 2 ;	//don't use 100M!
		//boot_params.cpu_clk.val = 3;
	switch ( i ) {
	case 0:	//200
		key = 12;
		mpll_val = (92<<12)|(4<<4)|(1);
		break;
	case 1:	//300
		key = 13;
		mpll_val = (67<<12)|(1<<4)|(1);
		break;
	case 2:	//400
		key = 14;
		mpll_val = (92<<12)|(1<<4)|(1);
		break;
	case 3:	//440!!!
		key = 14;
		mpll_val = (102<<12)|(1<<4)|(1);
		break;
	default:
		key = 14;
		mpll_val = (92<<12)|(1<<4)|(1);
		break;
	}
	
	//init FCLK=400M, so change MPLL first
	ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3);
	ChangeClockDivider(key, 12);
	cal_cpu_bus_clk();

    Uart_Init(0,115200);  //串口初始化 波特率为115200
    Uart_Select(0);  //选者串口0

	Clk0_Disable();
	Clk1_Disable();
	

	i=0;
	Uart_Printf("\n***********************************************************\n");
	Uart_Printf("*                  上海双实科技有限公司                   *\n");
	Uart_Printf("*                       -I/O测试-                         *\n");
	Uart_Printf("*                      Version 1.0                        *\n");
	Uart_Printf("*             Email:albert.sun@shss.com.cn                *\n");
	Uart_Printf("***********************************************************\n");
	Uart_Printf("\nBegin to start I/O test,OK? (Y/N)\n");
	key = Uart_Getch();
	
	if(key=='y'||key=='Y')
	{
		Uart_Printf("请观察SinoSys-M3左下角的四个LED,代码实现了跑马灯功能.\n");
		Led_Test1();
	}
	else
		Uart_Printf("\nOh! You quit the test!\n");
	
	Uart_Printf("\n====== I/O Test End ======\n");
}


⌨️ 快捷键说明

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