@@ -234,18 +234,32 @@ extern "C" void phy_bbpll_en_usb(bool en);
234
234
#endif
235
235
236
236
#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 ;
238
244
239
245
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) {
244
257
log_e (" esp_hosted_init failed!" );
258
+ hosted_initialized = false ;
245
259
return false ;
246
260
}
247
261
}
248
- // Attach pins to periman here
262
+ // Attach pins to PeriMan here
249
263
// Slave chip model is CONFIG_IDF_SLAVE_TARGET
250
264
// CONFIG_ESP_SDIO_PIN_CMD
251
265
// CONFIG_ESP_SDIO_PIN_CLK
@@ -331,6 +345,12 @@ static bool wifiLowLevelDeinit() {
331
345
arduino_event_t arduino_event;
332
346
arduino_event.event_id = ARDUINO_EVENT_WIFI_OFF;
333
347
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
334
354
}
335
355
}
336
356
return !lowLevelInitDone;
0 commit comments