clean up bsp

This commit is contained in:
hathach 2018-08-07 22:23:33 +07:00
parent 8c33712848
commit 0d301a23e2
2 changed files with 24 additions and 16 deletions

View File

@ -26,11 +26,9 @@
#error No boards defined
#endif
// Make sure we have at least two buttons (DFU + FRESET since DFU+FRST=OTA)
#if BUTTONS_NUMBER < 2
#error "At least two buttons required in the BSP (see 'BUTTONS_NUMBER')"
#endif
//--------------------------------------------------------------------+
// LED
//--------------------------------------------------------------------+
#define LED_RED LED_1
#define LED_BLUE LED_2
@ -51,4 +49,23 @@ static inline void led_off(uint32_t pin)
led_control(pin, false);
}
//--------------------------------------------------------------------+
// BUTTONS
//--------------------------------------------------------------------+
// Make sure we have at least two buttons (DFU + FRESET since DFU+FRST=OTA)
#if BUTTONS_NUMBER < 2
#error "At least two buttons required in the BSP (see 'BUTTONS_NUMBER')"
#endif
static inline void button_init(uint32_t pin)
{
nrf_gpio_cfg_sense_input(pin, BUTTON_PULL, NRF_GPIO_PIN_SENSE_LOW);
}
static inline bool button_pressed(uint32_t pin)
{
return (nrf_gpio_pin_read(pin) == 0) ? true : false;
}
#endif

View File

@ -137,15 +137,6 @@ bool _ota_update = false;
bool is_ota(void) { return _ota_update; }
static void button_pin_init(uint32_t pin)
{
nrf_gpio_cfg_sense_input(pin, BUTTON_PULL, NRF_GPIO_PIN_SENSE_LOW);
}
bool button_pressed(uint32_t pin)
{
return (nrf_gpio_pin_read(pin) == 0) ? true : false;
}
/*
@ -190,8 +181,8 @@ void blinky_fast_set(bool isFast)
void board_init(void)
{
button_pin_init(BOOTLOADER_BUTTON);
button_pin_init(FRESET_BUTTON);
button_init(BOOTLOADER_BUTTON);
button_init(FRESET_BUTTON);
NRFX_DELAY_US(100); // wait for the pin state is stable
// LED init