espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.32k stars 7.2k forks source link

SPI_HOST_MAX for ESP32C2/C3 is incorrect (IDFGH-8932) #10349

Closed nopnop2002 closed 1 year ago

nopnop2002 commented 1 year ago

Answers checklist.

General issue report

ESP32C2/C3 has hardware limitations compared to ESP32.

The number of hardware can be checked with the following constants.

SPI_HOST_MAX
I2C_NUM_MAX
UART_NUM_MAX

But the SPI_HOST_MAX of the ESP32C2/C3 is incorrect.

Version of ESP-IDF

$ idf.py --version
ESP-IDF v5.1-dev-1840-gaad600c9ca-dirty

Test code

#include <stdio.h>
#include "driver/i2c.h"
#include "driver/spi_master.h"
#include "driver/uart.h"

void app_main()
{
    printf("SPI_HOST_MAX=%d\n", SPI_HOST_MAX);
    printf("I2C_NUM_MAX=%d\n", I2C_NUM_MAX);
    printf("UART_NUM_MAX=%d\n", UART_NUM_MAX);
}

ESP32

SPI_HOST_MAX=3 I2C_NUM_MAX=2 UART_NUM_MAX=3

ESP32C2

SPI_HOST_MAX=3 ---> incorrect I2C_NUM_MAX=1 UART_NUM_MAX=2

ESP32C3

SPI_HOST_MAX=3 ---> incorrect I2C_NUM_MAX=1 UART_NUM_MAX=2

suda-morris commented 1 year ago

Hi @nopnop2002 Thanks for reporting.

Yes, the enum spi_host_device_t should reflect the SOC_SPI_PERIPH_NUM macro, we will fix it ASAP.

nopnop2002 commented 1 year ago

@suda-morris

The ESP32C2 and ESP32C3 documents have the following description.

It gives a false impression that SPI3 is available.

This description is misleading.

ESP32C2

ESP32C3

AxelLin commented 1 year ago

This was reported 1 year ago: https://github.com/espressif/esp-idf/issues/8144