Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Button not work in light-switch Server example for PCA10059

Dear

I have changed light_switch server example of " nrf5_SDK_for_Mesh_v4.0.0_src" from PCA10056 to PCA10059. All function of the code works well except button.

For button, I modified something below:

  1. pca10059.h

// There is only one button for the application

// as the second button is used for a RESET.

#define BUTTONS_NUMBER 4

 #define BUTTON_1       NRF_GPIO_PIN_MAP(1,6)

#define BUTTON_2       NRF_GPIO_PIN_MAP(1,2)

#define BUTTON_3       NRF_GPIO_PIN_MAP(1,5)

#define BUTTON_4       NRF_GPIO_PIN_MAP(1,3)

#define BUTTON_PULL    NRF_GPIO_PIN_PULLUP

 #define BUTTONS_ACTIVE_STATE 0

 #define BUTTONS_LIST { BUTTON_1,BUTTON_2,BUTTON_3,BUTTON_4, }

 #define BSP_BUTTON_0   BUTTON_1

#define BSP_BUTTON_1   BUTTON_2

#define BSP_BUTTON_2   BUTTON_3

#define BSP_BUTTON_3   BUTTON_4

 #define BSP_SELF_PINRESET_PIN NRF_GPIO_PIN_MAP(0,19)

 #define HWFC           true

 

  1. simple_hal.h

/** Boards with user buttons */

#define BUTTON_BOARD (defined(BOARD_PCA10059) || defined(BOARD_PCA10040) || defined(BOARD_PCA10028) || defined(BOARD_PCA10056) || defined(BOARD_PCA10100))

 

Building them was successful, Flashing the code to dongle was successful. When push the button(SW1) on dongle, nothing happened(In PCA10056, Push button1, the led should turn on or turn off)

 Did I miss anything or something wrong I did?

 

Thanks,

 

Di-Sheng

Parents Reply Children
  • Hi Anuprit,

    Last post is not clear

    Please follow below step to make button works in light-switch server project

    The frist, you should modify the project for make it match PCA10059

    Below step just for make button works.

    1.  In pcs10059.h

    modify to :

    #define BUTTONS_NUMBER 4

    #define BUTTON_1 6
    #define BUTTON_2 6
    #define BUTTON_3 6
    #define BUTTON_4 6

    2. In simple_hal.c

    Add:

    #if defined(BOARD_PCA10059)
    #ifndef NRF_GPIO1
    #define NRF_GPIO1 NRF_P1
    #endif
    #ifndef NRF_GPIO1_BASE
    #define NRF_GPIO1_BASE NRF_P1_BASE
    #endif

    uint32_t hal_buttons_init(hal_button_handler_cb_t cb)
    {
    ..........

    for (uint32_t i = 0; i < BUTTONS_NUMBER ; ++i)
    {

    //2020-0828 button debug start
    #if defined(BOARD_PCA10059)
    NRF_GPIO1->PIN_CNF[m_buttons_list[i]] = BUTTON_PIN_CONFIG;
    #else
    NRF_GPIO->PIN_CNF[m_buttons_list[i]] = BUTTON_PIN_CONFIG;
    #endif
    //2020-0828 button debug end
    }

    ...........
    }

    void GPIOTE_IRQHandler(void)
    {
    .......
    ////////////2020-0828 button debug start
    #if defined(BOARD_PCA10059)
    if ((~NRF_GPIO1->IN & (1 << (m_buttons_list[i]))) &&
    TIMER_DIFF(m_last_button_press, NRF_RTC1->COUNTER) > HAL_BUTTON_PRESS_FREQUENCY)
    #else
    if ((~NRF_GPIO->IN & (1 << (m_buttons_list[i]))) &&
    TIMER_DIFF(m_last_button_press, NRF_RTC1->COUNTER) > HAL_BUTTON_PRESS_FREQUENCY)
    #endif ////////////2020-0828 button debug end
    ..........
    }

    I think it will works.

    Thanks,

    B,Rs,

    Di-Sheng

    Hi Anuprit

Related