|
58 | 58 |
|
59 | 59 | #include "hal/efuse_hal.h" |
60 | 60 | #include "soc/rtc.h" |
| 61 | +#include "modem/modem_syscon_struct.h" |
61 | 62 |
|
62 | 63 | #if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED |
63 | 64 | #include "ble_log/ble_log_spi_out.h" |
|
70 | 71 | #define OSI_COEX_VERSION 0x00010006 |
71 | 72 | #define OSI_COEX_MAGIC_VALUE 0xFADEBEAD |
72 | 73 |
|
73 | | -#define EXT_FUNC_VERSION 0x20240422 |
| 74 | +#define EXT_FUNC_VERSION 0x20250415 |
74 | 75 | #define EXT_FUNC_MAGIC_VALUE 0xA5A5A5A5 |
75 | 76 |
|
76 | 77 | #define BT_ASSERT_PRINT ets_printf |
@@ -101,17 +102,29 @@ struct ext_funcs_t { |
101 | 102 | int (* _ecc_gen_key_pair)(uint8_t *public, uint8_t *priv); |
102 | 103 | int (* _ecc_gen_dh_key)(const uint8_t *remote_pub_key_x, const uint8_t *remote_pub_key_y, |
103 | 104 | const uint8_t *local_priv_key, uint8_t *dhkey); |
104 | | - void (* _esp_reset_rpa_moudle)(void); |
| 105 | +#if CONFIG_IDF_TARGET_ESP32C6 |
| 106 | + void (* _esp_reset_modem)(uint8_t mdl_opts, uint8_t start); |
| 107 | +#endif // CONFIG_IDF_TARGET_ESP32C6 |
105 | 108 | uint32_t magic; |
106 | 109 | }; |
107 | 110 |
|
108 | 111 | #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED |
109 | 112 | typedef void (*interface_func_t) (uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag); |
| 113 | + |
| 114 | +enum { |
| 115 | + BLE_LOG_INTERFACE_FLAG_CONTINUE = 0, |
| 116 | + BLE_LOG_INTERFACE_FLAG_END, |
| 117 | +}; |
110 | 118 | #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED |
111 | 119 |
|
112 | 120 | /* External functions or variables |
113 | 121 | ************************************************************************ |
114 | 122 | */ |
| 123 | +#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE |
| 124 | +extern void coex_hw_timer_set(uint8_t idx,uint8_t src, uint8_t pti,uint32_t latency, uint32_t perioidc); |
| 125 | +extern void coex_hw_timer_enable(uint8_t idx); |
| 126 | +extern void coex_hw_timer_disable(uint8_t idx); |
| 127 | +#endif // CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE |
115 | 128 | extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs); |
116 | 129 | extern int r_ble_controller_init(esp_bt_controller_config_t *cfg); |
117 | 130 | extern void esp_ble_controller_info_capture(uint32_t cycle_times); |
@@ -185,7 +198,9 @@ static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler, |
185 | 198 | static int esp_intr_free_wrapper(void **ret_handle); |
186 | 199 | static void osi_assert_wrapper(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2); |
187 | 200 | static uint32_t osi_random_wrapper(void); |
188 | | -static void esp_reset_rpa_moudle(void); |
| 201 | +#if CONFIG_IDF_TARGET_ESP32C6 |
| 202 | +static void esp_reset_modem(uint8_t mdl_opts,uint8_t start); |
| 203 | +#endif // CONFIG_IDF_TARGET_ESP32C6 |
189 | 204 | static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv); |
190 | 205 | static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y, |
191 | 206 | const uint8_t *our_priv_key, uint8_t *out_dhkey); |
@@ -463,15 +478,34 @@ struct ext_funcs_t ext_funcs_ro = { |
463 | 478 | ._os_random = osi_random_wrapper, |
464 | 479 | ._ecc_gen_key_pair = esp_ecc_gen_key_pair, |
465 | 480 | ._ecc_gen_dh_key = esp_ecc_gen_dh_key, |
466 | | - ._esp_reset_rpa_moudle = esp_reset_rpa_moudle, |
| 481 | +#if CONFIG_IDF_TARGET_ESP32C6 |
| 482 | + ._esp_reset_modem = esp_reset_modem, |
| 483 | +#endif // CONFIG_IDF_TARGET_ESP32C6 |
467 | 484 | .magic = EXT_FUNC_MAGIC_VALUE, |
468 | 485 | }; |
469 | 486 |
|
470 | | -static void IRAM_ATTR esp_reset_rpa_moudle(void) |
| 487 | +#if CONFIG_IDF_TARGET_ESP32C6 |
| 488 | +static void IRAM_ATTR esp_reset_modem(uint8_t mdl_opts,uint8_t start) |
471 | 489 | { |
| 490 | + if (mdl_opts == 0x05) { |
| 491 | + if (start) { |
| 492 | +#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE |
| 493 | + coex_hw_timer_set(0x04, 0x02, 15, 0, 5000); |
| 494 | + coex_hw_timer_enable(0x04); |
| 495 | +#endif // CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE |
| 496 | + MODEM_SYSCON.modem_rst_conf.val |= (BIT(16) | BIT(18)); |
| 497 | + MODEM_SYSCON.modem_rst_conf.val &= ~(BIT(16) | BIT(18)); |
| 498 | + } else { |
| 499 | +#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE |
| 500 | + coex_hw_timer_disable(0x04); |
| 501 | +#endif // CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE |
| 502 | + } |
472 | 503 |
|
| 504 | + } |
473 | 505 | } |
474 | 506 |
|
| 507 | +#endif // CONFIG_IDF_TARGET_ESP32C6 |
| 508 | + |
475 | 509 | static void IRAM_ATTR osi_assert_wrapper(const uint32_t ln, const char *fn, |
476 | 510 | uint32_t param1, uint32_t param2) |
477 | 511 | { |
@@ -1452,20 +1486,22 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po |
1452 | 1486 | #if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED |
1453 | 1487 | static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag) |
1454 | 1488 | { |
1455 | | - bool end = flag ? true : false; |
| 1489 | + bool end = (flag & BIT(BLE_LOG_INTERFACE_FLAG_END)); |
1456 | 1490 | #if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE |
1457 | 1491 | esp_bt_controller_log_storage(len, addr, end); |
1458 | 1492 | #else // !CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE |
1459 | 1493 | portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED; |
1460 | 1494 | portENTER_CRITICAL_SAFE(&spinlock); |
1461 | 1495 | esp_panic_handler_feed_wdts(); |
1462 | | - for (int i = 0; i < len; i++) { |
1463 | | - esp_rom_printf("%02x ", addr[i]); |
1464 | | - } |
1465 | 1496 |
|
1466 | | - if (end) { |
1467 | | - esp_rom_printf("\n"); |
| 1497 | + if (len && addr) { |
| 1498 | + for (int i = 0; i < len; i++) { esp_rom_printf("%02x ", addr[i]); } |
1468 | 1499 | } |
| 1500 | + if (len_append && addr_append) { |
| 1501 | + for (int i = 0; i < len_append; i++) { esp_rom_printf("%02x ", addr_append[i]); } |
| 1502 | + } |
| 1503 | + if (end) { esp_rom_printf("\n"); } |
| 1504 | + |
1469 | 1505 | portEXIT_CRITICAL_SAFE(&spinlock); |
1470 | 1506 | #endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE |
1471 | 1507 | } |
|
0 commit comments