spi_master:fix error when use spi_bus_add_device more than 3 device

update gpio_sig at `spics_out` array in each spi_periph.c of chips later than s2
then `spi_bus_add_device` can correctly distribute gpio_signals for cs_signal

Closes https://github.com/espressif/esp-idf/issues/8876
This commit is contained in:
wanlei 2022-08-31 21:06:24 +08:00
parent 7bc264ed80
commit 96aa2792f8
19 changed files with 57 additions and 63 deletions

View File

@ -535,6 +535,10 @@ config SOC_SPI_DMA_CHAN_NUM
int int
default 2 default 2
config SOC_SPI_MAX_CS_NUM
int
default 3
config SOC_SPI_MAXIMUM_BUFFER_SIZE config SOC_SPI_MAXIMUM_BUFFER_SIZE
int int
default 64 default 64

View File

@ -268,6 +268,7 @@
#define SOC_SPI_DMA_CHAN_NUM 2 #define SOC_SPI_DMA_CHAN_NUM 2
#define SOC_SPI_PERIPH_CS_NUM(i) 3 #define SOC_SPI_PERIPH_CS_NUM(i) 3
#define SOC_SPI_MAX_CS_NUM 3
#define SOC_SPI_MAXIMUM_BUFFER_SIZE 64 #define SOC_SPI_MAXIMUM_BUFFER_SIZE 64
#define SOC_SPI_MAX_PRE_DIVIDER 8192 #define SOC_SPI_MAX_PRE_DIVIDER 8192

View File

@ -335,6 +335,10 @@ config SOC_SPI_PERIPH_NUM
int int
default 2 default 2
config SOC_SPI_MAX_CS_NUM
int
default 6
config SOC_SPI_MAXIMUM_BUFFER_SIZE config SOC_SPI_MAXIMUM_BUFFER_SIZE
int int
default 64 default 64

View File

@ -179,6 +179,7 @@
/*-------------------------- SPI CAPS ----------------------------------------*/ /*-------------------------- SPI CAPS ----------------------------------------*/
#define SOC_SPI_PERIPH_NUM 2 #define SOC_SPI_PERIPH_NUM 2
#define SOC_SPI_PERIPH_CS_NUM(i) 6 #define SOC_SPI_PERIPH_CS_NUM(i) 6
#define SOC_SPI_MAX_CS_NUM 6
#define SOC_SPI_MAXIMUM_BUFFER_SIZE 64 #define SOC_SPI_MAXIMUM_BUFFER_SIZE 64

View File

