samples: bluetooth: mesh_demo: Align with changes in pwm_nrf5_sw driver

- add an overlay file for the bbc_microbit board with specification
  of GPIO that should be used as the PWM output to buzzer
- update a PWM related macro in the microbit specific code to refer
  to PWM channel instead of pin

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This commit is contained in:
Andrzej Głąbek 2022-04-21 12:47:11 +02:00 committed by Carles Cufí
parent 92b3cc78e7
commit 00f878f6f3
3 changed files with 8 additions and 7 deletions

View file

@ -8,8 +8,6 @@ project(mesh_demo)
target_sources(app PRIVATE src/main.c)
target_sources_ifdef(CONFIG_BOARD_BBC_MICROBIT app PRIVATE src/microbit.c)
zephyr_include_directories_ifdef(CONFIG_BOARD_BBC_MICROBIT
${ZEPHYR_BASE}/boards/arm/bbc_microbit)
if(NODE_ADDR)
zephyr_compile_definitions(NODE_ADDR=${NODE_ADDR})

View file

@ -0,0 +1,4 @@
&sw_pwm {
status = "okay";
channel-gpios = <&edge_connector 0 GPIO_ACTIVE_HIGH>;
};

View file

@ -7,7 +7,6 @@
*/
#include <drivers/gpio.h>
#include <board.h>
#include <soc.h>
#include <sys/printk.h>
#include <ctype.h>
@ -22,7 +21,7 @@
#define SCROLL_SPEED 300
#define BUZZER_PIN EXT_P0_GPIO_PIN
#define BUZZER_PWM_CHANNEL 0
#define BEEP_DURATION K_MSEC(60)
#define SEQ_PER_BIT 976
@ -130,14 +129,14 @@ void board_play_tune(const char *str)
}
if (period) {
pwm_pin_set_usec(pwm, BUZZER_PIN, period, period / 2U,
0);
pwm_pin_set_usec(pwm, BUZZER_PWM_CHANNEL,
period, period / 2U, 0);
}
k_sleep(K_MSEC(duration));
/* Disable the PWM */
pwm_pin_set_usec(pwm, BUZZER_PIN, 0, 0, 0);
pwm_pin_set_usec(pwm, BUZZER_PWM_CHANNEL, 0, 0, 0);
}
}