ARM学习笔记---Keyscan
已有 882 次阅读2009-3-5 12:18
|个人分类:ARM学习|系统分类:ARM
发一个在2440上的裸奔程序
注释已经很清楚了,不必多说
顺便提一句,觉得把ARM当超级单片机来学,还是比较容易上手
等一步步熟悉了硬件资源,再上操作系统......
/*******************************************************/
/* Project :KeyScan */
/* Compiler :ADS 1.2 */
/* Chip Type :S3C2440 */
/* Date :2009.3.4 */
/* Author :lhy */
/* */
/* Comments : */
/* 1. 硬件环境基于MINI2440; */
/* 2. 按下K1,LED1亮,依此类推,按下K5时,四LED同时亮*/
/*******************************************************/
#include "def.h"
#include "option.h"
#include "2440addr.h"
#include "2440lib.h"
#include "2440slib.h"
void PortInit(void)
{
rGPGCON = ((~(3<<0)) & (~(3<<6)) & (~(3<<10)) & (~(3<<12)) & (~(3<<14)));
rGPBCON = (1<<10) | (1<<12) | (1<<14) | (1<<16);
}
int Main(void)
{
unsigned long data;
PortInit();
while(1)
{
data = rGPGDAT;
if(!(data & 1))//Press K1
rGPBDAT &= ~(1<<5);
else
rGPBDAT |= (1<<5);
if(!(data & (1<<3)))//Press K2
rGPBDAT&= ~(1<<6);
else
rGPBDAT |= (1<<6);
if(!(data & (1<<5)))//Press K3
rGPBDAT&= ~(1<<7);
else
rGPBDAT |= (1<<7);
if(!(data & (1<<6)))//Press K4
rGPBDAT &= ~(1<<8);
else
rGPBDAT |= (1<<8);
if(!(data & (1<<7)))//Press K5
rGPBDAT &= ~((1<<5) | (1<<6) | (1<<7) | (1<<8));
else
rGPBDAT |= ((1<<5) | (1<<6) | (1<<7) | (1<<8));
}
return 0;
}