samples: bbc_microbit: Align with recent changes in pwm_nrf5_sw driver
- add `channel-gpios` property with GPIO assignments for PWM channels to `sw_pwm` nodes - update PWM related macros to refer to channels instead of pins - remove no longer needed inclusion of boards/arm/bbc_microbit/board.h Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This commit is contained in:
parent
7760e7c02d
commit
34630a81dd
|
@ -7,4 +7,3 @@ project(pong)
|
|||
|
||||
FILE(GLOB app_sources src/*.c)
|
||||
target_sources(app PRIVATE ${app_sources})
|
||||
zephyr_include_directories(${ZEPHYR_BASE}/boards/arm/bbc_microbit)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
&sw_pwm {
|
||||
status = "okay";
|
||||
channel-gpios = <&edge_connector 0 GPIO_ACTIVE_HIGH>;
|
||||
};
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <zephyr.h>
|
||||
#include <sys/printk.h>
|
||||
#include <board.h>
|
||||
#include <drivers/gpio.h>
|
||||
#include <device.h>
|
||||
#include <string.h>
|
||||
|
@ -107,7 +106,7 @@ static struct x_y ball_vel = { 0, 0 };
|
|||
static int64_t a_timestamp;
|
||||
static int64_t b_timestamp;
|
||||
|
||||
#define SOUND_PIN EXT_P0_GPIO_PIN
|
||||
#define SOUND_PWM_CHANNEL 0
|
||||
#define SOUND_PERIOD_PADDLE 200
|
||||
#define SOUND_PERIOD_WALL 1000
|
||||
|
||||
|
@ -121,7 +120,7 @@ static enum sound_state {
|
|||
|
||||
static inline void beep(int period)
|
||||
{
|
||||
pwm_pin_set_usec(pwm, SOUND_PIN, period, period / 2, 0);
|
||||
pwm_pin_set_usec(pwm, SOUND_PWM_CHANNEL, period, period / 2, 0);
|
||||
}
|
||||
|
||||
static void sound_set(enum sound_state state)
|
||||
|
|
|
@ -7,4 +7,3 @@ project(sound)
|
|||
|
||||
FILE(GLOB app_sources src/*.c)
|
||||
target_sources(app PRIVATE ${app_sources})
|
||||
zephyr_include_directories(${ZEPHYR_BASE}/boards/arm/bbc_microbit)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
&sw_pwm {
|
||||
status = "okay";
|
||||
channel-gpios = <&edge_connector 0 GPIO_ACTIVE_HIGH>;
|
||||
};
|
|
@ -6,14 +6,13 @@
|
|||
|
||||
#include <zephyr.h>
|
||||
#include <sys/printk.h>
|
||||
#include <board.h>
|
||||
#include <drivers/gpio.h>
|
||||
#include <drivers/pwm.h>
|
||||
#include <device.h>
|
||||
|
||||
#include <display/mb_display.h>
|
||||
|
||||
#define BUZZER_PIN EXT_P0_GPIO_PIN
|
||||
#define BUZZER_PWM_CHANNEL 0
|
||||
|
||||
#define PERIOD_MIN 50
|
||||
#define PERIOD_MAX 3900
|
||||
|
@ -34,11 +33,11 @@ static void beep(struct k_work *work)
|
|||
/* The "period / 2" pulse duration gives 50% duty cycle, which
|
||||
* should result in the maximum sound volume.
|
||||
*/
|
||||
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(BEEP_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);
|
||||
|
||||
/* Ensure there's a clear silent period between two tones */
|
||||
k_sleep(K_MSEC(50));
|
||||
|
|
Loading…
Reference in a new issue