@ -46,7 +46,7 @@ const spi_signal_conn_t spi_periph_signal[SOC_SPI_PERIPH_NUM] = {
.spiq_in = FSPIQ_IN_IDX, .spiq_in = FSPIQ_IN_IDX,
.spiwp_in = FSPIWP_IN_IDX, .spiwp_in = FSPIWP_IN_IDX,
.spihd_in = FSPIHD_IN_IDX, .spihd_in = FSPIHD_IN_IDX,
.spics_out = {FSPICS0_OUT_IDX, FSPICS1_OUT_IDX, FSPICS2_OUT_IDX}, .spics_out = {FSPICS0_OUT_IDX, FSPICS1_OUT_IDX, FSPICS2_OUT_IDX, FSPICS3_OUT_IDX, FSPICS4_OUT_IDX, FSPICS5_OUT_IDX},
.spics_in = FSPICS0_IN_IDX, .spics_in = FSPICS0_IN_IDX,
.spiclk_iomux_pin = SPI2_IOMUX_PIN_NUM_CLK, .spiclk_iomux_pin = SPI2_IOMUX_PIN_NUM_CLK,
.spid_iomux_pin = SPI2_IOMUX_PIN_NUM_MOSI, .spid_iomux_pin = SPI2_IOMUX_PIN_NUM_MOSI,

View File

@ -539,6 +539,10 @@ config SOC_SPI_PERIPH_NUM
int int
default 2 default 2
config SOC_SPI_MAX_CS_NUM
int
default 6
config SOC_SPI_MAXIMUM_BUFFER_SIZE config SOC_SPI_MAXIMUM_BUFFER_SIZE
int int
default 64 default 64

View File

@ -260,6 +260,7 @@
/*-------------------------- SPI CAPS ----------------------------------------*/ /*-------------------------- SPI CAPS ----------------------------------------*/
#define SOC_SPI_PERIPH_NUM 2 #define SOC_SPI_PERIPH_NUM 2
#define SOC_SPI_PERIPH_CS_NUM(i) 6 #define SOC_SPI_PERIPH_CS_NUM(i) 6
#define SOC_SPI_MAX_CS_NUM 6
#define SOC_SPI_MAXIMUM_BUFFER_SIZE 64 #define SOC_SPI_MAXIMUM_BUFFER_SIZE 64

View File

@ -1,16 +1,8 @@
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "soc/spi_periph.h" #include "soc/spi_periph.h"
#include "stddef.h" #include "stddef.h"
@ -54,7 +46,7 @@ const spi_signal_conn_t spi_periph_signal[SOC_SPI_PERIPH_NUM] = {
.spiq_in = FSPIQ_IN_IDX, .spiq_in = FSPIQ_IN_IDX,
.spiwp_in = FSPIWP_IN_IDX, .spiwp_in = FSPIWP_IN_IDX,
.spihd_in = FSPIHD_IN_IDX, .spihd_in = FSPIHD_IN_IDX,
.spics_out = {FSPICS0_OUT_IDX, FSPICS1_OUT_IDX, FSPICS2_OUT_IDX}, .spics_out = {FSPICS0_OUT_IDX, FSPICS1_OUT_IDX, FSPICS2_OUT_IDX, FSPICS3_OUT_IDX, FSPICS4_OUT_IDX, FSPICS5_OUT_IDX},
.spics_in = FSPICS0_IN_IDX, .spics_in = FSPICS0_IN_IDX,
.spiclk_iomux_pin = SPI2_IOMUX_PIN_NUM_CLK, .spiclk_iomux_pin = SPI2_IOMUX_PIN_NUM_CLK,
.spid_iomux_pin = SPI2_IOMUX_PIN_NUM_MOSI, .spid_iomux_pin = SPI2_IOMUX_PIN_NUM_MOSI,

View File

@ -511,6 +511,10 @@ config SOC_SPI_PERIPH_NUM
int int
default 2 default 2
config SOC_SPI_MAX_CS_NUM
int
default 6
config SOC_SPI_MAXIMUM_BUFFER_SIZE config SOC_SPI_MAXIMUM_BUFFER_SIZE
int int
default 64 default 64

View File

@ -263,6 +263,7 @@
/*-------------------------- SPI CAPS ----------------------------------------*/ /*-------------------------- SPI CAPS ----------------------------------------*/
#define SOC_SPI_PERIPH_NUM 2 #define SOC_SPI_PERIPH_NUM 2
#define SOC_SPI_PERIPH_CS_NUM(i) 6 #define SOC_SPI_PERIPH_CS_NUM(i) 6
#define SOC_SPI_MAX_CS_NUM 6
#define SOC_SPI_MAXIMUM_BUFFER_SIZE 64 #define SOC_SPI_MAXIMUM_BUFFER_SIZE 64

View File

@ -1,16 +1,8 @@
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "soc/spi_periph.h" #include "soc/spi_periph.h"
#include "stddef.h" #include "stddef.h"
@ -54,7 +46,7 @@ const spi_signal_conn_t spi_periph_signal[SOC_SPI_PERIPH_NUM] = {
.spiq_in = FSPIQ_IN_IDX, .spiq_in = FSPIQ_IN_IDX,
.spiwp_in = FSPIWP_IN_IDX, .spiwp_in = FSPIWP_IN_IDX,
.spihd_in = FSPIHD_IN_IDX, .spihd_in = FSPIHD_IN_IDX,
.spics_out = {FSPICS0_OUT_IDX, FSPICS1_OUT_IDX, FSPICS2_OUT_IDX}, .spics_out = {FSPICS0_OUT_IDX, FSPICS1_OUT_IDX, FSPICS2_OUT_IDX, FSPICS3_OUT_IDX, FSPICS4_OUT_IDX, FSPICS5_OUT_IDX},
.spics_in = FSPICS0_IN_IDX, .spics_in = FSPICS0_IN_IDX,
.spiclk_iomux_pin = SPI2_IOMUX_PIN_NUM_CLK, .spiclk_iomux_pin = SPI2_IOMUX_PIN_NUM_CLK,
.spid_iomux_pin = SPI2_IOMUX_PIN_NUM_MOSI, .spid_iomux_pin = SPI2_IOMUX_PIN_NUM_MOSI,

View File

@ -567,6 +567,10 @@ config SOC_SPI_DMA_CHAN_NUM
int int
default 3 default 3
config SOC_SPI_MAX_CS_NUM
int
default 6
config SOC_SPI_MAXIMUM_BUFFER_SIZE config SOC_SPI_MAXIMUM_BUFFER_SIZE
int int
default 72 default 72

View File

@ -253,6 +253,7 @@
#define SOC_SPI_PERIPH_NUM 3 #define SOC_SPI_PERIPH_NUM 3
#define SOC_SPI_DMA_CHAN_NUM 3 #define SOC_SPI_DMA_CHAN_NUM 3
#define SOC_SPI_PERIPH_CS_NUM(i) (((i)==0)? 2: (((i)==1)? 6: 3)) #define SOC_SPI_PERIPH_CS_NUM(i) (((i)==0)? 2: (((i)==1)? 6: 3))
#define SOC_SPI_MAX_CS_NUM 6
#define SOC_SPI_MAXIMUM_BUFFER_SIZE 72 #define SOC_SPI_MAXIMUM_BUFFER_SIZE 72
#define SOC_SPI_MAX_PRE_DIVIDER 8192 #define SOC_SPI_MAX_PRE_DIVIDER 8192

View File

@ -1,16 +1,8 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "soc/spi_periph.h" #include "soc/spi_periph.h"
#include "stddef.h" #include "stddef.h"
@ -62,7 +54,7 @@ const spi_signal_conn_t spi_periph_signal[SOC_SPI_PERIPH_NUM] = {
.spid5_in = FSPIIO5_IN_IDX, .spid5_in = FSPIIO5_IN_IDX,
.spid6_in = FSPIIO6_IN_IDX, .spid6_in = FSPIIO6_IN_IDX,
.spid7_in = FSPIIO7_IN_IDX, .spid7_in = FSPIIO7_IN_IDX,
.spics_out = {FSPICS0_OUT_IDX, FSPICS1_OUT_IDX, FSPICS2_OUT_IDX}, .spics_out = {FSPICS0_OUT_IDX, FSPICS1_OUT_IDX, FSPICS2_OUT_IDX, FSPICS3_OUT_IDX, FSPICS4_OUT_IDX, FSPICS5_OUT_IDX},
.spics_in = FSPICS0_IN_IDX, .spics_in = FSPICS0_IN_IDX,
.spiclk_iomux_pin = FSPI_IOMUX_PIN_NUM_CLK, .spiclk_iomux_pin = FSPI_IOMUX_PIN_NUM_CLK,
.spid_iomux_pin = FSPI_IOMUX_PIN_NUM_MOSI, .spid_iomux_pin = FSPI_IOMUX_PIN_NUM_MOSI,

View File

@ -647,6 +647,10 @@ config SOC_SPI_PERIPH_NUM
int int
default 3 default 3
config SOC_SPI_MAX_CS_NUM
int
default 6
config SOC_SPI_MAXIMUM_BUFFER_SIZE config SOC_SPI_MAXIMUM_BUFFER_SIZE
int int
default 64 default 64

View File

@ -266,7 +266,8 @@
/*-------------------------- SPI CAPS ----------------------------------------*/ /*-------------------------- SPI CAPS ----------------------------------------*/
#define SOC_SPI_PERIPH_NUM 3 #define SOC_SPI_PERIPH_NUM 3
#define SOC_SPI_PERIPH_CS_NUM(i) 3 #define SOC_SPI_PERIPH_CS_NUM(i) (((i)==0)? 2: (((i)==1)? 6: 3))
#define SOC_SPI_MAX_CS_NUM 6
#define SOC_SPI_MAXIMUM_BUFFER_SIZE 64 #define SOC_SPI_MAXIMUM_BUFFER_SIZE 64
#define SOC_SPI_SUPPORT_DDRCLK 1 #define SOC_SPI_SUPPORT_DDRCLK 1
#define SOC_SPI_SLAVE_SUPPORT_SEG_TRANS 1 #define SOC_SPI_SLAVE_SUPPORT_SEG_TRANS 1

View File

@ -1,16 +1,8 @@
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "soc/spi_periph.h" #include "soc/spi_periph.h"
#include "stddef.h" #include "stddef.h"
@ -62,7 +54,7 @@ const spi_signal_conn_t spi_periph_signal[SOC_SPI_PERIPH_NUM] = {
.spid5_in = FSPIIO5_IN_IDX, .spid5_in = FSPIIO5_IN_IDX,
.spid6_in = FSPIIO6_IN_IDX, .spid6_in = FSPIIO6_IN_IDX,
.spid7_in = FSPIIO7_IN_IDX, .spid7_in = FSPIIO7_IN_IDX,
.spics_out = {FSPICS0_OUT_IDX, FSPICS1_OUT_IDX, FSPICS2_OUT_IDX}, .spics_out = {FSPICS0_OUT_IDX, FSPICS1_OUT_IDX, FSPICS2_OUT_IDX, FSPICS3_OUT_IDX, FSPICS4_OUT_IDX, FSPICS5_OUT_IDX},
.spics_in = FSPICS0_IN_IDX, .spics_in = FSPICS0_IN_IDX,
.spiclk_iomux_pin = SPI2_IOMUX_PIN_NUM_CLK, .spiclk_iomux_pin = SPI2_IOMUX_PIN_NUM_CLK,
.spid_iomux_pin = SPI2_IOMUX_PIN_NUM_MOSI, .spid_iomux_pin = SPI2_IOMUX_PIN_NUM_MOSI,

View File

@ -60,7 +60,7 @@ typedef struct {
const uint8_t spid6_in; const uint8_t spid6_in;
const uint8_t spid7_in; const uint8_t spid7_in;
#endif // SOC_SPI_SUPPORT_OCT #endif // SOC_SPI_SUPPORT_OCT
const uint8_t spics_out[3]; // /CS GPIO output mux signals const uint8_t spics_out[SOC_SPI_MAX_CS_NUM]; // /CS GPIO output mux signals
const uint8_t spics_in; const uint8_t spics_in;
const uint8_t spidqs_out; const uint8_t spidqs_out;
const uint8_t spicd_out; const uint8_t spicd_out;

View File

@ -1038,7 +1038,6 @@ components/soc/esp32c3/include/soc/usb_serial_jtag_struct.h
components/soc/esp32c3/include/soc/wdev_reg.h components/soc/esp32c3/include/soc/wdev_reg.h
components/soc/esp32c3/interrupts.c components/soc/esp32c3/interrupts.c
components/soc/esp32c3/ledc_periph.c components/soc/esp32c3/ledc_periph.c
components/soc/esp32c3/spi_periph.c
components/soc/esp32c3/uart_periph.c components/soc/esp32c3/uart_periph.c
components/soc/esp32h2/i2c_periph.c components/soc/esp32h2/i2c_periph.c
components/soc/esp32h2/include/soc/apb_ctrl_reg.h components/soc/esp32h2/include/soc/apb_ctrl_reg.h
@ -1076,7 +1075,6 @@ components/soc/esp32h2/include/soc/usb_serial_jtag_reg.h
components/soc/esp32h2/include/soc/usb_serial_jtag_struct.h components/soc/esp32h2/include/soc/usb_serial_jtag_struct.h
components/soc/esp32h2/include/soc/wdev_reg.h components/soc/esp32h2/include/soc/wdev_reg.h
components/soc/esp32h2/ledc_periph.c components/soc/esp32h2/ledc_periph.c
components/soc/esp32h2/spi_periph.c
components/soc/esp32h2/uart_periph.c components/soc/esp32h2/uart_periph.c
components/soc/esp32s2/adc_periph.c components/soc/esp32s2/adc_periph.c
components/soc/esp32s2/dac_periph.c components/soc/esp32s2/dac_periph.c
@ -1132,7 +1130,6 @@ components/soc/esp32s2/include/soc/usb_wrap_struct.h
components/soc/esp32s2/include/soc/usbh_struct.h components/soc/esp32s2/include/soc/usbh_struct.h
components/soc/esp32s2/include/soc/wdev_reg.h components/soc/esp32s2/include/soc/wdev_reg.h
components/soc/esp32s2/ledc_periph.c components/soc/esp32s2/ledc_periph.c
components/soc/esp32s2/spi_periph.c
components/soc/esp32s2/uart_periph.c components/soc/esp32s2/uart_periph.c
components/soc/esp32s2/usb_periph.c components/soc/esp32s2/usb_periph.c
components/soc/esp32s3/dedic_gpio_periph.c components/soc/esp32s3/dedic_gpio_periph.c
@ -1216,7 +1213,6 @@ components/soc/esp32s3/include/soc/wdev_reg.h
components/soc/esp32s3/ledc_periph.c components/soc/esp32s3/ledc_periph.c
components/soc/esp32s3/sdio_slave_periph.c components/soc/esp32s3/sdio_slave_periph.c
components/soc/esp32s3/sdmmc_periph.c components/soc/esp32s3/sdmmc_periph.c
components/soc/esp32s3/spi_periph.c
components/soc/esp32s3/uart_periph.c components/soc/esp32s3/uart_periph.c
components/soc/esp32s3/usb_periph.c components/soc/esp32s3/usb_periph.c
components/soc/include/soc/dac_periph.h components/soc/include/soc/dac_periph.h