for{;;)
{
while((PORTB.F6 == 0) && (PORTB.F7 == 0)){
;
}
if((PORTB.F6 == 0) && (PORTB.F7 == 1)){
enter();
}
else if{PORTB.F7 == 0) && (PORTB.F6 == 1)){
leave();
}
while((PORTB.F6 == 1) || (PORTB.F7 == 1)){
;
}
if(counter > 0){
PORTC = 0xff;
}
else{
PORTC = 0x00;
}
}
/*--- function enter ---*/
void enter(void)
{
while(PORTB.F6 == 0)){ /* Time out function needed? */
;
}
if((PORTB.F6 == 1) && (PORTB.F7 == 1)){
counter++;
}
}
/*--- function leave ---*/
void leave(void)
{
while(PORTB.F7 == 0){ /* Time out function needed? */
;
}
if((PORTB.F7 == 1) && (PORTB.F6 == 1)){
if(counter > 0){
counter--;
}
}
}
/*--- End of File ---*/