#define FIO1SET (*(volatile unsigned long *)(FIO_BASE_ADDR + 0x38))
#define PORT0 0
#define PORT1 1
#define PORT2 2
#define PORT3 3
#define PORT4 4
void FIO_Set(unsigned char port, unsigned int pin)
{
switch (port)
{
case 0:
FIO0SET=pin;
break;
case 1:
FIO1SET=pin;
break;
case 2:
FIO2SET=pin;
break;
case 3:
FIO3SET=pin;
break;
case 4:
FIO4SET=pin;
break;
default:
break;
}
}
//val应当与relays的值相对应,例如置位K0,K4,则val的值为 0x00000011;
void Relay_Out(unsigned int relays,unsigned int val)
{
unsigned int i = 0;
for(i = 0; i < 10; i++)
{
switch( relays & (1<<i))
{
case KM1_OUT:
if( val & KM1_OUT)
FIO_Set(PORT1, Y0_P1_21);
else
FIO_Clr(PORT1, Y0_P1_21);
break;
case GM1_OUT:
。。。。
}
void Door_Ctrl(unsigned int cur_input)
{
unsigned int i = 0;
//判断输入值的下降沿
for(i=0;i<5;i++)
{
if(door_param.door_pre_input & (1<<i)) //door_param.door_pre_input: //门机信号输入
{
if(!(cur_input & (1<<i))) //cur_input:轿厢信号输入
{
//door_param.door_in_edge_detect:检测下降沿
door_param.door_in_edge_detect |= (1<<i);
if(door_param.door_led_cfg) //是否允许LED亮
{
if(i==0)
Relay_Out(KM1_OUT, KM1_OUT);
else if(i == 1)
Relay_Out(GM1_OUT, GM1_OUT);
else if(i == 1)
Relay_Out(GM1_OUT, GM1_OUT);
else if(i == 2)
Relay_Out(KM2_OUT, KM2_OUT);
else if(i == 3)
Relay_Out(GM2_OUT, GM2_OUT);
else
Relay_Out(KMDELAY_OUT, KMDELAY_OUT);
...........
. .........
}
这段程序是什么意思 ? |