|
|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
- * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
|
|
+ * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
|
|
*
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
*/
|
|
|
@@ -40,6 +40,7 @@ extern "C" {
|
|
|
|
|
|
#define SPI_LL_DMA_MAX_BIT_LEN (1 << 18) //reg len: 18 bits
|
|
|
#define SPI_LL_CPU_MAX_BIT_LEN (16 * 32) //Fifo len: 16 words
|
|
|
+#define SPI_LL_MOSI_FREE_LEVEL 1 //Default level after bus initialized
|
|
|
|
|
|
/**
|
|
|
* The data structure holding calculated clock configuration. Since the
|
|
|
@@ -186,36 +187,44 @@ static inline void spi_ll_slave_hd_init(spi_dev_t *hw)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Check whether user-defined transaction is done.
|
|
|
+ * Determine and unify the default level of mosi line when bus free
|
|
|
*
|
|
|
* @param hw Beginning address of the peripheral registers.
|
|
|
- *
|
|
|
- * @return True if transaction is done, otherwise false.
|
|
|
*/
|
|
|
-static inline bool spi_ll_usr_is_done(spi_dev_t *hw)
|
|
|
+static inline void spi_ll_set_mosi_free_level(spi_dev_t *hw, bool level)
|
|
|
{
|
|
|
- return hw->dma_int_raw.trans_done;
|
|
|
+ hw->ctrl.d_pol = level; //set default level for MOSI only on IDLE state
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Trigger start of user-defined transaction for master.
|
|
|
- * The synchronization between two clock domains is required in ESP32-S3
|
|
|
+ * Apply the register configurations and wait until it's done
|
|
|
*
|
|
|
* @param hw Beginning address of the peripheral registers.
|
|
|
*/
|
|
|
-static inline void spi_ll_master_user_start(spi_dev_t *hw)
|
|
|
+static inline void spi_ll_apply_config(spi_dev_t *hw)
|
|
|
{
|
|
|
hw->cmd.update = 1;
|
|
|
- while (hw->cmd.update);
|
|
|
- hw->cmd.usr = 1;
|
|
|
+ while (hw->cmd.update); //waiting config applied
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Check whether user-defined transaction is done.
|
|
|
+ *
|
|
|
+ * @param hw Beginning address of the peripheral registers.
|
|
|
+ *
|
|
|
+ * @return True if transaction is done, otherwise false.
|
|
|
+ */
|
|
|
+static inline bool spi_ll_usr_is_done(spi_dev_t *hw)
|
|
|
+{
|
|
|
+ return hw->dma_int_raw.trans_done;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Trigger start of user-defined transaction for slave.
|
|
|
+ * Trigger start of user-defined transaction.
|
|
|
*
|
|
|
* @param hw Beginning address of the peripheral registers.
|
|
|
*/
|
|
|
-static inline void spi_ll_slave_user_start(spi_dev_t *hw)
|
|
|
+static inline void spi_ll_user_start(spi_dev_t *hw)
|
|
|
{
|
|
|
hw->cmd.usr = 1;
|
|
|
}
|