|
| 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 |
0 commit comments