Skip to content

Commit a62841b

Browse files
committed
fix(hosted): Update hosted configuration
1 parent 7b3a9ae commit a62841b

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

Diff for: idf_component.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ dependencies:
103103
rules:
104104
- if: "target in [esp32s3]"
105105
espressif/esp_hosted:
106-
version: "^0.0.22"
106+
version: "^0.0.25"
107107
rules:
108108
- if: "target == esp32p4"
109109
espressif/esp_wifi_remote:

Diff for: libraries/WiFi/src/WiFiGeneric.cpp

+26-6
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,32 @@ extern "C" void phy_bbpll_en_usb(bool en);
234234
#endif
235235

236236
#if CONFIG_ESP_WIFI_REMOTE_ENABLED
237-
extern "C" esp_err_t esp_hosted_init(void *);
237+
extern "C" {
238+
//#include "esp_hosted.h"
239+
#include "esp_hosted_transport_config.h"
240+
extern esp_err_t esp_hosted_init();
241+
extern esp_err_t esp_hosted_deinit();
242+
};
243+
static bool hosted_initialized = false;
238244

239245
static bool wifiHostedInit() {
240-
static bool initialized = false;
241-
if (!initialized) {
242-
initialized = true;
243-
if (esp_hosted_init(NULL) != ESP_OK) {
246+
if (!hosted_initialized) {
247+
hosted_initialized = true;
248+
struct esp_hosted_sdio_config conf = INIT_DEFAULT_HOST_SDIO_CONFIG();
249+
conf.pin_clk.pin = CONFIG_ESP_SDIO_PIN_CLK;
250+
conf.pin_cmd.pin = CONFIG_ESP_SDIO_PIN_CMD;
251+
conf.pin_d0.pin = CONFIG_ESP_SDIO_PIN_D0;
252+
conf.pin_d1.pin = CONFIG_ESP_SDIO_PIN_D1;
253+
conf.pin_d2.pin = CONFIG_ESP_SDIO_PIN_D2;
254+
conf.pin_d3.pin = CONFIG_ESP_SDIO_PIN_D3;
255+
//conf.pin_rst.pin = CONFIG_ESP_SDIO_GPIO_RESET_SLAVE;
256+
if (esp_hosted_sdio_set_config(&conf) != ESP_OK || esp_hosted_init() != ESP_OK) {
244257
log_e("esp_hosted_init failed!");
258+
hosted_initialized = false;
245259
return false;
246260
}
247261
}
248-
// Attach pins to periman here
262+
// Attach pins to PeriMan here
249263
// Slave chip model is CONFIG_IDF_SLAVE_TARGET
250264
// CONFIG_ESP_SDIO_PIN_CMD
251265
// CONFIG_ESP_SDIO_PIN_CLK
@@ -331,6 +345,12 @@ static bool wifiLowLevelDeinit() {
331345
arduino_event_t arduino_event;
332346
arduino_event.event_id = ARDUINO_EVENT_WIFI_OFF;
333347
Network.postEvent(&arduino_event);
348+
#if CONFIG_ESP_WIFI_REMOTE_ENABLED
349+
if (!hosted_initialized && esp_hosted_deinit() == ESP_OK) {
350+
hosted_initialized = false;
351+
// detach SDIO pins from PeriMan
352+
}
353+
#endif
334354
}
335355
}
336356
return !lowLevelInitDone;

0 commit comments

Comments
 (0)