mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
spi: update examples to use the new GDMA driver
This commit is contained in:
parent
353f493f22
commit
b5b49eba82
@ -26,14 +26,12 @@
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
# ifdef CONFIG_EXAMPLE_USE_SPI1_PINS
|
||||
# define EEPROM_HOST SPI1_HOST
|
||||
# define DMA_CHAN 0
|
||||
// Use default pins, same as the flash chip.
|
||||
# define PIN_NUM_MISO 7
|
||||
# define PIN_NUM_MOSI 8
|
||||
# define PIN_NUM_CLK 6
|
||||
# else
|
||||
# define EEPROM_HOST HSPI_HOST
|
||||
# define DMA_CHAN 2
|
||||
# define PIN_NUM_MISO 18
|
||||
# define PIN_NUM_MOSI 23
|
||||
# define PIN_NUM_CLK 19
|
||||
@ -42,7 +40,6 @@
|
||||
# define PIN_NUM_CS 13
|
||||
#elif defined CONFIG_IDF_TARGET_ESP32S2
|
||||
# define EEPROM_HOST SPI2_HOST
|
||||
# define DMA_CHAN EEPROM_HOST
|
||||
|
||||
# define PIN_NUM_MISO 37
|
||||
# define PIN_NUM_MOSI 35
|
||||
@ -50,7 +47,6 @@
|
||||
# define PIN_NUM_CS 34
|
||||
#elif defined CONFIG_IDF_TARGET_ESP32C3
|
||||
# define EEPROM_HOST SPI2_HOST
|
||||
# define DMA_CHAN EEPROM_HOST
|
||||
|
||||
# define PIN_NUM_MISO 2
|
||||
# define PIN_NUM_MOSI 7
|
||||
@ -58,6 +54,7 @@
|
||||
# define PIN_NUM_CS 10
|
||||
#endif
|
||||
|
||||
|
||||
static const char TAG[] = "main";
|
||||
|
||||
void app_main(void)
|
||||
@ -74,7 +71,7 @@ void app_main(void)
|
||||
.max_transfer_sz = 32,
|
||||
};
|
||||
//Initialize the SPI bus
|
||||
ret = spi_bus_initialize(EEPROM_HOST, &buscfg, DMA_CHAN);
|
||||
ret = spi_bus_initialize(EEPROM_HOST, &buscfg, SPI_DMA_CH_AUTO);
|
||||
ESP_ERROR_CHECK(ret);
|
||||
#else
|
||||
ESP_LOGI(TAG, "Attach to main flash bus...");
|
||||
|
@ -30,7 +30,6 @@
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#define LCD_HOST HSPI_HOST
|
||||
#define DMA_CHAN 2
|
||||
|
||||
#define PIN_NUM_MISO 25
|
||||
#define PIN_NUM_MOSI 23
|
||||
@ -42,7 +41,6 @@
|
||||
#define PIN_NUM_BCKL 5
|
||||
#elif defined CONFIG_IDF_TARGET_ESP32S2
|
||||
#define LCD_HOST SPI2_HOST
|
||||
#define DMA_CHAN LCD_HOST
|
||||
|
||||
#define PIN_NUM_MISO 37
|
||||
#define PIN_NUM_MOSI 35
|
||||
@ -54,7 +52,6 @@
|
||||
#define PIN_NUM_BCKL 6
|
||||
#elif defined CONFIG_IDF_TARGET_ESP32C3
|
||||
#define LCD_HOST SPI2_HOST
|
||||
#define DMA_CHAN LCD_HOST
|
||||
|
||||
#define PIN_NUM_MISO 2
|
||||
#define PIN_NUM_MOSI 7
|
||||
@ -62,8 +59,8 @@
|
||||
#define PIN_NUM_CS 10
|
||||
|
||||
#define PIN_NUM_DC 9
|
||||
#define PIN_NUM_RST 18
|
||||
#define PIN_NUM_BCKL 19
|
||||
#define PIN_NUM_RST 4
|
||||
#define PIN_NUM_BCKL 5
|
||||
#endif
|
||||
|
||||
//To speed up transfers, every SPI transfer sends a bunch of lines. This define specifies how many. More means more memory use,
|
||||
@ -439,7 +436,7 @@ void app_main(void)
|
||||
.pre_cb=lcd_spi_pre_transfer_callback, //Specify pre-transfer callback to handle D/C line
|
||||
};
|
||||
//Initialize the SPI bus
|
||||
ret=spi_bus_initialize(LCD_HOST, &buscfg, DMA_CHAN);
|
||||
ret=spi_bus_initialize(LCD_HOST, &buscfg, SPI_DMA_CH_AUTO);
|
||||
ESP_ERROR_CHECK(ret);
|
||||
//Attach the LCD to the SPI bus
|
||||
ret=spi_bus_add_device(LCD_HOST, &devcfg, &spi);
|
||||
|
@ -68,15 +68,12 @@ Pins in use. The SPI Master can use the GPIO mux, so feel free to change these i
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#define RCV_HOST HSPI_HOST
|
||||
#define DMA_CHAN 2
|
||||
|
||||
#elif defined CONFIG_IDF_TARGET_ESP32S2
|
||||
#define RCV_HOST SPI2_HOST
|
||||
#define DMA_CHAN RCV_HOST
|
||||
|
||||
#elif defined CONFIG_IDF_TARGET_ESP32C3
|
||||
#define RCV_HOST SPI2_HOST
|
||||
#define DMA_CHAN RCV_HOST
|
||||
|
||||
#endif
|
||||
|
||||
@ -132,7 +129,7 @@ void app_main(void)
|
||||
gpio_set_pull_mode(GPIO_CS, GPIO_PULLUP_ONLY);
|
||||
|
||||
//Initialize SPI slave interface
|
||||
ret=spi_slave_initialize(RCV_HOST, &buscfg, &slvcfg, DMA_CHAN);
|
||||
ret=spi_slave_initialize(RCV_HOST, &buscfg, &slvcfg, SPI_DMA_CH_AUTO);
|
||||
assert(ret==ESP_OK);
|
||||
|
||||
WORD_ALIGNED_ATTR char sendbuf[129]="";
|
||||
|
@ -69,15 +69,12 @@ Pins in use. The SPI Master can use the GPIO mux, so feel free to change these i
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#define SENDER_HOST HSPI_HOST
|
||||
#define DMA_CHAN 2
|
||||
|
||||
#elif defined CONFIG_IDF_TARGET_ESP32S2
|
||||
#define SENDER_HOST SPI2_HOST
|
||||
#define DMA_CHAN SENDER_HOST
|
||||
|
||||
#elif defined CONFIG_IDF_TARGET_ESP32C3
|
||||
#define SENDER_HOST SPI2_HOST
|
||||
#define DMA_CHAN SENDER_HOST
|
||||
#define SENDER_HOST SPI2_HOST
|
||||
|
||||
#endif
|
||||
|
||||
@ -156,7 +153,7 @@ void app_main(void)
|
||||
gpio_isr_handler_add(GPIO_HANDSHAKE, gpio_handshake_isr_handler, NULL);
|
||||
|
||||
//Initialize the SPI bus and add the device we want to send stuff to.
|
||||
ret=spi_bus_initialize(SENDER_HOST, &buscfg, DMA_CHAN);
|
||||
ret=spi_bus_initialize(SENDER_HOST, &buscfg, SPI_DMA_CH_AUTO);
|
||||
assert(ret==ESP_OK);
|
||||
ret=spi_bus_add_device(SENDER_HOST, &devcfg, &handle);
|
||||
assert(ret==ESP_OK);
|
||||
|
Loading…
Reference in New Issue
Block a user