void s3c_setup_keypad_cfg_gpio(int rows, int columns) { unsigned int gpio; unsigned int end; end = S5PV210_GPH3(rows); /* Set all the necessary GPH2 pins to special-function 0 */ for (gpio = S5PV210_GPH3(0); gpio < end; gpio++) { s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3)); s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP); } end = S5PV210_GPH2(columns); /* Set all the necessary GPK pins to special-function 0 */ //for (gpio = S5PV210_GPH2(0); gpio < end; gpio++) for (gpio = S5PV210_GPH2(3); gpio < (end+3); gpio++)//lqm changed. { s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3)); s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); } }
/* Keypad interface */ static struct resource s3c_keypad_resource[] = { [0] = { .start = S3C_PA_KEYPAD, .end = S3C_PA_KEYPAD + S3C_SZ_KEYPAD - 1, .flags = IORESOURCE_MEM, }, [1] = { .start = IRQ_KEYPAD, .end = IRQ_KEYPAD, .flags = IORESOURCE_IRQ, } }; struct platform_device s3c_device_keypad = { .name = "s3c-keypad", .id = -1, .num_resources = ARRAY_SIZE(s3c_keypad_resource), .resource = s3c_keypad_resource, };
press_mask = ((keymask[col] ^ prevmask[col]) & keymask[col]); release_mask = ((keymask[col] ^ prevmask[col]) & prevmask[col]); ...... prevmask[col] = keymask[col]; ......
int keypad_keycode[] = { 1, 2, 3, 4, 5, 6, 7, 8,34, 10 };
key 42 VOLUME_UP WAKE key 58 VOLUME_DOWN WAKE key 51 HOME WAKE_DROPPED key 50 MENU WAKE_DROPPED key 26 ENDCALL WAKE_DROPPED key 34 BACK WAKE_DROPPED key 57 DPAD_LEFT WAKE_DROPPED key 49 DPAD_RIGHT WAKE_DROPPED key 25 DPAD_UP WAKE_DROPPED key 41 DPAD_DOWN WAKE_DROPPED key 33 DPAD_CENTER WAKE_DROPPED key 10 POWER WAKE
键将扮演返回的角色,其他同理。
附:相关源码下载:
http://xboot.org/forum.php?mod=viewthread&tid=348&extra=