1 // Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "soc/spi_periph.h"
16 #include "stddef.h"
17 
18 /*
19  Bunch of constants for every SPI peripheral: GPIO signals, irqs, hw addr of registers etc
20 */
21 const spi_signal_conn_t spi_periph_signal[SOC_SPI_PERIPH_NUM] = {
22     {
23         .spiclk_out = SPICLK_OUT_IDX,
24         .spiclk_in = 0,/* SPI clock is not an input signal*/
25         .spid_out = SPID_OUT_IDX,
26         .spiq_out = SPIQ_OUT_IDX,
27         .spiwp_out = SPIWP_OUT_IDX,
28         .spihd_out = SPIHD_OUT_IDX,
29         .spid_in = SPID_IN_IDX,
30         .spiq_in = SPIQ_IN_IDX,
31         .spiwp_in = SPIWP_IN_IDX,
32         .spihd_in = SPIHD_IN_IDX,
33         .spics_out = {SPICS0_OUT_IDX, SPICS1_OUT_IDX},/* SPI0/1 do not have CS2 now */
34         .spics_in = 0,/* SPI cs is not an input signal*/
35         .spiclk_iomux_pin = SPI_IOMUX_PIN_NUM_CLK,
36         .spid_iomux_pin = SPI_IOMUX_PIN_NUM_MOSI,
37         .spiq_iomux_pin = SPI_IOMUX_PIN_NUM_MISO,
38         .spiwp_iomux_pin = SPI_IOMUX_PIN_NUM_WP,
39         .spihd_iomux_pin = SPI_IOMUX_PIN_NUM_HD,
40         .spics0_iomux_pin = SPI_IOMUX_PIN_NUM_CS,
41         .irq = ETS_SPI1_INTR_SOURCE,
42         .irq_dma = -1,
43         .module = PERIPH_SPI_MODULE,
44         .hw = (spi_dev_t *) &SPIMEM1,
45         .func = SPI_FUNC_NUM,
46     }, {
47         .spiclk_out = FSPICLK_OUT_IDX,
48         .spiclk_in = FSPICLK_IN_IDX,
49         .spid_out = FSPID_OUT_IDX,
50         .spiq_out = FSPIQ_OUT_IDX,
51         .spiwp_out = FSPIWP_OUT_IDX,
52         .spihd_out = FSPIHD_OUT_IDX,
53         .spid4_out = FSPIIO4_OUT_IDX,
54         .spid5_out = FSPIIO5_OUT_IDX,
55         .spid6_out = FSPIIO6_OUT_IDX,
56         .spid7_out = FSPIIO7_OUT_IDX,
57         .spid_in = FSPID_IN_IDX,
58         .spiq_in = FSPIQ_IN_IDX,
59         .spiwp_in = FSPIWP_IN_IDX,
60         .spihd_in = FSPIHD_IN_IDX,
61         .spid4_in = FSPIIO4_IN_IDX,
62         .spid5_in = FSPIIO5_IN_IDX,
63         .spid6_in = FSPIIO6_IN_IDX,
64         .spid7_in = FSPIIO7_IN_IDX,
65         .spics_out = {FSPICS0_OUT_IDX, FSPICS1_OUT_IDX, FSPICS2_OUT_IDX},
66         .spics_in = FSPICS0_IN_IDX,
67         .spiclk_iomux_pin = SPI2_IOMUX_PIN_NUM_CLK,
68         .spid_iomux_pin = SPI2_IOMUX_PIN_NUM_MOSI,
69         .spiq_iomux_pin = SPI2_IOMUX_PIN_NUM_MISO,
70         .spiwp_iomux_pin = SPI2_IOMUX_PIN_NUM_WP,
71         .spihd_iomux_pin = SPI2_IOMUX_PIN_NUM_HD,
72         .spics0_iomux_pin = SPI2_IOMUX_PIN_NUM_CS,
73         .irq = ETS_SPI2_INTR_SOURCE,
74         .irq_dma = -1,
75         .module = PERIPH_SPI2_MODULE,
76         .hw = &GPSPI2,
77         .func = SPI2_FUNC_NUM,
78     }, {
79         .spiclk_out = SPI3_CLK_OUT_IDX,
80         .spiclk_in = SPI3_CLK_IN_IDX,
81         .spid_out = SPI3_D_OUT_IDX,
82         .spiq_out = SPI3_Q_OUT_IDX,
83         //SPI3 doesn't have wp and hd signals
84         .spiwp_out = SPI3_WP_OUT_IDX,
85         .spihd_out = SPI3_HD_OUT_IDX,
86         .spid_in = SPI3_D_IN_IDX,
87         .spiq_in = SPI3_Q_IN_IDX,
88         .spiwp_in = SPI3_WP_IN_IDX,
89         .spihd_in = SPI3_HD_IN_IDX,
90         .spics_out = {SPI3_CS0_OUT_IDX, SPI3_CS1_OUT_IDX, SPI3_CS2_OUT_IDX},
91         .spics_in = SPI3_CS0_IN_IDX,
92         //SPI3 doesn't have iomux pins
93         .spiclk_iomux_pin = -1,
94         .spid_iomux_pin = -1,
95         .spiq_iomux_pin = -1,
96         .spiwp_iomux_pin = -1,
97         .spihd_iomux_pin = -1,
98         .spics0_iomux_pin = -1,
99         .irq = ETS_SPI3_INTR_SOURCE,
100         .irq_dma = -1,
101         .module = PERIPH_SPI3_MODULE,
102         .hw = &GPSPI3,
103         .func = -1,
104     }
105 };
106