From afbe1ba8789bda2937a65fa58217c843d80c255b Mon Sep 17 00:00:00 2001 From: "Michael (XIAO Xufeng)" Date: Tue, 3 Sep 2019 14:06:26 +0800 Subject: [PATCH] spi: move deprecated functions into internal header Resolves https://github.com/espressif/esp-idf/issues/4132 --- components/driver/include/driver/spi_common.h | 281 +----------------- .../include/driver/spi_common_internal.h | 267 +++++++++++++++++ components/driver/spi_common.c | 2 +- components/driver/spi_master.c | 2 +- components/driver/spi_slave.c | 2 +- components/driver/test/test_spi_master.c | 1 + components/esp32/clk.c | 2 +- components/esp32/spiram_psram.c | 10 +- components/esp32/test/test_4mpsram.c | 2 +- components/spi_flash/esp_flash_spi_init.c | 2 +- components/spi_flash/test/test_esp_flash.c | 3 +- 11 files changed, 293 insertions(+), 281 deletions(-) create mode 100644 components/driver/include/driver/spi_common_internal.h diff --git a/components/driver/include/driver/spi_common.h b/components/driver/include/driver/spi_common.h index 50bc0fbce..eab9b3527 100644 --- a/components/driver/include/driver/spi_common.h +++ b/components/driver/include/driver/spi_common.h @@ -27,7 +27,6 @@ extern "C" { #endif - //Maximum amount of bytes that can be put in one DMA descriptor #define SPI_MAX_DMA_LEN (4096-4) @@ -60,6 +59,19 @@ extern "C" */ #define SPI_SWAP_DATA_RX(DATA, LEN) (__builtin_bswap32(DATA)>>(32-(LEN))) +#define SPICOMMON_BUSFLAG_SLAVE 0 ///< Initialize I/O in slave mode +#define SPICOMMON_BUSFLAG_MASTER (1<<0) ///< Initialize I/O in master mode +#define SPICOMMON_BUSFLAG_IOMUX_PINS (1<<1) ///< Check using iomux pins. Or indicates the pins are configured through the IO mux rather than GPIO matrix. +#define SPICOMMON_BUSFLAG_SCLK (1<<2) ///< Check existing of SCLK pin. Or indicates CLK line initialized. +#define SPICOMMON_BUSFLAG_MISO (1<<3) ///< Check existing of MISO pin. Or indicates MISO line initialized. +#define SPICOMMON_BUSFLAG_MOSI (1<<4) ///< Check existing of MOSI pin. Or indicates CLK line initialized. +#define SPICOMMON_BUSFLAG_DUAL (1<<5) ///< Check MOSI and MISO pins can output. Or indicates bus able to work under DIO mode. +#define SPICOMMON_BUSFLAG_WPHD (1<<6) ///< Check existing of WP and HD pins. Or indicates WP & HD pins initialized. +#define SPICOMMON_BUSFLAG_QUAD (SPICOMMON_BUSFLAG_DUAL|SPICOMMON_BUSFLAG_WPHD) ///< Check existing of MOSI/MISO/WP/HD pins as output. Or indicates bus able to work under QIO mode. + +#define SPICOMMON_BUSFLAG_NATIVE_PINS SPICOMMON_BUSFLAG_IOMUX_PINS + + /** * @brief This is a configuration structure for a SPI bus. * @@ -127,273 +139,6 @@ esp_err_t spi_bus_initialize(spi_host_device_t host, const spi_bus_config_t *bus esp_err_t spi_bus_free(spi_host_device_t host); -/** @cond */ //Doxygen command to hide deprecated function (or non-public) from API Reference - -/** - * @brief Try to claim a SPI peripheral - * - * Call this if your driver wants to manage a SPI peripheral. - * - * @param host Peripheral to claim - * @param source The caller indentification string. - * - * @note This public API is deprecated. - * - * @return True if peripheral is claimed successfully; false if peripheral already is claimed. - */ -bool spicommon_periph_claim(spi_host_device_t host, const char* source); - -/** - * @brief Check whether the spi periph is in use. - * - * @param host Peripheral to check. - * - * @note This public API is deprecated. - * - * @return True if in use, otherwise false. - */ -bool spicommon_periph_in_use(spi_host_device_t host); - -/** - * @brief Return the SPI peripheral so another driver can claim it. - * - * @param host Peripheral to return - * - * @note This public API is deprecated. - * - * @return True if peripheral is returned successfully; false if peripheral was free to claim already. - */ -bool spicommon_periph_free(spi_host_device_t host); - -/** - * @brief Try to claim a SPI DMA channel - * - * Call this if your driver wants to use SPI with a DMA channnel. - * - * @param dma_chan channel to claim - * - * @note This public API is deprecated. - * - * @return True if success; false otherwise. - */ -bool spicommon_dma_chan_claim(int dma_chan); - -/** - * @brief Check whether the spi DMA channel is in use. - * - * @param dma_chan DMA channel to check. - * - * @note This public API is deprecated. - * - * @return True if in use, otherwise false. - */ -bool spicommon_dma_chan_in_use(int dma_chan); - -/** - * @brief Return the SPI DMA channel so other driver can claim it, or just to power down DMA. - * - * @param dma_chan channel to return - * - * @note This public API is deprecated. - * - * @return True if success; false otherwise. - */ -bool spicommon_dma_chan_free(int dma_chan); - -/// @note macros deprecated from public API -#define SPICOMMON_BUSFLAG_SLAVE 0 ///< Initialize I/O in slave mode -#define SPICOMMON_BUSFLAG_MASTER (1<<0) ///< Initialize I/O in master mode -#define SPICOMMON_BUSFLAG_IOMUX_PINS (1<<1) ///< Check using iomux pins. Or indicates the pins are configured through the IO mux rather than GPIO matrix. -#define SPICOMMON_BUSFLAG_SCLK (1<<2) ///< Check existing of SCLK pin. Or indicates CLK line initialized. -#define SPICOMMON_BUSFLAG_MISO (1<<3) ///< Check existing of MISO pin. Or indicates MISO line initialized. -#define SPICOMMON_BUSFLAG_MOSI (1<<4) ///< Check existing of MOSI pin. Or indicates CLK line initialized. -#define SPICOMMON_BUSFLAG_DUAL (1<<5) ///< Check MOSI and MISO pins can output. Or indicates bus able to work under DIO mode. -#define SPICOMMON_BUSFLAG_WPHD (1<<6) ///< Check existing of WP and HD pins. Or indicates WP & HD pins initialized. -#define SPICOMMON_BUSFLAG_QUAD (SPICOMMON_BUSFLAG_DUAL|SPICOMMON_BUSFLAG_WPHD) ///< Check existing of MOSI/MISO/WP/HD pins as output. Or indicates bus able to work under QIO mode. - -#define SPICOMMON_BUSFLAG_NATIVE_PINS SPICOMMON_BUSFLAG_IOMUX_PINS - - -/** - * @brief Connect a SPI peripheral to GPIO pins - * - * This routine is used to connect a SPI peripheral to the IO-pads and DMA channel given in - * the arguments. Depending on the IO-pads requested, the routing is done either using the - * IO_mux or using the GPIO matrix. - * - * @note This public API is deprecated. Please call ``spi_bus_initialize`` for master - * bus initialization and ``spi_slave_initialize`` for slave initialization. - * - * @param host SPI peripheral to be routed - * @param bus_config Pointer to a spi_bus_config struct detailing the GPIO pins - * @param dma_chan DMA-channel (1 or 2) to use, or 0 for no DMA. - * @param flags Combination of SPICOMMON_BUSFLAG_* flags, set to ensure the pins set are capable with some functions: - * - ``SPICOMMON_BUSFLAG_MASTER``: Initialize I/O in master mode - * - ``SPICOMMON_BUSFLAG_SLAVE``: Initialize I/O in slave mode - * - ``SPICOMMON_BUSFLAG_IOMUX_PINS``: Pins set should match the iomux pins of the controller. - * - ``SPICOMMON_BUSFLAG_SCLK``, ``SPICOMMON_BUSFLAG_MISO``, ``SPICOMMON_BUSFLAG_MOSI``: - * Make sure SCLK/MISO/MOSI is/are set to a valid GPIO. Also check output capability according to the mode. - * - ``SPICOMMON_BUSFLAG_DUAL``: Make sure both MISO and MOSI are output capable so that DIO mode is capable. - * - ``SPICOMMON_BUSFLAG_WPHD`` Make sure WP and HD are set to valid output GPIOs. - * - ``SPICOMMON_BUSFLAG_QUAD``: Combination of ``SPICOMMON_BUSFLAG_DUAL`` and ``SPICOMMON_BUSFLAG_WPHD``. - * @param[out] flags_o A SPICOMMON_BUSFLAG_* flag combination of bus abilities will be written to this address. - * Leave to NULL if not needed. - * - ``SPICOMMON_BUSFLAG_IOMUX_PINS``: The bus is connected to iomux pins. - * - ``SPICOMMON_BUSFLAG_SCLK``, ``SPICOMMON_BUSFLAG_MISO``, ``SPICOMMON_BUSFLAG_MOSI``: The bus has - * CLK/MISO/MOSI connected. - * - ``SPICOMMON_BUSFLAG_DUAL``: The bus is capable with DIO mode. - * - ``SPICOMMON_BUSFLAG_WPHD`` The bus has WP and HD connected. - * - ``SPICOMMON_BUSFLAG_QUAD``: Combination of ``SPICOMMON_BUSFLAG_DUAL`` and ``SPICOMMON_BUSFLAG_WPHD``. - * @return - * - ESP_ERR_INVALID_ARG if parameter is invalid - * - ESP_OK on success - */ -esp_err_t spicommon_bus_initialize_io(spi_host_device_t host, const spi_bus_config_t *bus_config, int dma_chan, uint32_t flags, uint32_t *flags_o); - -/** - * @brief Free the IO used by a SPI peripheral - * - * @note This public API is deprecated. Please call ``spi_bus_free`` for master - * bus deinitialization and ``spi_slave_free`` for slave deinitialization. - * - * @param bus_cfg Bus config struct which defines which pins to be used. - * - * @return - * - ESP_ERR_INVALID_ARG if parameter is invalid - * - ESP_OK on success - */ -esp_err_t spicommon_bus_free_io_cfg(const spi_bus_config_t *bus_cfg); - -/** - * @brief Initialize a Chip Select pin for a specific SPI peripheral - * - * @note This public API is deprecated. Please call corresponding device initialization - * functions. - * - * @param host SPI peripheral - * @param cs_io_num GPIO pin to route - * @param cs_num CS id to route - * @param force_gpio_matrix If true, CS will always be routed through the GPIO matrix. If false, - * if the GPIO number allows it, the routing will happen through the IO_mux. - */ -void spicommon_cs_initialize(spi_host_device_t host, int cs_io_num, int cs_num, int force_gpio_matrix); - -/** - * @brief Free a chip select line - * - * @param cs_gpio_num CS gpio num to free - * - * @note This public API is deprecated. - */ -void spicommon_cs_free_io(int cs_gpio_num); - -/** - * @brief Check whether all pins used by a host are through IOMUX. - * - * @param host SPI peripheral - * - * @note This public API is deprecated. - * - * @return false if any pins are through the GPIO matrix, otherwise true. - */ -bool spicommon_bus_using_iomux(spi_host_device_t host); - -/** - * @brief Check whether all pins used by a host are through IOMUX. - * - * @param host SPI peripheral - * - * @note This public API is deprecated. - * - * @return false if any pins are through the GPIO matrix, otherwise true. - */ -bool spicommon_bus_using_iomux(spi_host_device_t host); - -/** - * @brief Get the IRQ source for a specific SPI host - * - * @param host The SPI host - * - * @note This public API is deprecated. - * - * @return The hosts IRQ source - */ -int spicommon_irqsource_for_host(spi_host_device_t host); - -/** - * @brief Get the IRQ source for a specific SPI DMA - * - * @param host The SPI host - * - * @note This public API is deprecated. - * - * @return The hosts IRQ source - */ -int spicommon_irqdma_source_for_host(spi_host_device_t host); - -/** - * Callback, to be called when a DMA engine reset is completed -*/ -typedef void(*dmaworkaround_cb_t)(void *arg); - - -/** - * @brief Request a reset for a certain DMA channel - * - * @note In some (well-defined) cases in the ESP32 (at least rev v.0 and v.1), a SPI DMA channel will get confused. This can be remedied - * by resetting the SPI DMA hardware in case this happens. Unfortunately, the reset knob used for thsi will reset _both_ DMA channels, and - * as such can only done safely when both DMA channels are idle. These functions coordinate this. - * - * Essentially, when a reset is needed, a driver can request this using spicommon_dmaworkaround_req_reset. This is supposed to be called - * with an user-supplied function as an argument. If both DMA channels are idle, this call will reset the DMA subsystem and return true. - * If the other DMA channel is still busy, it will return false; as soon as the other DMA channel is done, however, it will reset the - * DMA subsystem and call the callback. The callback is then supposed to be used to continue the SPI drivers activity. - * - * @param dmachan DMA channel associated with the SPI host that needs a reset - * @param cb Callback to call in case DMA channel cannot be reset immediately - * @param arg Argument to the callback - * - * @note This public API is deprecated. - * - * @return True when a DMA reset could be executed immediately. False when it could not; in this - * case the callback will be called with the specified argument when the logic can execute - * a reset, after that reset. - */ -bool spicommon_dmaworkaround_req_reset(int dmachan, dmaworkaround_cb_t cb, void *arg); - - -/** - * @brief Check if a DMA reset is requested but has not completed yet - * - * @note This public API is deprecated. - * - * @return True when a DMA reset is requested but hasn't completed yet. False otherwise. - */ -bool spicommon_dmaworkaround_reset_in_progress(void); - - -/** - * @brief Mark a DMA channel as idle. - * - * A call to this function tells the workaround logic that this channel will - * not be affected by a global SPI DMA reset. - * - * @note This public API is deprecated. - */ -void spicommon_dmaworkaround_idle(int dmachan); - -/** - * @brief Mark a DMA channel as active. - * - * A call to this function tells the workaround logic that this channel will - * be affected by a global SPI DMA reset, and a reset like that should not be attempted. - * - * @note This public API is deprecated. - */ -void spicommon_dmaworkaround_transfer_active(int dmachan); - -/** @endcond */ - #ifdef __cplusplus } #endif diff --git a/components/driver/include/driver/spi_common_internal.h b/components/driver/include/driver/spi_common_internal.h new file mode 100644 index 000000000..8b692745b --- /dev/null +++ b/components/driver/include/driver/spi_common_internal.h @@ -0,0 +1,267 @@ +// Copyright 2010-2019 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// 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. + +// Internal header, don't use it in the user code + +#pragma once + +#include "driver/spi_common.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** + * @brief Try to claim a SPI peripheral + * + * Call this if your driver wants to manage a SPI peripheral. + * + * @param host Peripheral to claim + * @param source The caller indentification string. + * + * @note This public API is deprecated. + * + * @return True if peripheral is claimed successfully; false if peripheral already is claimed. + */ +bool spicommon_periph_claim(spi_host_device_t host, const char* source); + +/** + * @brief Check whether the spi periph is in use. + * + * @param host Peripheral to check. + * + * @note This public API is deprecated. + * + * @return True if in use, otherwise false. + */ +bool spicommon_periph_in_use(spi_host_device_t host); + +/** + * @brief Return the SPI peripheral so another driver can claim it. + * + * @param host Peripheral to return + * + * @note This public API is deprecated. + * + * @return True if peripheral is returned successfully; false if peripheral was free to claim already. + */ +bool spicommon_periph_free(spi_host_device_t host); + +/** + * @brief Try to claim a SPI DMA channel + * + * Call this if your driver wants to use SPI with a DMA channnel. + * + * @param dma_chan channel to claim + * + * @note This public API is deprecated. + * + * @return True if success; false otherwise. + */ +bool spicommon_dma_chan_claim(int dma_chan); + +/** + * @brief Check whether the spi DMA channel is in use. + * + * @param dma_chan DMA channel to check. + * + * @note This public API is deprecated. + * + * @return True if in use, otherwise false. + */ +bool spicommon_dma_chan_in_use(int dma_chan); + +/** + * @brief Return the SPI DMA channel so other driver can claim it, or just to power down DMA. + * + * @param dma_chan channel to return + * + * @note This public API is deprecated. + * + * @return True if success; false otherwise. + */ +bool spicommon_dma_chan_free(int dma_chan); + +/** + * @brief Connect a SPI peripheral to GPIO pins + * + * This routine is used to connect a SPI peripheral to the IO-pads and DMA channel given in + * the arguments. Depending on the IO-pads requested, the routing is done either using the + * IO_mux or using the GPIO matrix. + * + * @note This public API is deprecated. Please call ``spi_bus_initialize`` for master + * bus initialization and ``spi_slave_initialize`` for slave initialization. + * + * @param host SPI peripheral to be routed + * @param bus_config Pointer to a spi_bus_config struct detailing the GPIO pins + * @param dma_chan DMA-channel (1 or 2) to use, or 0 for no DMA. + * @param flags Combination of SPICOMMON_BUSFLAG_* flags, set to ensure the pins set are capable with some functions: + * - ``SPICOMMON_BUSFLAG_MASTER``: Initialize I/O in master mode + * - ``SPICOMMON_BUSFLAG_SLAVE``: Initialize I/O in slave mode + * - ``SPICOMMON_BUSFLAG_IOMUX_PINS``: Pins set should match the iomux pins of the controller. + * - ``SPICOMMON_BUSFLAG_SCLK``, ``SPICOMMON_BUSFLAG_MISO``, ``SPICOMMON_BUSFLAG_MOSI``: + * Make sure SCLK/MISO/MOSI is/are set to a valid GPIO. Also check output capability according to the mode. + * - ``SPICOMMON_BUSFLAG_DUAL``: Make sure both MISO and MOSI are output capable so that DIO mode is capable. + * - ``SPICOMMON_BUSFLAG_WPHD`` Make sure WP and HD are set to valid output GPIOs. + * - ``SPICOMMON_BUSFLAG_QUAD``: Combination of ``SPICOMMON_BUSFLAG_DUAL`` and ``SPICOMMON_BUSFLAG_WPHD``. + * @param[out] flags_o A SPICOMMON_BUSFLAG_* flag combination of bus abilities will be written to this address. + * Leave to NULL if not needed. + * - ``SPICOMMON_BUSFLAG_IOMUX_PINS``: The bus is connected to iomux pins. + * - ``SPICOMMON_BUSFLAG_SCLK``, ``SPICOMMON_BUSFLAG_MISO``, ``SPICOMMON_BUSFLAG_MOSI``: The bus has + * CLK/MISO/MOSI connected. + * - ``SPICOMMON_BUSFLAG_DUAL``: The bus is capable with DIO mode. + * - ``SPICOMMON_BUSFLAG_WPHD`` The bus has WP and HD connected. + * - ``SPICOMMON_BUSFLAG_QUAD``: Combination of ``SPICOMMON_BUSFLAG_DUAL`` and ``SPICOMMON_BUSFLAG_WPHD``. + * @return + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_OK on success + */ +esp_err_t spicommon_bus_initialize_io(spi_host_device_t host, const spi_bus_config_t *bus_config, int dma_chan, uint32_t flags, uint32_t *flags_o); + +/** + * @brief Free the IO used by a SPI peripheral + * + * @note This public API is deprecated. Please call ``spi_bus_free`` for master + * bus deinitialization and ``spi_slave_free`` for slave deinitialization. + * + * @param bus_cfg Bus config struct which defines which pins to be used. + * + * @return + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_OK on success + */ +esp_err_t spicommon_bus_free_io_cfg(const spi_bus_config_t *bus_cfg); + +/** + * @brief Initialize a Chip Select pin for a specific SPI peripheral + * + * @note This public API is deprecated. Please call corresponding device initialization + * functions. + * + * @param host SPI peripheral + * @param cs_io_num GPIO pin to route + * @param cs_num CS id to route + * @param force_gpio_matrix If true, CS will always be routed through the GPIO matrix. If false, + * if the GPIO number allows it, the routing will happen through the IO_mux. + */ +void spicommon_cs_initialize(spi_host_device_t host, int cs_io_num, int cs_num, int force_gpio_matrix); + +/** + * @brief Free a chip select line + * + * @param cs_gpio_num CS gpio num to free + * + * @note This public API is deprecated. + */ +void spicommon_cs_free_io(int cs_gpio_num); + +/** + * @brief Check whether all pins used by a host are through IOMUX. + * + * @param host SPI peripheral + * + * @note This public API is deprecated. + * + * @return false if any pins are through the GPIO matrix, otherwise true. + */ +bool spicommon_bus_using_iomux(spi_host_device_t host); + +/** + * @brief Get the IRQ source for a specific SPI host + * + * @param host The SPI host + * + * @note This public API is deprecated. + * + * @return The hosts IRQ source + */ +int spicommon_irqsource_for_host(spi_host_device_t host); + +/** + * @brief Get the IRQ source for a specific SPI DMA + * + * @param host The SPI host + * + * @note This public API is deprecated. + * + * @return The hosts IRQ source + */ +int spicommon_irqdma_source_for_host(spi_host_device_t host); + +/** + * Callback, to be called when a DMA engine reset is completed +*/ +typedef void(*dmaworkaround_cb_t)(void *arg); + + +/** + * @brief Request a reset for a certain DMA channel + * + * @note In some (well-defined) cases in the ESP32 (at least rev v.0 and v.1), a SPI DMA channel will get confused. This can be remedied + * by resetting the SPI DMA hardware in case this happens. Unfortunately, the reset knob used for thsi will reset _both_ DMA channels, and + * as such can only done safely when both DMA channels are idle. These functions coordinate this. + * + * Essentially, when a reset is needed, a driver can request this using spicommon_dmaworkaround_req_reset. This is supposed to be called + * with an user-supplied function as an argument. If both DMA channels are idle, this call will reset the DMA subsystem and return true. + * If the other DMA channel is still busy, it will return false; as soon as the other DMA channel is done, however, it will reset the + * DMA subsystem and call the callback. The callback is then supposed to be used to continue the SPI drivers activity. + * + * @param dmachan DMA channel associated with the SPI host that needs a reset + * @param cb Callback to call in case DMA channel cannot be reset immediately + * @param arg Argument to the callback + * + * @note This public API is deprecated. + * + * @return True when a DMA reset could be executed immediately. False when it could not; in this + * case the callback will be called with the specified argument when the logic can execute + * a reset, after that reset. + */ +bool spicommon_dmaworkaround_req_reset(int dmachan, dmaworkaround_cb_t cb, void *arg); + + +/** + * @brief Check if a DMA reset is requested but has not completed yet + * + * @note This public API is deprecated. + * + * @return True when a DMA reset is requested but hasn't completed yet. False otherwise. + */ +bool spicommon_dmaworkaround_reset_in_progress(void); + + +/** + * @brief Mark a DMA channel as idle. + * + * A call to this function tells the workaround logic that this channel will + * not be affected by a global SPI DMA reset. + * + * @note This public API is deprecated. + */ +void spicommon_dmaworkaround_idle(int dmachan); + +/** + * @brief Mark a DMA channel as active. + * + * A call to this function tells the workaround logic that this channel will + * be affected by a global SPI DMA reset, and a reset like that should not be attempted. + * + * @note This public API is deprecated. + */ +void spicommon_dmaworkaround_transfer_active(int dmachan); + +#ifdef __cplusplus +} +#endif diff --git a/components/driver/spi_common.c b/components/driver/spi_common.c index a8954d07c..83ab84eea 100644 --- a/components/driver/spi_common.c +++ b/components/driver/spi_common.c @@ -27,7 +27,7 @@ #include "driver/gpio.h" #include "driver/periph_ctrl.h" #include "esp_heap_caps.h" -#include "driver/spi_common.h" +#include "driver/spi_common_internal.h" #include "stdatomic.h" #include "hal/spi_hal.h" diff --git a/components/driver/spi_master.c b/components/driver/spi_master.c index 14a9e08a4..fee42c148 100644 --- a/components/driver/spi_master.c +++ b/components/driver/spi_master.c @@ -119,7 +119,7 @@ We have two bits to control the interrupt: */ #include -#include "driver/spi_common.h" +#include "driver/spi_common_internal.h" #include "driver/spi_master.h" #include "soc/spi_periph.h" #include "esp32/rom/ets_sys.h" diff --git a/components/driver/spi_slave.c b/components/driver/spi_slave.c index 01cc97525..abefdc767 100644 --- a/components/driver/spi_slave.c +++ b/components/driver/spi_slave.c @@ -16,7 +16,7 @@ #include #include #include -#include "driver/spi_common.h" +#include "driver/spi_common_internal.h" #include "driver/spi_slave.h" #include "soc/spi_periph.h" #include "esp32/rom/ets_sys.h" diff --git a/components/driver/test/test_spi_master.c b/components/driver/test/test_spi_master.c index 5b1c3c233..7e773cd68 100644 --- a/components/driver/test/test_spi_master.c +++ b/components/driver/test/test_spi_master.c @@ -25,6 +25,7 @@ #include "sdkconfig.h" #include "../cache_utils.h" #include "soc/soc_memory_layout.h" +#include "driver/spi_common_internal.h" const static char TAG[] = "test_spi"; diff --git a/components/esp32/clk.c b/components/esp32/clk.c index 28bcbec7f..9ac244a9e 100644 --- a/components/esp32/clk.c +++ b/components/esp32/clk.c @@ -33,7 +33,7 @@ #include "driver/periph_ctrl.h" #include "xtensa/core-macros.h" #include "bootloader_clock.h" -#include "driver/spi_common.h" +#include "driver/spi_common_internal.h" /* Number of cycles to wait from the 32k XTAL oscillator to consider it running. * Larger values increase startup delay. Smaller values may cause false positive diff --git a/components/esp32/spiram_psram.c b/components/esp32/spiram_psram.c index 67e4d5af1..b23e7fa9c 100644 --- a/components/esp32/spiram_psram.c +++ b/components/esp32/spiram_psram.c @@ -33,7 +33,7 @@ #include "soc/efuse_periph.h" #include "soc/spi_caps.h" #include "driver/gpio.h" -#include "driver/spi_common.h" +#include "driver/spi_common_internal.h" #include "driver/periph_ctrl.h" #include "bootloader_common.h" @@ -469,7 +469,7 @@ static esp_err_t IRAM_ATTR psram_enable_qio_mode(psram_spi_num_t spi_num) void psram_set_cs_timing(psram_spi_num_t spi_num, psram_clk_mode_t clk_mode) { - if (clk_mode == PSRAM_CLK_MODE_NORM) { + if (clk_mode == PSRAM_CLK_MODE_NORM) { SET_PERI_REG_MASK(SPI_USER_REG(spi_num), SPI_CS_HOLD_M | SPI_CS_SETUP_M); // Set cs time. SET_PERI_REG_BITS(SPI_CTRL2_REG(spi_num), SPI_HOLD_TIME_V, 1, SPI_HOLD_TIME_S); @@ -566,7 +566,7 @@ static void IRAM_ATTR psram_gpio_config(psram_io_t *psram_io, psram_cache_mode_t gpio_matrix_in(psram_io->psram_spiwp_sd3_io, SPIWP_IN_IDX, 0); gpio_matrix_out(psram_io->psram_spihd_sd2_io, SPIHD_OUT_IDX, 0, 0); gpio_matrix_in(psram_io->psram_spihd_sd2_io, SPIHD_IN_IDX, 0); - + //select pin function gpio if ((psram_io->flash_clk_io == SPI_IOMUX_PIN_NUM_CLK) && (psram_io->flash_clk_io != psram_io->psram_clk_io)) { //flash clock signal should come from IO MUX. @@ -685,7 +685,7 @@ esp_err_t IRAM_ATTR psram_enable(psram_cache_mode_t mode, psram_vaddr_mode_t vad CLEAR_PERI_REG_MASK(SPI_USER_REG(PSRAM_SPI_1), SPI_USR_PREP_HOLD_M); psram_spi_init(PSRAM_SPI_1, mode); - + switch (mode) { case PSRAM_CACHE_F80M_S80M: gpio_matrix_out(psram_io.psram_clk_io, SPICLK_OUT_IDX, 0, 0); @@ -754,7 +754,7 @@ esp_err_t IRAM_ATTR psram_enable(psram_cache_mode_t mode, psram_vaddr_mode_t vad gpio_matrix_out(PSRAM_INTERNAL_IO_29, SIG_GPIO_OUT_IDX, 0, 0); gpio_matrix_out(psram_io.psram_clk_io, SPICLK_OUT_IDX, 0, 0); } - + // Update cs timing according to psram driving method. psram_set_cs_timing(PSRAM_SPI_1, s_clk_mode); psram_set_cs_timing(_SPI_CACHE_PORT, s_clk_mode); diff --git a/components/esp32/test/test_4mpsram.c b/components/esp32/test/test_4mpsram.c index 9e8688214..64210b30b 100644 --- a/components/esp32/test/test_4mpsram.c +++ b/components/esp32/test/test_4mpsram.c @@ -1,7 +1,7 @@ #include "esp_heap_caps.h" #include "unity.h" #include "esp_log.h" -#include "driver/spi_common.h" +#include "driver/spi_common_internal.h" #include "sdkconfig.h" static const char TAG[] = "test_psram"; diff --git a/components/spi_flash/esp_flash_spi_init.c b/components/spi_flash/esp_flash_spi_init.c index 9938ab3fb..01b6ec717 100644 --- a/components/spi_flash/esp_flash_spi_init.c +++ b/components/spi_flash/esp_flash_spi_init.c @@ -21,7 +21,7 @@ #include "esp_log.h" #include "esp_heap_caps.h" #include "hal/spi_types.h" -#include "driver/spi_common.h" +#include "driver/spi_common_internal.h" #include "esp_flash_internal.h" __attribute__((unused)) static const char TAG[] = "spi_flash"; diff --git a/components/spi_flash/test/test_esp_flash.c b/components/spi_flash/test/test_esp_flash.c index 19a93c8bf..f6eaf94f1 100644 --- a/components/spi_flash/test/test_esp_flash.c +++ b/components/spi_flash/test/test_esp_flash.c @@ -6,7 +6,7 @@ #include #include "esp_flash.h" -#include "driver/spi_common.h" +#include "driver/spi_common_internal.h" #include "esp_flash_spi_init.h" #include #include "esp_log.h" @@ -14,7 +14,6 @@ #include #include "unity.h" -#include "driver/spi_common.h" #include "driver/gpio.h" #include "soc/io_mux_reg.h"