From 91c46124035779c845cef4a30b52f6b2f905fb86 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 8 May 2024 21:24:32 -0700 Subject: [PATCH] FIXME: initial buzzer support Signed-off-by: Chris Wilson --- boards/aludel_elixir_ns.conf | 5 +++++ src/main.c | 24 ++++++++++++++++++++++++ west.yml | 5 +++++ 3 files changed, 34 insertions(+) diff --git a/boards/aludel_elixir_ns.conf b/boards/aludel_elixir_ns.conf index e97e2cf..e683bd9 100644 --- a/boards/aludel_elixir_ns.conf +++ b/boards/aludel_elixir_ns.conf @@ -40,3 +40,8 @@ CONFIG_BOOTLOADER_MCUBOOT=y # Use Golioth Ostentus Faceplate CONFIG_LIB_OSTENTUS=y + +# Enable Golioth buzzer PWM library +CONFIG_PWM=y +CONFIG_PWM_BUZZER=y +CONFIG_PWM_BUZZER_SONGS=y diff --git a/src/main.c b/src/main.c index 44d158b..98039db 100644 --- a/src/main.c +++ b/src/main.c @@ -16,6 +16,7 @@ LOG_MODULE_REGISTER(golioth_rd_template, LOG_LEVEL_DBG); #include #include #include +#include #ifdef CONFIG_SOC_NRF9160 #include @@ -33,6 +34,18 @@ LOG_MODULE_REGISTER(golioth_rd_template, LOG_LEVEL_DBG); #include #endif +#ifdef CONFIG_PWM_BUZZER +#include +#endif /* CONFIG_PWM_BUZZER */ + +#ifdef CONFIG_PWM_BUZZER_SONGS +#include +#endif /* CONFIG_PWM_BUZZER_SONGS */ + +#if DT_NODE_EXISTS(DT_ALIAS(pwm_buzzer0)) +const struct pwm_dt_spec buzzer = PWM_DT_SPEC_GET(DT_ALIAS(pwm_buzzer0)); +#endif /* DT_NODE_EXISTS(DT_ALIAS(pwm_buzzer0)) */ + /* Current firmware version; update in prj.conf or via build argument */ static const char *_current_version = CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION; @@ -254,6 +267,17 @@ int main(void) slideshow(30000); )); +#ifdef CONFIG_PWM_BUZZER + pwm_buzzer_init(&buzzer); + // pwm_buzzer_beep(&buzzer); +#endif /* CONFIG_PWM_BUZZER */ + +#ifdef CONFIG_PWM_BUZZER_SONGS + // pwm_buzzer_play_funkytown(&buzzer); + pwm_buzzer_play_mario(&buzzer); + // pwm_buzzer_play_golioth(&buzzer); +#endif /* CONFIG_PWM_BUZZER_SONGS */ + while (true) { app_sensors_read_and_stream(); diff --git a/west.yml b/west.yml index 97f8940..61c9a44 100644 --- a/west.yml +++ b/west.yml @@ -46,5 +46,10 @@ manifest: revision: v1.1.1 url: https://github.com/golioth/zephyr-network-info + - name: reference-design-common + path: deps/modules/lib/reference-design-common + revision: 73843d3d0e41e31715d6f663eb87b3d0724ed532 + url: https://github.com/golioth/reference-design-common + self: path: app