Sw2 button-dwm1001 dev


It was previously said I could reconfigure the SW2 button on the DWM1001 Dev board. My question is, quite simply, how? Would I have to modify existing code (if so, where would that code be?)? Or would I have to write new code to overwrite the previous function?


Yes, definitely.
Below is a piece of my code using SW2 button to switch on/off LED depending of the button state. I skipped some code not related to the button usage.
Note that this button is not available if you configured DWM as a tag and enabled BLE (see 3.4.5 of the DWM1001-API-Guide.pdf). If so, the function dwm_gpio_value_get returns an error (can’t remember which error exactly). Strange for me, because concurrent reading such a resource should be safe, but…



  • Check hardware button state
  • @return state
  • @retval true Button pressed
    bool CheckButton(void)
    bool value;
    int res = dwm_gpio_value_get( SLEEP_BTN_GPIO, &value);
    if ( res != DWM_OK ) {
    // in case of any error assuming button is not pressed
    return false;
    // check pin value, light LED if pressed and return current button state
    if ( value == 0 ) {
    res = dwm_gpio_value_set( LED_BTN_GPIO, false);
    return true;
    res = dwm_gpio_value_set( LED_BTN_GPIO, true);
    return false;


  • Application thread
  • @param[in] data Pointer to user data
    void app_thread_entry(uint32_t data)

    // some initialisation
    // Config GPIO2(user wakeup button)
    dwm_gpio_cfg_input( SLEEP_BTN_GPIO, DWM_GPIO_PIN_PULLUP);
    // configure LED pin, blink twice
    dwm_gpio_cfg_output( LED_BTN_GPIO, false);

    // only task is to check User Button
    while (1) {
    Thread loop */
    if ( CheckButton() ) {
    sleep_btn_counter = 0;
    // delay 20ms


i tried this code but i cant turn on and turn off the LED