examples: support spi master examples on esp32cxx

This commit is contained in:
wanlei 2022-10-19 16:58:32 +08:00
parent eee7b4cbfc
commit 7a91b77329
5 changed files with 24 additions and 34 deletions

View File

@ -132,18 +132,6 @@ examples/peripherals/sigma_delta:
disable:
- if: SOC_SDM_SUPPORTED != 1
examples/peripherals/spi_master/hd_eeprom:
disable:
- if: IDF_TARGET == "esp32c2"
temporary: true
reason: target esp32c2 is not supported yet
examples/peripherals/spi_master/lcd:
enable:
- if: IDF_TARGET in ["esp32", "esp32c3", "esp32s2"]
temporary: true
reason: the other targets are not tested yet
examples/peripherals/spi_slave_hd/append_mode/slave:
enable:
- if: IDF_TARGET == "esp32s2"

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- |
## SPI master half duplex EEPROM example
@ -11,16 +11,16 @@
For different chip and host used, the connections may be different.
| | ESP32 | ESP32 | ESP32S2 | ESP32C3 | ESP32S3 |
| ---- | ----- | ----- | ------- | ------- | ------- |
| Host | SPI1 | HSPI | FSPI | SPI2 | SPI2 |
| VCC | 3.3V | 3.3V | 3.3V | 3.3V | 3.3V |
| GND | GND | GND | GND | GND | GND |
| DO | 7 | 18 | 37 | 2 | 13 |
| DI | 8 | 23 | 35 | 7 | 11 |
| SK | 6 | 19 | 36 | 6 | 12 |
| CS | 13 | 13 | 34 | 10 | 10 |
| ORG | GND | GND | GND | GND | GND |
| | ESP32 | ESP32 | ESP32S2 | ESP32C2 | ESP32C3 | ESP32S3 |
| ---- | ----- | ----- | ------- | ------- | ------- | ------- |
| Host | SPI1 | HSPI | SPI2 | SPI2 | SPI2 | SPI2 |
| VCC | 3.3V | 3.3V | 3.3V | 3.3V | 3.3V | 3.3V |
| GND | GND | GND | GND | GND | GND | GND |
| DO | 7 | 18 | 37 | 2 | 2 | 13 |
| DI | 8 | 23 | 35 | 7 | 7 | 11 |
| SK | 6 | 19 | 36 | 6 | 6 | 12 |
| CS | 13 | 13 | 34 | 10 | 10 | 10 |
| ORG | GND | GND | GND | GND | GND | GND |
### Notes

View File

@ -45,7 +45,7 @@
# define PIN_NUM_MOSI 35
# define PIN_NUM_CLK 36
# define PIN_NUM_CS 34
#elif defined CONFIG_IDF_TARGET_ESP32C3
#elif defined CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2
# define EEPROM_HOST SPI2_HOST
# define PIN_NUM_MISO 2

View File

@ -1,11 +1,11 @@
| Supported Targets | ESP32 | ESP32-C3 | ESP32-S2 |
| ----------------- | ----- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- |
# SPI Host Driver Example
(See the README.md file in the upper level 'examples' directory for more information about examples.)
This example aims to show how to use SPI Host driver API, like `spi_transaction_t` and spi_device_queue.
This example aims to show how to use SPI Host driver API, like `spi_transaction_t` and spi_device_queue.
If you are looking for code to drive LCDs in general, rather than code that uses the SPI master, that may be a better example to look at as it uses ESP-IDFs built-in LCD support rather than doing all the low-level work itself, which can be found at `examples/peripherals/lcd/tjpgd/`

View File

@ -40,18 +40,18 @@
#define PIN_NUM_DC 21
#define PIN_NUM_RST 18
#define PIN_NUM_BCKL 5
#elif defined CONFIG_IDF_TARGET_ESP32S2
#elif defined CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
#define LCD_HOST SPI2_HOST
#define PIN_NUM_MISO 37
#define PIN_NUM_MOSI 35
#define PIN_NUM_CLK 36
#define PIN_NUM_CS 34
#define PIN_NUM_CS 45
#define PIN_NUM_DC 4
#define PIN_NUM_RST 5
#define PIN_NUM_BCKL 6
#elif defined CONFIG_IDF_TARGET_ESP32C3
#elif defined CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2
#define LCD_HOST SPI2_HOST
#define PIN_NUM_MISO 2
@ -258,9 +258,11 @@ void lcd_init(spi_device_handle_t spi)
const lcd_init_cmd_t* lcd_init_cmds;
//Initialize non-SPI GPIOs
gpio_set_direction(PIN_NUM_DC, GPIO_MODE_OUTPUT);
gpio_set_direction(PIN_NUM_RST, GPIO_MODE_OUTPUT);
gpio_set_direction(PIN_NUM_BCKL, GPIO_MODE_OUTPUT);
gpio_config_t io_conf = {};
io_conf.pin_bit_mask = ((1ULL<<PIN_NUM_DC) | (1ULL<<PIN_NUM_RST) | (1ULL<<PIN_NUM_BCKL));
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pull_up_en = true;
gpio_config(&io_conf);
//Reset the display
gpio_set_level(PIN_NUM_RST, 0);