Skip to content

Commit 51d9ef4

Browse files
committed
Merge branch 'ex/transport_config_b4_init' into 'main'
fix(transport_config): Add host example to showcase transport config before esp_hosted_init() See merge request app-frameworks/esp_hosted_mcu!114
2 parents d64f350 + 61ad639 commit 51d9ef4

File tree

12 files changed

+827
-88
lines changed

12 files changed

+827
-88
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ if(CONFIG_ESP_HOSTED_ENABLED)
106106
list(APPEND srcs
107107
"${host_dir}/port/esp/freertos/src/port_esp_hosted_host_init.c"
108108
"${host_dir}/port/esp/freertos/src/port_esp_hosted_host_os.c"
109-
"${host_dir}/port/esp/freertos/src/port_esp_hosted_host_ota.c")
109+
"${host_dir}/port/esp/freertos/src/port_esp_hosted_host_ota.c"
110+
"${host_dir}/port/esp/freertos/src/port_esp_hosted_host_transport_defaults.c"
111+
)
110112

111113
if(CONFIG_ESP_HOSTED_SDIO_HOST_INTERFACE)
112114
list(APPEND srcs "${host_dir}/port/esp/freertos/src/port_esp_hosted_host_sdio.c")
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The following lines of boilerplate have to be in your project's CMakeLists
2+
# in this exact order for cmake to work correctly
3+
cmake_minimum_required(VERSION 3.16)
4+
5+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
6+
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
7+
idf_build_set_property(MINIMAL_BUILD ON)
8+
project(transport_config)
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# ESP-Hosted Transport Configuration Example
2+
3+
Demonstrates how to configure ESP-Hosted transport interfaces (SDIO, SPI, UART) before initialization.
4+
5+
## Supported Transports
6+
7+
| Transport | Speed | Pins | Use Case |
8+
|-----------|-------|------|----------|
9+
| **SDIO 1-bit** | High | 5 pins | Good performance, fewer pins |
10+
| **SDIO 4-bit** | Highest | 7 pins | Best performance |
11+
| **SPI Full-Duplex** | Medium | 6 pins | Standard interface |
12+
| **SPI HD Dual** | Medium | 4 pins | Fewer pins needed |
13+
| **SPI HD Quad** | Medium | 6 pins | Better throughput |
14+
| **UART** | Low | 3 pins | Simple connection |
15+
16+
## Pin Connections
17+
18+
### SDIO 1-bit
19+
| Host <-> Slave (5 pins) | CLK | CMD | DAT0 | DAT1 (interrupt) | RESET |
20+
|---|---|---|---|---|---|
21+
22+
### SDIO 4-bit (Default)
23+
| Host <-> Slave (7 pins) | CLK | CMD | DAT0 | DAT1 | DAT2 | DAT3 | RESET |
24+
|---|---|---|---|---|---|---|---|
25+
26+
### SPI Full-Duplex
27+
| Host <-> Slave (6 pins) | MOSI | MISO | SCLK | CS | HANDSHAKE | DATA_READY |
28+
|---|---|---|---|---|---|---|
29+
30+
### SPI Half-Duplex Dual
31+
| Host <-> Slave (4 pins) | CLK | CS | D0 | D1 (+ DATA_READY) |
32+
|---|---|---|---|---|
33+
34+
### SPI Half-Duplex Quad
35+
| Host <-> Slave (6 pins) | CLK | CS | D0 | D1 | D2 | D3 (+ DATA_READY) |
36+
|---|---|---|---|---|---|---|
37+
38+
### UART
39+
| Host <-> Slave (3 pins) | TX | RX | RESET |
40+
|---|---|---|---|
41+
42+
## What This Example Shows
43+
44+
- Get default transport configuration
45+
- Customize parameters (clock, pins, buffers)
46+
- Apply configuration before `esp_hosted_init()`
47+
48+
## Key Code Pattern
49+
50+
```c
51+
// 1. Get default config
52+
struct esp_hosted_sdio_config config = INIT_DEFAULT_HOST_SDIO_CONFIG();
53+
54+
// 2. Customize settings
55+
config.clock_freq_khz = 25000;
56+
config.bus_width = 4;
57+
58+
// 3. Apply config
59+
esp_hosted_sdio_set_config(&config);
60+
61+
// 4. Initialize ESP-Hosted
62+
esp_hosted_init();
63+
```
64+
65+
## Customization
66+
67+
> [!TIP]
68+
>
69+
> This example was added to showcase (Option 2: Programmatic Configuration) discussed below.
70+
> (Option 1: Using menuconfig) is anyway available for any host example.
71+
72+
### Pin Configuration Options
73+
74+
**Option 1: Using menuconfig**
75+
76+
First select your transport:
77+
```bash
78+
idf.py menuconfig
79+
# (Top) → Component config → ESP-Hosted config → Transport layer
80+
```
81+
82+
Then configure pins:
83+
- **SDIO**: `(Top) → Component config → ESP-Hosted config → Hosted SDIO Configuration`
84+
- **SPI Full-Duplex**: `(Top) → Component config → ESP-Hosted config → SPI Configuration`
85+
- **SPI Half-Duplex**: `(Top) → Component config → ESP-Hosted config → SPI Half-duplex Configuration`
86+
- **UART**: `(Top) → Component config → ESP-Hosted config → UART Configuration`
87+
88+
**Option 2: Programmatic Configuration**
89+
Edit the configuration functions in `main.c` for users who prefer code-based configuration or have limitations with menuconfig:
90+
91+
```c
92+
// Example: Custom SPI pin assignment
93+
spi_config.pin_mosi.pin = YOUR_MOSI_PIN;
94+
spi_config.pin_miso.pin = YOUR_MISO_PIN;
95+
spi_config.pin_sclk.pin = YOUR_SCLK_PIN;
96+
spi_config.pin_cs.pin = YOUR_CS_PIN;
97+
```
98+
99+
### Other Customizations
100+
- **Clock speeds**: Adjust for stability vs performance
101+
- **Buffer sizes**: Tune for your throughput needs
102+
- **Data lines**: Configure GPIOs to match your connections
103+
- **Transport config**: Any other transport specific config
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
idf_component_register(SRCS "transport_config_main.c"
2+
PRIV_REQUIRES esp_wifi console nvs_flash
3+
INCLUDE_DIRS ".")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dependencies:
2+
espressif/esp_wifi_remote:
3+
version: "*"
4+
rules:
5+
- if: "target in [esp32p4, esp32h2]"
6+
espressif/esp_hosted:
7+
version: "*"
8+
rules:
9+
- if: "target in [esp32p4, esp32h2]"

0 commit comments

Comments
 (0)