ESP32 SDIO AT Guide¶
SDIO AT is based on ESP32 AT, using SDIO, instead of UART, to communicate with host MCU. The ESP32 SDIO AT runs as an SDIO slave.
SDIO communication needs at least 4 pins: CMD, CLK, DAT0, DAT1;
for one line mode, DAT1 runs as the interrupt pin;
for four lines mode, two more pins (DAT2 and DAT3) are needed.
SDIO SLAVE pins is as below:
CLK is GPIO14
CMD is GPIO15
DAT0 is GPIO2
DAT1 is GPIO4
DAT2 is GPIO12 (for four lines mode only)
DAT3 is GPIO13 (for four lines mode only)
Turn switch 1, 2, 3, 4, 5 “ON”; and others are “OFF”.
Flashing firmware to the master. After the flashing completed, the light on ESP32 slave will turn on, it means that the master runs successfully, and power on the slave.
Flashing the SDIO AT firmware to the slave.
If you use ESP32-DevKitC or ESP-WROVER-KIT V2 (or earlier versions), please refer to the board-compatibility to set strapping pins, and run the SDIO demo firstly, to make sure the SDIO communication works properly. If it is, then you can start your SDIO AT journey.
SDIO Data Transimission¶
Power on the SDIO SLAVE (this step is for ESP-SDIO-TESTBOARD-V1 only)
ESP-SDIO-TESTBOARD-V1 contains one master and three slaves (ESP32, ESP8266 and ESP8089).
To use ESP32 as SDIO slave, you need to pull down GPIO5, see
Intialize SDIO HOST
To initialize SDIO, including configure one line or four lines mode, SDIO frequency, initialize SD mode.
Negotiate SDIO Communication
Negotiate SDIO parameters with the slave according to SDIO spec. Please note that SDIO HOST must wait till the slave startup done, then to start the negotiation. Usually the host needs to delay some time to wait.
When the SDIO host detects an interrupt from DAT1, if it is the slave sends new packet to the host, the host will read those data by CMD53.
In SDIO AT demo, the data inputs from serial port, when the SDIO host gets it, the host will send it to the slave through SDIO by CMD53.
Please note that if the sending time out, there may be something wrong with the slave, then we will re-initiate both SDIO host and slave.
Also, after AT+RST or AT+RESTORE, both SDIO host and slave should be initiated again.
When SDIO slave receives data from SDIO host, the slave will inform the AT core and give the data to the AT core to handle. After the AT core finished the work, the slave will send data to the host as feedback.
Initialize SDIO Slave
sdio_slave_initializeto initialize SDIO slave driver
sdio_slave_recv_register_bufto register receiving buffer. To make it receive data faster, you can register multiple buffers.
sdio_slave_recv_load_bufto load the receiving buffer, ready to receive data.
sdio_slave_set_host_intenato set interrupt for host, which mainly used is the
SDIO_SLAVE_HOSTINT_SEND_NEW_PACKET, to notify that there is a new packet sent from the host.
sdio_slave_startto start SDIO hardware transmission.
Since the SDIO slave data transmission via DMA, you need to copy the data from AT core to the memory which DMA can read firstly.
sdio_slave_transmitto send the data.
To speed up the data transmission, after receiving data by
sdio_slave_recv, we use a circular linked list to transmit the received data to the AT core.