Skip to content

Commit d7eaa77

Browse files
authored
Merge pull request #511 from david-cermak/feat/eppp_sdio
[eppp]: Add support for SDIO transport
2 parents a05fbc7 + 402176c commit d7eaa77

File tree

11 files changed

+524
-15
lines changed

11 files changed

+524
-15
lines changed

components/eppp_link/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
idf_component_register(SRCS "eppp_link.c"
1+
idf_component_register(SRCS eppp_link.c eppp_sdio_slave.c eppp_sdio_host.c
22
INCLUDE_DIRS "include"
33
PRIV_REQUIRES esp_netif esp_driver_spi esp_driver_gpio esp_timer driver)

components/eppp_link/Kconfig

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ menu "eppp_link"
2121
bool "SPI"
2222
help
2323
Use SPI.
24+
25+
config EPPP_LINK_DEVICE_SDIO
26+
bool "SDIO"
27+
depends on SOC_SDMMC_HOST_SUPPORTED || SOC_SDIO_SLAVE_SUPPORTED
28+
help
29+
Use SDIO.
30+
2431
endchoice
2532

2633
config EPPP_LINK_CONN_MAX_RETRY
@@ -34,8 +41,30 @@ menu "eppp_link"
3441
config EPPP_LINK_PACKET_QUEUE_SIZE
3542
int "Packet queue size"
3643
default 64
44+
depends on EPPP_LINK_DEVICE_SPI
3745
help
3846
Size of the Tx packet queue.
3947
You can decrease the number for slower bit rates.
4048

49+
choice EPPP_LINK_SDIO_ROLE
50+
prompt "Choose SDIO host or slave"
51+
depends on EPPP_LINK_DEVICE_SDIO
52+
default EPPP_LINK_DEVICE_SDIO_HOST if SOC_SDMMC_HOST_SUPPORTED
53+
help
54+
Select which either SDIO host or slave
55+
56+
config EPPP_LINK_DEVICE_SDIO_HOST
57+
bool "Host"
58+
depends on SOC_SDMMC_HOST_SUPPORTED
59+
help
60+
Use SDIO host.
61+
62+
config EPPP_LINK_DEVICE_SDIO_SLAVE
63+
bool "SLAVE"
64+
depends on SOC_SDIO_SLAVE_SUPPORTED
65+
help
66+
Use SDIO slave.
67+
68+
endchoice
69+
4170
endmenu

components/eppp_link/README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ brings in the WiFi connectivity from the "SLAVE" microcontroller.
1414
SLAVE micro HOST micro
1515
\|/ +----------------+ +----------------+
1616
| | | serial line | |
17-
+---+ WiFi NAT PPPoS |======== UART / SPI =======| PPPoS client |
17+
+---+ WiFi NAT PPPoS |=== UART / SPI / SDIO =====| PPPoS client |
1818
| (server)| | |
1919
+----------------+ +----------------+
2020
```
@@ -39,14 +39,19 @@ brings in the WiFi connectivity from the "SLAVE" microcontroller.
3939

4040
## Throughput
4141

42-
Tested with WiFi-NAPT example, no IRAM optimizations
42+
Tested with WiFi-NAPT example
4343

4444
### UART @ 3Mbauds
4545

4646
* TCP - 2Mbits/s
4747
* UDP - 2Mbits/s
4848

49-
### SPI @ 20MHz
49+
### SPI @ 16MHz
5050

51-
* TCP - 6Mbits/s
52-
* UDP - 10Mbits/s
51+
* TCP - 5Mbits/s
52+
* UDP - 8Mbits/s
53+
54+
### SDIO
55+
56+
* TCP - 9Mbits/s
57+
* UDP - 11Mbits/s

components/eppp_link/eppp_link.c

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "esp_event.h"
1313
#include "esp_netif_ppp.h"
1414
#include "eppp_link.h"
15+
#include "esp_serial_slave_link/essl_sdio.h"
1516

1617
#if CONFIG_EPPP_LINK_DEVICE_SPI
1718
#include "driver/spi_master.h"
@@ -86,7 +87,18 @@ struct eppp_handle {
8687
bool netif_stop;
8788
};
8889

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
90102
static esp_err_t transmit(void *h, void *buffer, size_t len)
91103
{
92104
struct eppp_handle *handle = h;
@@ -125,9 +137,10 @@ static esp_err_t transmit(void *h, void *buffer, size_t len)
125137
#elif CONFIG_EPPP_LINK_DEVICE_UART
126138
ESP_LOG_BUFFER_HEXDUMP("ppp_uart_send", buffer, len, ESP_LOG_VERBOSE);
127139
uart_write_bytes(handle->uart_port, buffer, len);
128-
#endif
140+
#endif // DEVICE UART or SPI
129141
return ESP_OK;
130142
}
143+
#endif
131144

132145
static void netif_deinit(esp_netif_t *netif)
133146
{
@@ -209,7 +222,11 @@ static esp_netif_t *netif_init(eppp_type_t role, eppp_config_t *eppp_config)
209222

210223
esp_netif_driver_ifconfig_t driver_cfg = {
211224
.handle = h,
225+
#if CONFIG_EPPP_LINK_DEVICE_SDIO
226+
.transmit = role == EPPP_CLIENT ? eppp_sdio_host_tx : eppp_sdio_slave_tx,
227+
#else
212228
.transmit = transmit,
229+
#endif
213230
};
214231
const esp_netif_driver_ifconfig_t *ppp_driver_cfg = &driver_cfg;
215232

@@ -657,6 +674,20 @@ esp_err_t eppp_perform(esp_netif_t *netif)
657674
}
658675
return ESP_OK;
659676
}
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+
}
660691

661692
#endif // CONFIG_EPPP_LINK_DEVICE_SPI / UART
662693

@@ -700,6 +731,13 @@ void eppp_deinit(esp_netif_t *netif)
700731
}
701732
#elif CONFIG_EPPP_LINK_DEVICE_UART
702733
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+
}
703741
#endif
704742
netif_deinit(netif);
705743
}
@@ -714,7 +752,6 @@ esp_netif_t *eppp_init(eppp_type_t role, eppp_config_t *config)
714752
esp_netif_t *netif = netif_init(role, config);
715753
if (!netif) {
716754
ESP_LOGE(TAG, "Failed to initialize PPP netif");
717-
remove_handlers();
718755
return NULL;
719756
}
720757
esp_netif_ppp_config_t netif_params;
@@ -732,6 +769,18 @@ esp_netif_t *eppp_init(eppp_type_t role, eppp_config_t *config)
732769
}
733770
#elif CONFIG_EPPP_LINK_DEVICE_UART
734771
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+
}
735784
#endif
736785
return netif;
737786
}
@@ -754,6 +803,12 @@ esp_netif_t *eppp_open(eppp_type_t role, eppp_config_t *config, int connect_time
754803
return NULL;
755804
}
756805
#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
757812

758813
if (config->task.run_task == false) {
759814
ESP_LOGE(TAG, "task.run_task == false is invalid in this API. Please use eppp_init()");

components/eppp_link/eppp_sdio.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#pragma once
7+
8+
#define MAX_SDIO_PAYLOAD 1500
9+
#define SDIO_ALIGN(size) (((size) + 3U) & ~(3U))
10+
#define SDIO_PAYLOAD SDIO_ALIGN(MAX_SDIO_PAYLOAD)
11+
#define PPP_SOF 0x7E
12+
13+
// Interrupts and registers
14+
#define SLAVE_INTR 0
15+
#define SLAVE_REG_REQ 0
16+
17+
// Requests from host to slave
18+
#define REQ_RESET 1
19+
#define REQ_INIT 2

0 commit comments

Comments
 (0)