Hi. I have a problem with my NRF52840 Dongle. When using BSP driven button. I've tried to use some SDK precompiled examples - it doesn't work. Neither with ble_peripheral, nor ZigBee or Thread examples. Then I tried this code:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
#include "boards.h"
int main(){
bsp_board_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS);
while (true)
{
if (bsp_board_button_state_get(BSP_BUTTON_0)){
bsp_board_led_invert(BSP_BOARD_LED_2);
}
}
}
But the following code, which is intended to perform the same action:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "boards.h"
#include "app_timer.h"
#include "app_button.h"
static void buttons_handler(uint8_t pin, uint8_t action)
{
if (pin == BSP_BOARD_BUTTON_0){
if (action == APP_BUTTON_PUSH){
bsp_board_led_invert(BSP_BOARD_LED_0);
}
}
}
int main(void)
{
bsp_board_init(BSP_INIT_LEDS);
app_timer_init();
static app_button_cfg_t buttons [] = {
{BSP_BOARD_BUTTON_0, false, BUTTON_PULL, buttons_handler}
};
app_button_init(buttons, ARRAY_SIZE(buttons), APP_TIMER_TICKS(50));
This code works well:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdbool.h>
#include <stdint.h>
#include "boards.h"
#include "bsp.h"
#include "app_timer.h"
#include "nordic_common.h"
void bsp_evt_handler(bsp_event_t evt)
{
switch (evt)
{
case BSP_EVENT_KEY_0:
bsp_board_led_invert(BSP_BOARD_LED_0);
break;
default:
return;
}
}
int main(void){
But the same construction in examples doesn't work (Ble blinky, for example).
I need some help because I don't know, where to look for some kind of solution.