static void pan_direct_gpio_interrupt(UINT32 param) { struct pan_key key; static int keypress_count = 0, keypress_intv = 0; static UINT32 keypress_bak = 0; UINT32 keypress = PAN_KEY_INVALID; unsigned char index; if(pan_get_gpio(POS_GPIO_STANDBY_KEY)== POS_GPIO_STANDBY_KEY_POLAR) index = 1; else if(pan_get_gpio(POS_GPIO_CHANNEL_UP_KEY) == POS_GPIO_CHANNEL_UP_KEY_POLAR) index = 2; else if(pan_get_gpio(POS_GPIO_CHANNEL_DOWN_KEY) == POS_GPIO_CHANNEL_DOWN_KEY_POLAR) index = 3; else index = 0; keypress = scan_key_map[index]; /* Some key input */ if (keypress != PAN_KEY_INVALID) { if(keypress_bak == PAN_KEY_INVALID) { keypress_bak = keypress; keypress_count = 1; keypress_intv = 150; } else if(keypress_bak == keypress) { keypress_count++; if(keypress_count == keypress_repeat) { key.type = PAN_KEY_TYPE_PANEL; key.state = PAN_KEY_PRESSED; key.count = 1; key.code = keypress_bak; //libc_printf("key press: %x \n",key.code); pan_buff_queue_tail(&key); } else if(keypress_count == keypress_intv) { keypress_count = 0; keypress_intv = 130; } } } else { keypress_bak = keypress; } }
static void panel_ch455_task(UINT32 param) { struct pan_device *dev = (struct pan_device *)param; struct pan_ch455_private *tp = (struct pan_ch455_private *)dev->priv; //struct pan_hw_info *hp = tp->hw_info; struct pan_key key; UINT8 row, column, status; UINT8 data = 0xff; static UINT8 cnt = 0; UINT32 keypress = PAN_KEY_INVALID; UINT32 re; while(1) { if(re = read_key(tp, &data)) { PAN_CH455_PRINTF("%s()=>Scan keyboard failed!re = %d.\n", __FUNCTION__, re); goto ch455_sleep; } else { //bit 7 should always be 0, bit 2 should always be 1. if(((data & 0x80) != 0) || ((data & 0x04) == 0)) { PAN_CH455_PRINTF("%s()=>Read bad key code!data = 0x%2x.\n", __FUNCTION__, data); goto ch455_sleep; } else { column = data & tp->mask_column; //(0~1) row = (data & tp->mask_row) >> 3; //(0~6) status = (data & tp->mask_status) >> 6; //PAN_CH455_PRINTF("%s()=>data: 0x%2x, column: %d, row: %d, status: %d.\n", __FUNCTION__, data, column, row, status); } } /* //(column,row)=>(0,0), (0,1), (0,2), (0,3), (0,4), (0,5), (0,6), (1,0) if(column == 0) key_temp = 1 << row; else key_temp = 0x80; */ keypress = 0xffff0000 | data; if (tp->bak_status == CH455_STATUS_UP) { if (status == CH455_STATUS_UP) goto ch455_sleep; //status == CH455_STATUS_DOWN key.type = PAN_KEY_TYPE_PANEL; key.state = PAN_KEY_PRESSED; key.count = tp->key_cnt; key.code = keypress; pan_buff_queue_tail(&key); tp->key_cnt ++; tp->bak_status = status; tp->keypress_cnt = 0; } else //tp->bak_status == CH455_STATUS_DOWN { if (status == CH455_STATUS_UP) { tp->key_cnt = 1; //if (tp->hw_info->intv_release & 1) //If intv_release is odd, pan key repeat enable if(1) { key.type = PAN_KEY_TYPE_PANEL; key.state = PAN_KEY_RELEASE; key.count = 1; key.code = keypress; pan_buff_queue_tail(&key); } tp->bak_status = status; } else { //status == CH455_STATUS_DOWN tp->keypress_cnt ++; if (tp->keypress_cnt == tp->keypress_intv) { key.type = PAN_KEY_TYPE_PANEL; key.state = PAN_KEY_PRESSED; key.count = tp->key_cnt; key.code = keypress; pan_buff_queue_tail(&key); tp->key_cnt++; tp->keypress_cnt = 0; } } } ch455_sleep: osal_task_sleep(CH455_KEY_INTERVAL); //osal_task_sleep(1000); }//while(1) }