This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to add custom button using BSP?

Hello,

How to ass custom button using BSP? In the default setting, there are only 4 buttons. But my custom board has more than 4 buttons. How to add more button using BSP?? I increase "BUTTONS_NUMBER" and corresponding other values also, like BUTTON_x, BSP_BUTTON_x... But think I've done right, But I got error(NRF_ERROR_INVALID_STATE) from "bsp_init".

Do I have to modify other file also?? Or there is some limit of the number of buttons. Thank you.

Parents
  • I did exactly what you said. here is my code related the the buttons in my custom bsp header file.

    #define BUTTONS_NUMBER 5
    #define BUTTON_START   1
    #define BUTTON_1       1
    #define BUTTON_2       2
    #define BUTTON_3       3
    #define BUTTON_4       4
    #define BUTTON_5       5
    #define BUTTON_STOP    5
    #define BUTTON_PULL    NRF_GPIO_PIN_PULLUP
    
    #define BUTTONS_LIST { BUTTON_1, BUTTON_2, BUTTON_3, BUTTON_4, BUTTON_5}
    
    #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_BUTTON_4   BUTTON_5
    
    #define BSP_BUTTON_0_MASK (1<<BSP_BUTTON_0)
    #define BSP_BUTTON_1_MASK (1<<BSP_BUTTON_1)
    #define BSP_BUTTON_2_MASK (1<<BSP_BUTTON_2)
    #define BSP_BUTTON_3_MASK (1<<BSP_BUTTON_3)
    #define BSP_BUTTON_4_MASK (1<<BSP_BUTTON_4)
    
    //#define BUTTONS_MASK   0x000007FE
    #define BUTTONS_MASK   0x0000003E
    

    What is wrong with the code? FYI, I am using S130, 2.0.1, and ble_app_uart_c_s130 example.

    I got

    NRF_ERROR_INVALID_STATE (If button or GPIOTE has not been initialized). error from bsp_init.

Reply
  • I did exactly what you said. here is my code related the the buttons in my custom bsp header file.

    #define BUTTONS_NUMBER 5
    #define BUTTON_START   1
    #define BUTTON_1       1
    #define BUTTON_2       2
    #define BUTTON_3       3
    #define BUTTON_4       4
    #define BUTTON_5       5
    #define BUTTON_STOP    5
    #define BUTTON_PULL    NRF_GPIO_PIN_PULLUP
    
    #define BUTTONS_LIST { BUTTON_1, BUTTON_2, BUTTON_3, BUTTON_4, BUTTON_5}
    
    #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_BUTTON_4   BUTTON_5
    
    #define BSP_BUTTON_0_MASK (1<<BSP_BUTTON_0)
    #define BSP_BUTTON_1_MASK (1<<BSP_BUTTON_1)
    #define BSP_BUTTON_2_MASK (1<<BSP_BUTTON_2)
    #define BSP_BUTTON_3_MASK (1<<BSP_BUTTON_3)
    #define BSP_BUTTON_4_MASK (1<<BSP_BUTTON_4)
    
    //#define BUTTONS_MASK   0x000007FE
    #define BUTTONS_MASK   0x0000003E
    

    What is wrong with the code? FYI, I am using S130, 2.0.1, and ble_app_uart_c_s130 example.

    I got

    NRF_ERROR_INVALID_STATE (If button or GPIOTE has not been initialized). error from bsp_init.

Children
No Data
Related