12
12
#include "esp_event.h"
13
13
#include "esp_netif_ppp.h"
14
14
#include "eppp_link.h"
15
+ #include "esp_serial_slave_link/essl_sdio.h"
15
16
16
17
#if CONFIG_EPPP_LINK_DEVICE_SPI
17
18
#include "driver/spi_master.h"
@@ -86,7 +87,18 @@ struct eppp_handle {
86
87
bool netif_stop ;
87
88
};
88
89
89
-
90
+ typedef esp_err_t (* transmit_t )(void * h , void * buffer , size_t len );
91
+
92
+ #if CONFIG_EPPP_LINK_DEVICE_SDIO
93
+ esp_err_t eppp_sdio_host_tx (void * h , void * buffer , size_t len );
94
+ esp_err_t eppp_sdio_host_rx (esp_netif_t * netif );
95
+ esp_err_t eppp_sdio_slave_rx (esp_netif_t * netif );
96
+ esp_err_t eppp_sdio_slave_tx (void * h , void * buffer , size_t len );
97
+ esp_err_t eppp_sdio_host_init (struct eppp_config_sdio_s * config );
98
+ esp_err_t eppp_sdio_slave_init (void );
99
+ void eppp_sdio_slave_deinit (void );
100
+ void eppp_sdio_host_deinit (void );
101
+ #else
90
102
static esp_err_t transmit (void * h , void * buffer , size_t len )
91
103
{
92
104
struct eppp_handle * handle = h ;
@@ -125,9 +137,10 @@ static esp_err_t transmit(void *h, void *buffer, size_t len)
125
137
#elif CONFIG_EPPP_LINK_DEVICE_UART
126
138
ESP_LOG_BUFFER_HEXDUMP ("ppp_uart_send" , buffer , len , ESP_LOG_VERBOSE );
127
139
uart_write_bytes (handle -> uart_port , buffer , len );
128
- #endif
140
+ #endif // DEVICE UART or SPI
129
141
return ESP_OK ;
130
142
}
143
+ #endif
131
144
132
145
static void netif_deinit (esp_netif_t * netif )
133
146
{
@@ -209,7 +222,11 @@ static esp_netif_t *netif_init(eppp_type_t role, eppp_config_t *eppp_config)
209
222
210
223
esp_netif_driver_ifconfig_t driver_cfg = {
211
224
.handle = h ,
225
+ #if CONFIG_EPPP_LINK_DEVICE_SDIO
226
+ .transmit = role == EPPP_CLIENT ? eppp_sdio_host_tx : eppp_sdio_slave_tx ,
227
+ #else
212
228
.transmit = transmit ,
229
+ #endif
213
230
};
214
231
const esp_netif_driver_ifconfig_t * ppp_driver_cfg = & driver_cfg ;
215
232
@@ -657,6 +674,20 @@ esp_err_t eppp_perform(esp_netif_t *netif)
657
674
}
658
675
return ESP_OK ;
659
676
}
677
+ #elif CONFIG_EPPP_LINK_DEVICE_SDIO
678
+
679
+ esp_err_t eppp_perform (esp_netif_t * netif )
680
+ {
681
+ struct eppp_handle * h = esp_netif_get_io_driver (netif );
682
+ if (h -> stop ) {
683
+ return ESP_ERR_TIMEOUT ;
684
+ }
685
+ if (h -> role == EPPP_SERVER ) {
686
+ return eppp_sdio_slave_rx (netif );
687
+ } else {
688
+ return eppp_sdio_host_rx (netif );
689
+ }
690
+ }
660
691
661
692
#endif // CONFIG_EPPP_LINK_DEVICE_SPI / UART
662
693
@@ -700,6 +731,13 @@ void eppp_deinit(esp_netif_t *netif)
700
731
}
701
732
#elif CONFIG_EPPP_LINK_DEVICE_UART
702
733
deinit_uart (esp_netif_get_io_driver (netif ));
734
+ #elif CONFIG_EPPP_LINK_DEVICE_SDIO
735
+ struct eppp_handle * h = esp_netif_get_io_driver (netif );
736
+ if (h -> role == EPPP_CLIENT ) {
737
+ eppp_sdio_host_deinit ();
738
+ } else {
739
+ eppp_sdio_slave_deinit ();
740
+ }
703
741
#endif
704
742
netif_deinit (netif );
705
743
}
@@ -714,7 +752,6 @@ esp_netif_t *eppp_init(eppp_type_t role, eppp_config_t *config)
714
752
esp_netif_t * netif = netif_init (role , config );
715
753
if (!netif ) {
716
754
ESP_LOGE (TAG , "Failed to initialize PPP netif" );
717
- remove_handlers ();
718
755
return NULL ;
719
756
}
720
757
esp_netif_ppp_config_t netif_params ;
@@ -732,6 +769,18 @@ esp_netif_t *eppp_init(eppp_type_t role, eppp_config_t *config)
732
769
}
733
770
#elif CONFIG_EPPP_LINK_DEVICE_UART
734
771
init_uart (esp_netif_get_io_driver (netif ), config );
772
+ #elif CONFIG_EPPP_LINK_DEVICE_SDIO
773
+ esp_err_t ret ;
774
+ if (role == EPPP_SERVER ) {
775
+ ret = eppp_sdio_slave_init ();
776
+ } else {
777
+ ret = eppp_sdio_host_init (& config -> sdio );
778
+ }
779
+
780
+ if (ret != ESP_OK ) {
781
+ ESP_LOGE (TAG , "Failed to initialize SDIO %d" , ret );
782
+ return NULL ;
783
+ }
735
784
#endif
736
785
return netif ;
737
786
}
@@ -754,6 +803,12 @@ esp_netif_t *eppp_open(eppp_type_t role, eppp_config_t *config, int connect_time
754
803
return NULL ;
755
804
}
756
805
#endif
806
+ #if CONFIG_EPPP_LINK_DEVICE_SDIO
807
+ if (config -> transport != EPPP_TRANSPORT_SDIO ) {
808
+ ESP_LOGE (TAG , "Invalid transport: SDIO device must be enabled in Kconfig" );
809
+ return NULL ;
810
+ }
811
+ #endif
757
812
758
813
if (config -> task .run_task == false) {
759
814
ESP_LOGE (TAG , "task.run_task == false is invalid in this API. Please use eppp_init()" );
0 commit comments