From 561ab18fd0352eeb868f83e33b00789e86fd982e Mon Sep 17 00:00:00 2001 From: Krzysztof Taborowski Date: Wed, 13 Nov 2024 12:39:18 +0100 Subject: [PATCH] samples: add sid pal radio sleep on init [KRKNWK-19545] Signed-off-by: Krzysztof Taborowski --- samples/sid_end_device/src/sidewalk_events.c | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/samples/sid_end_device/src/sidewalk_events.c b/samples/sid_end_device/src/sidewalk_events.c index 112ee2fcc1..da9c6d1ea9 100644 --- a/samples/sid_end_device/src/sidewalk_events.c +++ b/samples/sid_end_device/src/sidewalk_events.c @@ -12,6 +12,7 @@ #include #ifdef CONFIG_SIDEWALK_SUBGHZ_SUPPORT #include +#include #endif /* CONFIG_SIDEWALK_SUBGHZ_SUPPORT */ #include @@ -30,6 +31,20 @@ LOG_MODULE_REGISTER(sidewalk_events, CONFIG_SIDEWALK_LOG_LEVEL); +#ifdef CONFIG_SIDEWALK_SUBGHZ_SUPPORT +static sid_pal_radio_rx_packet_t radio_rx_packet; + +static void radio_event_notifier(sid_pal_radio_events_t event) +{ + LOG_DBG("Radio event %d", event); +} + +static void radio_irq_handler(void) +{ + LOG_DBG("Radio IRQ"); +} +#endif /* CONFIG_SIDEWALK_SUBGHZ_SUPPORT */ + // private void sidewalk_event_process(sidewalk_ctx_t *sid, void *ctx) { @@ -66,6 +81,18 @@ void sidewalk_event_platform_init(sidewalk_ctx_t *sid, void *ctx) LOG_ERR("SIZE: 0x%08x", APP_MFG_CFG_FLASH_SIZE); return; } + +#ifdef CONFIG_SIDEWALK_SUBGHZ_SUPPORT + int32_t err = 0; + err = sid_pal_radio_init(radio_event_notifier, radio_irq_handler, &radio_rx_packet); + if (err) { + LOG_ERR("radio init err %d", err); + } + err = sid_pal_radio_sleep(0); + if (err) { + LOG_ERR("radio sleep err %d", err); + } +#endif /* CONFIG_SIDEWALK_SUBGHZ_SUPPORT */ } void sidewalk_event_autostart(sidewalk_ctx_t *sid, void *ctx)