File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 42
42
//------------- IMPLEMENTATION -------------//
43
43
void button_init (uint32_t pin )
44
44
{
45
- nrf_gpio_cfg_sense_input (pin , BUTTON_PULL , NRF_GPIO_PIN_SENSE_LOW );
45
+ if (BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN ) {
46
+ nrf_gpio_cfg_sense_input (pin , BUTTON_PULL , NRF_GPIO_PIN_SENSE_HIGH );
47
+ } else {
48
+ nrf_gpio_cfg_sense_input (pin , BUTTON_PULL , NRF_GPIO_PIN_SENSE_LOW );
49
+ }
46
50
}
47
51
48
52
bool button_pressed (uint32_t pin )
49
53
{
50
- return (nrf_gpio_pin_read (pin ) == 0 ) ? true : false;
54
+ return (nrf_gpio_pin_read (pin ) == BUTTON_DIR ) ? true : false;
51
55
}
52
56
53
57
void board_init (void )
Original file line number Diff line number Diff line change 38
38
#ifndef BUTTON_FRESET
39
39
#define BUTTON_FRESET BUTTON_2
40
40
#endif
41
+ #ifndef BUTTON_DIR
42
+ #if BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN
43
+ #define BUTTON_DIR 1
44
+ #elif BUTTON_PULL == NRF_GPIO_PIN_PULLUP
45
+ #define BUTTON_DIR 0
46
+ #endif
47
+ #endif
41
48
42
49
// The primary LED is usually Red but not in all cases.
43
50
#define LED_PRIMARY 0
You can’t perform that action at this time.
0 commit comments