Skip to content

Commit

Permalink
feat(external coex): add set tx line flag api
Browse files Browse the repository at this point in the history
  • Loading branch information
muhaidong committed Jul 13, 2023
1 parent 2f56bd8 commit 7c4cd75
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 16 deletions.
8 changes: 6 additions & 2 deletions components/esp_coex/include/esp_coexist.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ esp_err_t esp_disable_extern_coex_gpio_pin();
* @brief Configure leader work mode, gpio pin correspondly and finally enable external coex,
* demand not to call the legacy function of `esp_enable_extern_coex_gpio_pin` any more.
* @param wire_type : to select the whole external coex gpio number.
* @param gpio_pin : gpio pin number to select.
* @param request : request gpio pin number to select.
* @param priority : priority gpio pin number to select.
* @param grant : grant gpio pin number to select.
* @return : ESP_OK - success, other - failed
*/
esp_err_t esp_external_coex_leader_role_set_gpio_pin(external_coex_wire_t wire_type, uint32_t request, uint32_t priority,
Expand All @@ -177,7 +179,9 @@ esp_err_t esp_external_coex_leader_role_set_gpio_pin(external_coex_wire_t wire_t
* @brief Configure follower work mode, gpio pin correspondly and finally enable external coex,
* demand not to call the legacy function of `esp_enable_extern_coex_gpio_pin` any more.
* @param wire_type : to select the whole external coex gpio number.
* @param gpio_pin : gpio pin number to select.
* @param request : request gpio pin number to select.
* @param priority : priority gpio pin number to select.
* @param grant : grant gpio pin number to select.
* @return : ESP_OK - success, other - failed
*/
esp_err_t esp_external_coex_follower_role_set_gpio_pin(external_coex_wire_t wire_type, uint32_t request, uint32_t priority,
Expand Down
17 changes: 16 additions & 1 deletion components/esp_coex/include/esp_coexist_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,13 @@ esp_err_t esp_coex_adapter_register(coex_adapter_funcs_t *funcs);
/**
* @brief Set external coexistence advanced informations, like working mode.
*
* @param out_pti1 This parameter no longer works, will be deprecated and later removed in future releases.
* @param out_pti2 This parameter no longer works, will be deprecated and later removed in future releases.
*
* @return
* - ESP_OK: succeed
*/
esp_err_t esp_coex_external_params(esp_external_coex_advance_t coex_info);
esp_err_t esp_coex_external_params(esp_external_coex_advance_t coex_info, uint32_t out_pti1, uint32_t out_pti2);

/**
* @brief Set external coexistence pti level and enable it.
Expand All @@ -333,6 +336,18 @@ esp_err_t esp_coex_external_set(esp_coex_pti_level_t level1,
* - ESP_OK: succeed
*/
void esp_coex_external_stop(void);

#if SOC_EXTERNAL_COEX_LEADER_TX_LINE
/**
* @brief Enable external coexist tx line
*
* @param en Enable external coex tx line
*
* @return
* - ESP_OK: succeed
*/
void esp_coex_external_set_txline(bool en);
#endif /*SOC_EXTERNAL_COEX_LEADER_TX_LINE*/
#endif /*External Coex*/

/**
Expand Down
8 changes: 5 additions & 3 deletions components/esp_coex/src/coexist.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ esp_err_t esp_enable_extern_coex_gpio_pin(external_coex_wire_t wire_type, esp_ex
}

#if SOC_EXTERNAL_COEX_ADVANCE
esp_coex_external_params(g_external_coex_params);
esp_coex_external_params(g_external_coex_params, 0, 0);
#endif

if(EXTERNAL_COEX_LEADER_ROLE == g_external_coex_params.work_mode) {
Expand All @@ -173,6 +173,7 @@ esp_err_t esp_enable_extern_coex_gpio_pin(external_coex_wire_t wire_type, esp_ex
#if SOC_EXTERNAL_COEX_LEADER_TX_LINE
case EXTERN_COEX_WIRE_4:
{
esp_coex_external_set_txline(true);
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.tx_line], PIN_FUNC_GPIO);
gpio_set_direction(gpio_pin.tx_line, GPIO_MODE_OUTPUT);
REG_WRITE(GPIO_ENABLE_W1TC_REG, BIT(gpio_pin.tx_line));
Expand Down Expand Up @@ -254,10 +255,11 @@ esp_err_t esp_enable_extern_coex_gpio_pin(external_coex_wire_t wire_type, esp_ex
return ESP_FAIL;
}
}
#endif /* SOC_EXTERNAL_COEX_ADVANCE */
#else
return ESP_ERR_INVALID_ARG;
#endif /* SOC_EXTERNAL_COEX_ADVANCE */
}
int ret = esp_coex_external_set(EXTERN_COEX_PTI_MID, EXTERN_COEX_PTI_MID, EXTERN_COEX_PTI_HIGH);
esp_err_t ret = esp_coex_external_set(EXTERN_COEX_PTI_MID, EXTERN_COEX_PTI_MID, EXTERN_COEX_PTI_HIGH);
if (ESP_OK != ret) {
return ESP_FAIL;
}
Expand Down
16 changes: 8 additions & 8 deletions examples/wifi/iperf/main/cmd_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,21 @@ void initialise_wifi(void)
ESP_ERROR_CHECK(esp_wifi_start() );

#if CONFIG_EXTERNAL_COEX_ENABLE
#if SOC_EXTERNAL_COEX_ADVANCE
uint32_t request = 1;
uint32_t priority = 2;
uint32_t grant = 3;
ESP_ERROR_CHECK(esp_external_coex_leader_role_set_gpio_pin(EXTERN_COEX_WIRE_3, request, priority, grant));
#else
esp_external_coex_gpio_set_t gpio_pin;
gpio_pin.request = 1;
gpio_pin.priority = 2;
gpio_pin.grant = 3;
#if SOC_EXTERNAL_COEX_LEADER_TX_LINE
gpio_pin.tx_line = 4;
#endif

esp_external_coex_set_work_mode(EXTERNAL_COEX_LEADER_ROLE);
#if SOC_EXTERNAL_COEX_LEADER_TX_LINE
ESP_ERROR_CHECK(esp_enable_extern_coex_gpio_pin(EXTERN_COEX_WIRE_4, gpio_pin));
#endif
#endif
#else
ESP_ERROR_CHECK(esp_enable_extern_coex_gpio_pin(EXTERN_COEX_WIRE_3, gpio_pin));
#endif /* SOC_EXTERNAL_COEX_LEADER_TX_LINE */
#endif /* CONFIG_EXTERNAL_COEX_ENABLE */

#if CONFIG_ESP_WIFI_ENABLE_WIFI_RX_STATS
#if CONFIG_ESP_WIFI_ENABLE_WIFI_RX_MU_STATS
Expand Down

0 comments on commit 7c4cd75

Please sign in to comment.