📄 main.c
字号:
/******************************************************************************/
/*main.c */
/* */
/* This is proprietary information, not to be published -- DIGIPRO DATA */
/* Copyright (C) 2002, DigiPro Information Co.,Ltd. All Rights Reserved. */
/* */
/* Author: Wu DingMing & Li Fayue */
/* Date: August 12-28, 2002 */
/******************************************************************************/
#include <stdio.h>
#include "mmdrv.h"
#include "mcbsp.h"
#include "cpu_reg.h"
#include "lcd_86.h"
/*led_traf state*/
#define BLANK 0x00
#define RED 0x01
#define GREEN 0x02
#define YELLOW 0x03
/*led_traf bit*/
#define EAST 0x00
#define NORTH 0x01
#define WEST 0x02
#define SOUTH 0x03
ioport unsigned portefff;
#define IO_374 portefff
//unsigned int exint1_flag= 0xffff;
void init_exint1_interrupt();
void init_GPIO(void);
unsigned int flag=0 ;
void main(void)
{
unsigned int i ;
SWWSR = 0x7fff;
SWCR = 0x0001;
BSCR = 0x8006;
CLKMD = PLL_DIV_INIT;
waitloop( 0x0400 );
CLKMD = PLL_LOCK_INIT_X(9);
waitloop( 0x0400 );
PMST = 0x0168;
init_exint1_interrupt();
init_GPIO();
init_lcd();
LCD_clear(0);
cur_row=3;
cur_col=8;
LCD_pr_chars("I/O_INTERRUPT TEST",18);
cur_row=4;
cur_col=1;
LCD_pr_chars("=======================",23);
IO_374=0xffff; //374 enable
Close_LED_Traf();
Close_LED_sign();
Close_LED_Data();
waitloop( 0x0400 );
while(1)
{
/*e w=red,n s=green 1 */
flag=1;
Disp_LED_Traf(RED,EAST);
Disp_LED_Traf(RED,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(GREEN,NORTH);
Disp_LED_Traf(GREEN,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
waitloop( 0x4000000L );
/*e w=red,n s=green flicker*/
for(i=0;i<4;i++)
{
flag=2;
Disp_LED_Traf(RED,EAST);
Disp_LED_Traf(RED,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(BLANK,NORTH);
Disp_LED_Traf(BLANK,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
waitloop( 0x00200000L );
Disp_LED_Traf(RED,EAST);
Disp_LED_Traf(RED,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(GREEN,NORTH);
Disp_LED_Traf(GREEN,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
waitloop( 0x00200000L );
}
/*e w=red,n s=yellow 2 */
flag=3;
Disp_LED_Traf(RED,EAST);
Disp_LED_Traf(RED,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(YELLOW,NORTH);
Disp_LED_Traf(YELLOW,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
waitloop( 0x00800000L );
/*e w=red,n s=red */
flag=4;
Disp_LED_Traf(RED,EAST);
Disp_LED_Traf(RED,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(RED,NORTH);
Disp_LED_Traf(RED,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
waitloop( 0x00800000L );
/*e w=green, n s=red 3 */
flag=5;
Disp_LED_Traf(GREEN,EAST);
Disp_LED_Traf(GREEN,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(RED,NORTH);
Disp_LED_Traf(RED,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
waitloop( 0x4000000L );
/* */
/*n s=red,e w=green flicker*/
for(i=0;i<4;i++)
{
flag=6;
Disp_LED_Traf(BLANK,EAST);
Disp_LED_Traf(BLANK,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(RED,NORTH);
Disp_LED_Traf(RED,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
waitloop( 0x00200000L );
Disp_LED_Traf(GREEN,EAST);
Disp_LED_Traf(GREEN,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(RED,NORTH);
Disp_LED_Traf(RED,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
waitloop( 0x00200000L );
}
/*n s=red,e w=yellow 4*/
flag=7;
Disp_LED_Traf(YELLOW,EAST);
Disp_LED_Traf(YELLOW,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(RED,NORTH);
Disp_LED_Traf(RED,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
waitloop( 0x00800000L );
/*n s=red,e w=red */
Disp_LED_Traf(RED,EAST);
Disp_LED_Traf(RED,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(RED,NORTH);
Disp_LED_Traf(RED,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
waitloop( 0x00800000L );
}
}
interrupt void EXINT1_isr()
{
//exint1_flag=~exint1_flag;
IMR =0x0000; //close EXINT1=IMR.1
cur_row=5;
cur_col=15;
LCD_pr_chars("car is arriving...",18);
/*e w=red,n s=red */
Disp_LED_Traf(RED,EAST);
Disp_LED_Traf(RED,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(RED,NORTH);
Disp_LED_Traf(RED,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
while(!(GPIOSR&0x01))
{
asm("\tnop");
asm("\tnop");
}
while((GPIOSR&0x01))
{
asm("\tnop");
asm("\tnop");
}
while(!(GPIOSR&0x01))
{
asm("\tnop");
asm("\tnop");
}
switch(flag)
{
default:
break;
case 1:
Disp_LED_Traf(RED,EAST);
Disp_LED_Traf(RED,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(GREEN,NORTH);
Disp_LED_Traf(GREEN,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
break;
case 3:
Disp_LED_Traf(RED,EAST);
Disp_LED_Traf(RED,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(YELLOW,NORTH);
Disp_LED_Traf(YELLOW,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
break;
case 5:
Disp_LED_Traf(GREEN,EAST);
Disp_LED_Traf(GREEN,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(RED,NORTH);
Disp_LED_Traf(RED,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
break;
case 7:
Disp_LED_Traf(YELLOW,EAST);
Disp_LED_Traf(YELLOW,WEST);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
Disp_LED_Traf(RED,NORTH);
Disp_LED_Traf(RED,SOUTH);
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
break;
}
cur_row=5;
cur_col=15;
LCD_pr_chars("car has left......",18);
IFR =0xffff;
asm("\tnop");
asm("\tnop");
asm("\tnop");
asm("\tnop");
IMR =0x0002; //turn on EXINT1=IMR.1
}
void init_exint1_interrupt()
{
IFR =0xffff;
IMR =0x0002; //EXINT1=IMR.1
asm("\trsbx\tintm ");
}
void init_GPIO(void)
{
GPIOCR =0xfffe; //EXINT1=GPIO.0=input=0,nand_cs=GPIO.6=output=1
GPIOSR =0x0040; //GPIO.6=output=1
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -