Skip to content

Commit

Permalink
feat(spi_slave_hd): p4 update examples and document
Browse files Browse the repository at this point in the history
  • Loading branch information
wanckl committed Nov 7, 2023
1 parent daeb71d commit 2e115ec
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 103 deletions.
3 changes: 0 additions & 3 deletions components/driver/test_apps/.build-test-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ components/driver/test_apps/spi/master:
components/driver/test_apps/spi/param:
disable:
- if: SOC_GPSPI_SUPPORTED != 1
- if: IDF_TARGET in ["esp32p4"]
temporary: true
reason: target(s) is not supported yet # TODO: IDF-7505

components/driver/test_apps/spi/slave:
disable:
Expand Down
4 changes: 2 additions & 2 deletions components/driver/test_apps/spi/param/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
4 changes: 4 additions & 0 deletions components/driver/test_apps/spi/param/main/test_spi_param.c
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,7 @@ static void test_slave_fd_dma(void)
.tx_buffer = slave_send,
.rx_buffer = slave_recive,
.length = test_trans_len * 8,
.flags = SPI_SLAVE_TRANS_DMA_BUFFER_ALIGN_AUTO,
};
unity_send_signal("Slave ready");
TEST_ESP_OK(spi_slave_transmit(TEST_SPI_HOST, &trans_cfg, portMAX_DELAY));
Expand Down Expand Up @@ -1589,6 +1590,7 @@ static void test_slave_hd_dma(void)
spi_slave_hd_data_t *ret_trans, slave_trans = {
.data = slave_send,
.len = test_trans_len,
.flags = SPI_SLAVE_HD_TRANS_DMA_BUFFER_ALIGN_AUTO,
};
unity_send_signal("Slave ready");
TEST_ESP_OK(spi_slave_hd_queue_trans(TEST_SPI_HOST, SPI_SLAVE_CHAN_TX, &slave_trans, portMAX_DELAY));
Expand Down Expand Up @@ -1690,6 +1692,7 @@ static void test_slave_hd_no_dma(void)
spi_slave_hd_data_t *ret_trans, slave_trans = {
.data = slave_send,
.len = test_trans_len,
.flags = SPI_SLAVE_HD_TRANS_DMA_BUFFER_ALIGN_AUTO,
};
unity_send_signal("Slave ready");
TEST_ESP_OK(spi_slave_hd_queue_trans(TEST_SPI_HOST, SPI_SLAVE_CHAN_TX, &slave_trans, portMAX_DELAY));
Expand Down Expand Up @@ -1826,6 +1829,7 @@ static void test_slave_sio_dma(void)
.length = TEST_STEP_LEN * 8,
.tx_buffer = slave_send,
.rx_buffer = slave_recive,
.flags = SPI_SLAVE_TRANS_DMA_BUFFER_ALIGN_AUTO,
};
unity_send_signal("Slave ready");
TEST_ESP_OK(spi_slave_transmit(TEST_SPI_HOST, &trans, portMAX_DELAY));
Expand Down
2 changes: 0 additions & 2 deletions docs/docs_not_updated/esp32p4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ api-reference/peripherals/spi_flash/auto_suspend.inc
api-reference/peripherals/sdm.rst
api-reference/peripherals/touch_pad.rst
api-reference/peripherals/adc_calibration.rst
api-reference/peripherals/spi_slave_hd.rst
api-reference/peripherals/parlio.rst
api-reference/peripherals/i2c.rst
api-reference/peripherals/dedic_gpio.rst
Expand Down Expand Up @@ -168,7 +167,6 @@ api-reference/protocols/esp_local_ctrl.rst
api-reference/protocols/esp_crt_bundle.rst
api-reference/protocols/esp_http_client.rst
api-reference/protocols/esp_https_server.rst
api-reference/protocols/esp_spi_slave_protocol.rst
api-reference/protocols/modbus.rst
api-reference/protocols/esp_tls.rst
api-reference/protocols/mdns.rst
Expand Down
30 changes: 15 additions & 15 deletions docs/en/api-reference/protocols/esp_spi_slave_protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ ESP SPI Slave HD (Half Duplex) Mode Protocol
SPI Slave Capabilities of Espressif Chips
-----------------------------------------

+------------------+-------+----------+----------+----------+----------+----------+----------+
| | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 | ESP32-C2 | ESP32-C6 | ESP32-H2 |
+------------------+-------+----------+----------+----------+----------+----------+----------+
| SPI Slave HD | N | Y (v2) | Y (v2) | Y (v2) | Y (v2) | Y (v2) | Y (v2) |
+------------------+-------+----------+----------+----------+----------+----------+----------+
| Tohost intr | | N | N | N | N | N | N |
+------------------+-------+----------+----------+----------+----------+----------+----------+
| Frhost intr | | 2 \* | 2 \* | 2 \* | 2 \* | 2 \* | 2 \* |
+------------------+-------+----------+----------+----------+----------+----------+----------+
| TX DMA | | Y | Y | Y | Y | Y | Y |
+------------------+-------+----------+----------+----------+----------+----------+----------+
| RX DMA | | Y | Y | Y | Y | Y | Y |
+------------------+-------+----------+----------+----------+----------+----------+----------+
| Shared registers | | 72 | 64 | 64 | 64 | 64 | 64 |
+------------------+-------+----------+----------+----------+----------+----------+----------+
+------------------+-------+----------+----------+----------+----------+----------+----------+----------+
| | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 | ESP32-C2 | ESP32-C6 | ESP32-H2 | ESP32-P4 |
+------------------+-------+----------+----------+----------+----------+----------+----------+----------+
| SPI Slave HD | N | Y (v2) | Y (v2) | Y (v2) | Y (v2) | Y (v2) | Y (v2) | Y (v2) |
+------------------+-------+----------+----------+----------+----------+----------+----------+----------+
| Tohost intr | | N | N | N | N | N | N | N |
+------------------+-------+----------+----------+----------+----------+----------+----------+----------+
| Frhost intr | | 2 \* | 2 \* | 2 \* | 2 \* | 2 \* | 2 \* | 2 \* |
+------------------+-------+----------+----------+----------+----------+----------+----------+----------+
| TX DMA | | Y | Y | Y | Y | Y | Y | Y |
+------------------+-------+----------+----------+----------+----------+----------+----------+----------+
| RX DMA | | Y | Y | Y | Y | Y | Y | Y |
+------------------+-------+----------+----------+----------+----------+----------+----------+----------+
| Shared registers | | 72 | 64 | 64 | 64 | 64 | 64 | 64 |
+------------------+-------+----------+----------+----------+----------+----------+----------+----------+

Introduction
------------
Expand Down
20 changes: 5 additions & 15 deletions examples/peripherals/.build-test-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,29 +263,19 @@ examples/peripherals/spi_slave:

examples/peripherals/spi_slave_hd/append_mode/master:
disable:
- if: IDF_TARGET in ["esp32c6", "esp32p4"]
temporary: true
reason: target(s) not supported yet # TODO: IDF-7505
- if: SOC_GPSPI_SUPPORTED != 1 or SOC_SPI_SUPPORT_SLAVE_HD_VER2 != 1

examples/peripherals/spi_slave_hd/append_mode/slave:
enable:
- if: IDF_TARGET == "esp32s2"
temporary: true
reason: the other targets are not tested yet
disable:
- if: SOC_GPSPI_SUPPORTED != 1 or SOC_SPI_SUPPORT_SLAVE_HD_VER2 != 1

examples/peripherals/spi_slave_hd/segment_mode/seg_master:
disable:
- if: SOC_GPSPI_SUPPORTED != 1
- if: IDF_TARGET in ["esp32p4"]
temporary: true
reason: target(s) is not supported yet # TODO: IDF-7505 slave hd support
- if: SOC_GPSPI_SUPPORTED != 1 or SOC_SPI_SUPPORT_SLAVE_HD_VER2 != 1

examples/peripherals/spi_slave_hd/segment_mode/seg_slave:
disable:
- if: IDF_TARGET == "esp32" or SOC_GPSPI_SUPPORTED != 1
- if: IDF_TARGET in ["esp32p4"]
temporary: true
reason: target(s) is not supported yet # TODO: IDF-7505 slave hd support
- if: SOC_GPSPI_SUPPORTED != 1 or SOC_SPI_SUPPORT_SLAVE_HD_VER2 != 1

examples/peripherals/temperature_sensor/temp_sensor:
disable:
Expand Down
2 changes: 1 addition & 1 deletion examples/peripherals/spi_slave_hd/append_mode/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPI Halfduplex Slave Append Mode Example
# SPI Slave Halfduplex: Append Mode Example

(See the README.md file in the upper level 'examples' directory for more information about examples.)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- |
| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |

See README.md in the parent directory
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,13 @@
#include "esp_serial_slave_link/essl.h"
#include "esp_serial_slave_link/essl_spi.h"

#ifdef CONFIG_IDF_TARGET_ESP32H2
#define GPIO_MOSI 5
#define GPIO_MISO 0
#define GPIO_SCLK 4
#define GPIO_CS 1

#else
//////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////// Please update the following configuration according to your Hardware spec /////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
#define GPIO_MOSI 11
#define GPIO_MISO 13
#define GPIO_SCLK 12
#define GPIO_CS 10
#endif

