📄 main.c
字号:
/**************************************************************************************************
* FILENAME
* test.c
*
* VERSION
* 1.0
*
* DESCRIPTION
* This file contains the main routine for winarm project.
*
* DATA STRUCTURES
* None
*
* FUNCTIONS
* None
*
* HISTORY
* 10/28/2003 Ver 1.0 Created by Hank Ji
*
* REMARK
* None
*
*************************************************************************************************/
#include <stdio.h>
#include "740defs.h"
#define C_main
#include "ist.h"
#define MA_AreaHold_enr 20
#define MA_AreaHold_mac 20
#define MA_QualityHold_enr 20
#define MA_QualityHold_mac 20
/************** main program ***************/
int main(void)
{
uint32 sys;
Fun_init_system();
sys = GPIO_DATAIN;
sys = sys & ((0x0000001)<<19);
Fun_buzzer2();
Fun_UART_Initialize(115200); //initialize uart
while(1)
{
if(Fun_pc_com()){;}
}
return 0;
}
/************************************************/
/* Name: Fun_init_system */
/* In: None */
/* Out: None */
/* Description: */
/* init system */
/************************************************/
void Fun_init_system(void)
{
//remap interrupt vector table
*(volatile unsigned int *)0x34 = (unsigned int)IRQ_IntHandler;
//remap external i/o bank2 and bank 3;
EXT2CON = 0x6000fffd;
EXT3CON = 0x8000fffd;
//setup gpio property
SDA_HI;
SCL_LO;
GPIO_AFG = 0x00000010; //enable uart port ,others is GPIO
GPIO_DIR = 0x00002069; //enable output
DEBNCE_CTRL =0; //disable debug mode
//initialize globle variable
// Led_redoff; //1 sec = 100 ticks
// Led_greenoff;
// Buzz_off;
AIC_IMR = 0x80;
AIC_MECR = 0x80;
AIC_SCR7 = 0x41;
if(Fun_check_flash())
{
flash_status = False;
}
else
{
flash_status = True;
}
}
/************************************************/
/* Name: Fun_check_flash */
/* In: None */
/* Out: None */
/* Description: */
/* find out which is the same with the */
/* input image in all enrolled user */
/************************************************/
bool Fun_check_flash(void)
{
//load parameter from flash,
if(Fun_rd_parameter()==0)return False;
return True;
}
/************************************************/
/* Name: Fun_check_flash */
/* In: None */
/* Out: None */
/* Description: */
/* find out which is the same with the */
/* input image in all enrolled user */
/************************************************/
bool Fun_check_lowpower(void)
{
uint8 x;
x = cs3&0x01;
if(x == 0)
{
return False;
}
return True;
}
bool Fun_judge_sw(void)
{
uint8 i;
i = DIGTAL_SW;
switch(i)
{
case USER1_SWITCH:
SwitchVal = 1;
break;
case USER2_SWITCH:
SwitchVal = 2;
break;
case USER3_SWITCH:
SwitchVal = 3;
break;
default:
return False;
}
return True;
}
/************************************************/
/* Name: Fun_show_error */
/* In: None */
/* Out: None */
/* Description: */
/* 3 short beep & red LED & POWER OFF */
/************************************************/
void Fun_show_error(void)
{
uint8 i;
for(i=0;i<2;i++)
{
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
}
Buzz_on;
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
Buzz_off;
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
Buzz_on;
Led_redon;
Fun_delay_10ms(3);
Power_off;
Led_redoff;
Fun_delay_10ms(4);
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
Buzz_off;
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
Buzz_on;
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
Buzz_off;
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
for(i=0;i<2;i++)
{
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
}
while(1)
{
Power_off;
}
}
/************************************************/
/* Name: Fun_show_ok */
/* In: None */
/* Out: None */
/* Description: */
/* 1 long beep & green LED & POWER OFF */
/************************************************/
void Fun_show_ok(void)
{
Led_greenon;
Power_off;
Buzz_on;
Fun_delay_10ms(100);
Buzz_off;
while(1)
{
Power_off;
}
}
/************************************************/
/* Name: Fun_show_ok */
/* In: None */
/* Out: None */
/* Description: */
/* 1 long beep & green LED & POWER OFF */
/************************************************/
void Fun_show_open(void)
{
Lock_open;
Led_greenon;
Buzz_on;
Fun_delay_10ms(100);
Buzz_off;
Fun_delay_10ms(200);
Led_greenoff;
Power_off;
Fun_delay_10ms(100);
Fun_delay_10ms(100);
Lock_close;
while(1)
{
Power_off;
}
}
/************************************************/
/* Name: Fun_show_lowpower */
/* In: None */
/* Out: None */
/* Description: */
/* 3 short beep & red LED */
/************************************************/
void Fun_show_lowpower(void)
{
uint8 i;
for(i=0;i<2;i++)
{
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
}
for(i=0;i<3;i++)
{
Buzz_on;
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
Buzz_off;
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
}
for(i=0;i<2;i++)
{
Led_redon;
Fun_delay_10ms(3);
Led_redoff;
Fun_delay_10ms(4);
}
Led_redon;
}
/************************************************/
/* Name: Fun_buzzer1 */
/* In: None */
/* Out: None */
/* Description: */
/* one short beep & green LED */
/************************************************/
void Fun_buzzer1(void)
{
Buzz_on;
Fun_delay_10ms(15);
Buzz_off;
}
/************************************************/
/* Name: Fun_buzzer2 */
/* In: None */
/* Out: None */
/* Description: */
/* two short beep & green LED */
/************************************************/
void Fun_buzzer2(void)
{
Buzz_on;
Fun_delay_10ms(15);
Buzz_off;
Fun_delay_10ms(10);
Buzz_on;
Fun_delay_10ms(15);
Buzz_off;
}
void Fun_delay_10ms(uint16 t)
{
uint16 i,j;
for(i=0;i<t;i++)
{
for(j=0;j<49000;j++)
{
nops;
}
}
}
void Fun_delay_1ms(uint16 t)
{
uint16 i,j;
for(i=0;i<t;i++)
{
for(j=0;j<4900;j++)
{
nops;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -