From 8f0766c56e727023c179cfbbc019ec1a2ea29680 Mon Sep 17 00:00:00 2001 From: wangmengyang Date: Fri, 17 Feb 2023 13:03:29 +0800 Subject: [PATCH] bt: added coex adapter operation to get version of coexist module to ESP32 Bluetooth Controller --- components/bt/controller/esp32/bt.c | 30 ++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/components/bt/controller/esp32/bt.c b/components/bt/controller/esp32/bt.c index 618b903997..df120520c5 100644 --- a/components/bt/controller/esp32/bt.c +++ b/components/bt/controller/esp32/bt.c @@ -33,6 +33,7 @@ #include "soc/rtc.h" #include "soc/soc_memory_layout.h" #include "esp32/clk.h" +#include "esp_coexist.h" #include "esp_coexist_internal.h" #include "esp_timer.h" #if !CONFIG_FREERTOS_UNICORE @@ -85,7 +86,7 @@ do{\ } while(0) #define OSI_FUNCS_TIME_BLOCKING 0xffffffff -#define OSI_VERSION 0x00010003 +#define OSI_VERSION 0x00010004 #define OSI_MAGIC_VALUE 0xFADEBEAD @@ -173,6 +174,7 @@ struct osi_funcs_t { void (*_interrupt_l3_disable)(void); void (*_interrupt_l3_restore)(void); void *(* _customer_queue_create)(uint32_t queue_len, uint32_t item_size); + int (* _coex_version_get)(unsigned int *major, unsigned int *minor, unsigned int *patch); uint32_t _magic; }; @@ -305,6 +307,7 @@ static uint8_t coex_schm_curr_period_get_wrapper(void); static void * coex_schm_curr_phase_get_wrapper(void); static int coex_wifi_channel_get_wrapper(uint8_t *primary, uint8_t *secondary); static int coex_register_wifi_channel_change_callback_wrapper(void *cb); +static int coex_version_get_wrapper(unsigned int *major, unsigned int *minor, unsigned int *patch); static void bt_controller_deinit_internal(void); /* Local variable definition @@ -372,6 +375,7 @@ static const struct osi_funcs_t osi_funcs_ro = { ._interrupt_l3_disable = interrupt_disable, ._interrupt_l3_restore = interrupt_restore, ._customer_queue_create = NULL, + ._coex_version_get = coex_version_get_wrapper, ._magic = OSI_MAGIC_VALUE, }; @@ -997,6 +1001,30 @@ static int coex_register_wifi_channel_change_callback_wrapper(void *cb) #endif } +static int coex_version_get_wrapper(unsigned int *major, unsigned int *minor, unsigned int *patch) +{ +#if CONFIG_SW_COEXIST_ENABLE + const char *ver_str = esp_coex_version_get(); + if (ver_str != NULL) { + unsigned int _major = 0, _minor = 0, _patch = 0; + if (sscanf(ver_str, "%u.%u.%u", &_major, &_minor, &_patch) != 3) { + return -1; + } + if (major != NULL) { + *major = _major; + } + if (minor != NULL) { + *minor = _minor; + } + if (patch != NULL) { + *patch = _patch; + } + return 0; + } +#endif + return -1; +} + bool esp_vhci_host_check_send_available(void) { return API_vhci_host_check_send_available();