#define HOST_ID SPI2_HOST
#define TRANSACTION_LEN 16
Expand Down
4 changes: 2 additions & 2 deletions examples/peripherals/spi_slave_hd/append_mode/slave/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
| Supported Targets | ESP32-S2 |
| ----------------- | -------- |
| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |

See README.md in the parent directory
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
#include "freertos/semphr.h"
#include "driver/spi_slave_hd.h"

//////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////// Please update the following configuration according to your Hardware spec /////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
#define GPIO_MOSI 11
#define GPIO_MISO 13
#define GPIO_SCLK 12
#define GPIO_CS 10
#define HOST_ID 1

#define HOST_ID SPI2_HOST
#define QUEUE_SIZE 6
#define TRANSACTION_LEN 16
#define SYNC_REG_FROM_HOST (14 * 4)
Expand Down
5 changes: 2 additions & 3 deletions examples/peripherals/spi_slave_hd/segment_mode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ These two projects illustrate the SPI Slave Halfduplex Segment Mode.

### Hardware Required

These two projects are supposed to be flashed onto two seperate boards and jumped together via correctly connected SPI pins defined in both of the ``app_main.c`` files. For the ``seg_master`` project, it could be flashed onto all the ESP Chips. Whereas the ``seg_slave`` currently could be flashed onto ESP32-S2. Once they are connected and flashed, they will use the SPI Master and SPI Slave Halfduplex drivers to communicate with each other.
These two projects are supposed to be flashed onto two seperate boards and jumped together via correctly connected SPI pins defined in both of the ``app_main.c`` files. Once they are connected and flashed, they will use the SPI Master and SPI Slave Halfduplex drivers to communicate with each other.

Following is the connection between 2 ESP32S2 boards:

Expand All @@ -21,8 +21,7 @@ Following is the connection between 2 ESP32S2 boards:
| SCLK | GPIO12 | GPIO12 |
| CS | GPIO10 | GPIO10 |

Plase refer to the macro definations at the top of ``app_main.c`` files, to know the connection on different chips.
Feel free to change the GPIO settings by editing the macro definations.
Feel free to change the GPIO settings by editing the macro definations on the top of the ``app_main.c``

### Build and Flash

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |
| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |

See README.md in the parent directory
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,15 @@
#include "driver/spi_master.h"
#include "esp_serial_slave_link/essl_spi.h"

//Pin setting
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
//////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////// Please update the following configuration according to your Hardware spec /////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
#define GPIO_MOSI 11
#define GPIO_MISO 13
#define GPIO_SCLK 12
#define GPIO_CS 10

#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2
#define GPIO_MOSI 7
#define GPIO_MISO 2
#define GPIO_SCLK 6
#define GPIO_CS 10

#elif CONFIG_IDF_TARGET_ESP32C6
#define GPIO_MOSI 19
#define GPIO_MISO 20
#define GPIO_SCLK 18
#define GPIO_CS 9

#elif CONFIG_IDF_TARGET_ESP32H2
#define GPIO_HANDSHAKE 2
#define GPIO_MOSI 5
#define GPIO_MISO 0
#define GPIO_SCLK 4
#define GPIO_CS 1
#endif

#define MASTER_HOST SPI2_HOST
#define MASTER_HOST SPI2_HOST
#define DMA_CHAN SPI_DMA_CH_AUTO

#define TX_SIZE_MIN 40
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- | -------- | -------- | -------- |
| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,14 @@

#define TIME_IS_OUT(start, end, timeout) (timeout) > ((end)-(start)) ? 0 : 1

//Pin setting
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
//////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////// Please update the following configuration according to your Hardware spec /////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
#define GPIO_MOSI 11
#define GPIO_MISO 13
#define GPIO_SCLK 12
#define GPIO_CS 10

#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2
#define GPIO_MOSI 7
#define GPIO_MISO 2
#define GPIO_SCLK 6
#define GPIO_CS 10

#elif CONFIG_IDF_TARGET_ESP32C6
#define GPIO_MOSI 19
#define GPIO_MISO 20
#define GPIO_SCLK 18
#define GPIO_CS 9

#elif CONFIG_IDF_TARGET_ESP32H2
#define GPIO_HANDSHAKE 2
#define GPIO_MOSI 5
#define GPIO_MISO 0
#define GPIO_SCLK 4
#define GPIO_CS 1
#endif

#define SLAVE_HOST SPI2_HOST
#define DMA_CHAN SPI_DMA_CH_AUTO
#define QUEUE_SIZE 4
Expand Down

0 comments on commit 2e115ec

Please sign in to comment.