samples: subsys: usb: hid-mouse: Activate pull on switch pin
This commit would add the pull-up or pull-down on the switch pin and makes it functional on the board where there is no external pull-up. Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
This commit is contained in:
parent
1e31faad06
commit
f9be2c563d
|
@ -15,7 +15,7 @@
|
|||
#ifdef SW0_GPIO_NAME
|
||||
#define SW0_GPIO_CONTROLLER SW0_GPIO_NAME
|
||||
#else
|
||||
#error SW0_GPIO_NAME or SW0_GPIO_CONTROLLER needs to be set in board.h
|
||||
#error SW0_GPIO_NAME or SW0_GPIO_CONTROLLER needs to be set
|
||||
#endif
|
||||
#endif
|
||||
#define PORT SW0_GPIO_CONTROLLER
|
||||
|
@ -24,9 +24,17 @@
|
|||
#ifdef SW0_GPIO_PIN
|
||||
#define PIN SW0_GPIO_PIN
|
||||
#else
|
||||
#error SW0_GPIO_PIN needs to be set in board.h
|
||||
#error SW0_GPIO_PIN needs to be set
|
||||
#endif
|
||||
|
||||
/* The switch pin pull-up/down flags */
|
||||
#ifdef SW0_GPIO_FLAGS
|
||||
#define PIN_FLAGS SW0_GPIO_FLAGS
|
||||
#else
|
||||
#error SW0_GPIO_FLAGS needs to be set
|
||||
#endif
|
||||
|
||||
|
||||
static const u8_t hid_report_desc[] = {
|
||||
HID_GI_USAGE_PAGE, USAGE_GEN_DESKTOP,
|
||||
/* USAGE_PAGE (Generic Desktop) 05 01 */
|
||||
|
@ -137,7 +145,8 @@ void main(void)
|
|||
|
||||
gpio_pin_configure(gpio, PIN,
|
||||
GPIO_DIR_IN | GPIO_INT |
|
||||
GPIO_INT_EDGE | GPIO_INT_DOUBLE_EDGE);
|
||||
GPIO_INT_EDGE | GPIO_INT_DOUBLE_EDGE |
|
||||
PIN_FLAGS);
|
||||
|
||||
gpio_pin_read(gpio, PIN, &def_val);
|
||||
gpio_init_callback(&gpio_cb, button_pressed, BIT(PIN));
|
||||
|
|
Loading…
Reference in a new issue