📄 iop.c
字号:
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* iop.c KS32C5000, KS32C50100 : version 1.0 */
/* */
/* COMPONENT */
/* */
/* */
/* DESCRIPTION */
/* */
/* */
/* AUTHOR */
/* */
/* Young Sun KIM, Samsung Electronics, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* */
/* FUNCTIONS */
/* */
/* I/O port input, output and share function test */
/* */
/* DEPENDENCIES */
/* */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* in4maker 12-18-1998 Created initial version 1.0 */
/*************************************************************************/
//nclude <stdio.h>
#include "../inc/iop.h"
#include "../inc/irq.h"
#include "../inc/s3c4510b.h"
#include "../inc/board.h"
#include "../inc/utils.h"
#include "../inc/def.h"
#include "../inc/config.h"
#include "../inc/lcd.h"
#define MON_TIME_DELAY 1000000
volatile unsigned int ExtIntFlag = 0;
volatile unsigned int ExtIntCnt = 0;
extern volatile unsigned int clk_tick; //defined at timer.c
/* I/O Function Test */
void ioptest(void)
{
int key;
unsigned char ch;
rIOPMOD =0x00ff;
rIOPDATA = ~0xd; // In iop test mode
// rIOPCON=0XA5294;
rIOPCON=0X84210;
//SysSetInterrupt(INT_EXTINT1, ext1isr);
//Enable_Int(INT_EXTINT1);
//SysSetInterrupt(INT_EXTINT0, ext0isr);
//SysSetInterrupt(INT_EXTINT2, ext2isr);
//SysSetInterrupt(INT_EXTINT3, ext3isr);
//
// Enable_Int(INT_EXTINT2);
// Enable_Int(INT_EXTINT3);
// Enable_Int(INT_GLOBAL); //enable global interrupt mask
puts(" \n SW3 : D4 AND D5 ON\n ");
puts(" \n SW4 : D6 AND D7 ON\n ");
puts(" \n SW5 : D8 AND D9 ON\n ");
puts(" \n SW6 : D10 AND D11 ON\n ");
/* -------------------------*/
/* --- use for debugging ---*/
/* -------------------------*/
//rIOPMOD |= 0x1F; // Use output port for LED display
while((ch=getkey())!=ESC_KEY)
{
key=keyscan();
switch(key)
{
case 1:
{
LedSet(0x3);
// l2Print("you enter is"," KINT1");
break;
}
case 2:
{
LedSet(0xc);
// l2Print("you enter is"," KINT2");
break;
}
case 3:
{
LedSet(0x30);
// l2Print("you enter is"," KINT3");
break;
}
case 4:
{
LedSet(0xc0);
// LedSet(0xc0);
// l2Print("you enter is"," KINT4");
break;
}
default:break;
}
}
}
void ext0isr(void)
{
Clear_PendingBit(INT_EXTINT0);
//puts("\n> External interrupt 0 !!!\n");
//CLKCON = 0x0; //Recover the system clock to 33Mhz
LedSet(0xc0);
ExtIntCnt++;
ExtIntFlag = 1;
//ExtIntDisable(0);
}
void ext1isr(void)
{
//Clear_PendingBit(nEXT1_INT);
//puts("\n> External interrupt 1 !!!\n");
//CLKCON = 0x0; //Recover the system clock to 33Mhz
l2Print("you enter is"," KINT1");
LedSet(0x3);
ExtIntCnt++;
ExtIntFlag = 1;
//ExtIntDisable(1);
}
void ext2isr(void)
{
//Clear_PendingBit(nEXT2_INT);
// puts("\n> External interrupt 2 !!!\n");
//CLKCON = 0x0; //Recover the system clock to 33Mhz
LedSet(0XC);
l2Print("you enter is"," KINT2");
ExtIntCnt++;
ExtIntFlag = 1;
//ExtIntDisable(2);
}
void ext3isr(void)
{
//Clear_PendingBit(nEXT3_INT);
//puts("\n> External interrupt 3 !!!\n");
//CLKCON = 0x0; //Recover the system clock to 33Mhz
LedSet(0X30);
l2Print("you enter is"," KINT3");
ExtIntCnt++;
ExtIntFlag = 1;
//ExtIntDisable(3);
}
int keyscan(void)
{
int key_value=0;
int time;
if(~(inl(IOPDATA))&0x400)
{ for(time=0;time<KEY_TIME_OUT;time++);
if(~(inl(IOPDATA))&0x400)
key_value=4;
}
if(~(inl(IOPDATA))&0x800)
{
for(time=0;time<KEY_TIME_OUT;time++);
if(~(inl(IOPDATA))&0x800);
key_value=3;
}
if(~(inl(IOPDATA))&0x1000)
{ for(time=0;time<KEY_TIME_OUT;time++);
if(~(inl(IOPDATA))&0x1000)
key_value=1;
}
if(~(inl(IOPDATA))&0x2000)
{
for(time=0;time<KEY_TIME_OUT;time++);
if(~(inl(IOPDATA))&0x20000)
key_value=2;
}
// printf(" enter key %i\n",key_value);
return key_value;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -