File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
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
- if (BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN ) {
45
+ if ( BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN )
46
+ {
46
47
nrf_gpio_cfg_sense_input (pin , BUTTON_PULL , NRF_GPIO_PIN_SENSE_HIGH );
47
- } else {
48
+ }
49
+ else
50
+ {
48
51
nrf_gpio_cfg_sense_input (pin , BUTTON_PULL , NRF_GPIO_PIN_SENSE_LOW );
49
52
}
50
53
}
51
54
52
55
bool button_pressed (uint32_t pin )
53
56
{
54
- return (nrf_gpio_pin_read (pin ) == BUTTON_DIR ) ? true : false;
57
+ uint32_t const active_state = (BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN ? 1 : 0 );
58
+ return nrf_gpio_pin_read (pin ) == active_state ;
55
59
}
56
60
57
61
void board_init (void )
Original file line number Diff line number Diff line change 35
35
#ifndef BUTTON_DFU
36
36
#define BUTTON_DFU BUTTON_1
37
37
#endif
38
+
38
39
#ifndef BUTTON_FRESET
39
40
#define BUTTON_FRESET BUTTON_2
40
41
#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
48
42
49
43
// The primary LED is usually Red but not in all cases.
50
44
#define LED_PRIMARY 0
You can’t perform that action at this time.
0 commit comments