WAT-910BD H/W MANUAL
WAT-910BD H/W MANUAL
WAT-910BD H/W MANUAL
WAT-910BD H/W MANUAL
while(i<3){
// read SW status in 3 times
SW_S_C[i] = p1 ;
wait_ms(10) ;
// 5ms waite
SW_S_C[i+1] = p1 ;
// read one more
if (SW_S_C[i] == SW_S_C[i+1]){
i++ ;
}else{
i = 0 ;
}
}
// if SW status equal 3 times, check previous SW status.
// if it is not equal, key input was changed and stable.
if(SW_STATUS != SW_S_C[3]){
SW_STATUS = SW_S_C[3] ;
// judge which SW is ON and processing SPI communication.
if(check_key_status() != TRUE){
p4_5 = 0 ;
// LED lit ON
}else{
p4_5 = 1 ;
}
}
}
}
// end of main--------------------------------------------------------------------
//--------------------------------------------------------------------------------
// FUNCTION: check_key_status
//
// Decode SW status and process SPI communication.
// if illegal code was read, return FALSE.
//--------------------------------------------------------------------------------
unsigned char
check_key_status(void)
{
unsigned
char
i ;
unsigned
char
RetV ;
// TRUE/FALSE
// decode 5 key
switch( SW_STATUS & 0x1F ){
case 0x1E:
// 5key UP
// INC address and Read Parameter
if (Adr_C == 0x5FF){
Adr_C = 0x400 ;
}else{
Adr_C++ ;
}
RetV = INDIRECT_READ(Adr_C) ;
break ;
case 0x1D:
// 5key DOWN
// DEC adress and Read Parameter
if (Adr_C == 0x400){
Adr_C = 0x5FF ;
- 49 -