您的位置 首页 国产IC

S3C2440 GPIO操控

/****************************************************************NAME:u2440mon.cDESC:u2440monentrypo

/****************************************************************

NAME: u2440mon.c
DESC: u2440mon entry point,menu,download
****************************************************************/
#defineGLOBAL_CLK1
//头文件
#include
#include
#include “def.h”
#include “option.h”
#include “2440addr.h”
#include “2440lib.h”
#include “2440slib.h”
#include “mmu.h”
#include “profile.h”
#include “memtest.h”
#include “clock.h”

void Isr_Init(void);

//******************************************
//测验函数
void test_led(U32 i)
{
rGPBDAT =~ (1<}

//延时
void delay(U32 i)
{
U32 del;
while(i–)
{
for(del=0;del<1000000;del++);
}
}

/************************************主函数*****************************************/
void Main(void)
{

/**************************************************************************
硬件初始化
**************************************************************************/
MMU_Init(); //初始化MMU
Port_Init(); //初始化I/O口
Isr_Init(); //封闭一切中止
cal_cpu_bus_clk(); //时钟分频 1 :4 :8, FCLK = 400MHZ,HCLK = 100MHZ,PCLK = 50MHZ,UCLK=48MHZ
Uart_Init( 0,115200 ); //初始化串口 0,波特率 115200
Uart_Select( 0 ); //挑选串口 0,传递大局参数
Uart_SendByte(\n);
Uart_Printf(“GT2440 TEST \n”);
Uart_Printf(“*******************Init clock :*******************\n\n”);
Uart_Printf(“HCLK= %d ,PCLK= %d, FCLK= %d\n\n”,HCLK,PCLK,FCLK);
Uart_Printf(“*******************Init uart0 :*******************\n\n”);
Uart_Printf(” Enter= 0 ,RATE= 115200 \n\n”);
//—————————————————————————
/************************************************************************
用户测验程序
********************************************************************************/

//GPB5 :LED1 , GPB6 :LED2 , GPB7 :LED3 , GPB8 :LED4
//00:输入 ,01:输出
rGPBCON = (0X01<<5*2)+(0X01<<6*2)+(0X01<<7*2)+(0X01<<8*2);
//GPDAT = 1,输出高电平
rGPBDAT = 0Xff<<5;
while(1)
{
test_led(5); //LED1亮
delay(10);
test_led(6); //LED2亮
delay(10);
test_led(7); //LED3亮
delay(10);
test_led(8); //LED4亮
delay(10);
test_led(7); //LED7亮
delay(10);
test_led(6); //LED6亮
delay(10);
}

}

/**********************中止设置*************************/
void Isr_Init(void)
{
rINTMOD=0x0; // All=IRQ mode
rINTMSK=BIT_ALLMSK; // All interrupt is masked.
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/bandaoti/ic/272578.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部