]> granicus.if.org Git - esp-idf/commitdiff
spi_master: fix the dual/quad io issue
authormichael <xiaoxufeng@espressif.com>
Fri, 26 Apr 2019 17:29:48 +0000 (01:29 +0800)
committerMichael (XIAO Xufeng) <xiaoxufeng@espressif.com>
Fri, 26 Apr 2019 17:36:47 +0000 (01:36 +0800)
introduced in f871cc5ffa951032adf435997ed7688e31afb3ba

The issue is caused by

1. The hal didn't pass the io_mode to LL.
2. The setup_device function overwrite the trans-specific settings.

components/driver/spi_master.c
components/soc/src/hal/spi_hal_iram.c

index 23954a2a18f14bcca0fbcbb366e0faf1a397aa46..ca0267c23b205e78776fecea29dabf86a057d3a8 100644 (file)
@@ -647,7 +647,9 @@ static void SPI_MASTER_ISR_ATTR spi_new_trans(spi_device_t *dev, spi_trans_priv_
 
     trans = trans_buf->trans;
     host->cur_cs = dev_id;
-    //We should be done with the transmission.
+
+    //Reconfigure according to device settings, the function only has effect when the dev_id is changed.
+    spi_setup_device(host, dev_id);
 
     hal->tx_bitlen = trans->length;
     hal->rx_bitlen = trans->rxlength;
@@ -683,8 +685,6 @@ static void SPI_MASTER_ISR_ATTR spi_new_trans(spi_device_t *dev, spi_trans_priv_
         hal->dummy_bits = dev->cfg.dummy_bits;
     }
 
-    //Reconfigure according to device settings, the function only has effect when the dev_id is changed.
-    spi_setup_device(host, dev_id);
     spi_hal_setup_trans(hal);
     spi_hal_prepare_data(hal);
 
index 00bd082bf584a362689a5ef6da9f2f5bf3960f8e..2bf0aadb805ad57a3415c85f3920e7f40e1b696a 100644 (file)
@@ -41,11 +41,12 @@ void spi_hal_setup_trans(const spi_hal_context_t *hal)
 {
     spi_dev_t *hw = hal->hw;
 
+    //clear int bit
     spi_ll_clear_int_stat(hal->hw);
+    //We should be done with the transmission.
     assert(spi_ll_get_running_cmd(hw) == 0);
 
-    //clear int bit
-    spi_ll_master_set_io_mode(hw, SPI_LL_IO_MODE_NORMAL);
+    spi_ll_master_set_io_mode(hw, hal->io_mode);
 
     int extra_dummy = 0;
     //when no_dummy is not set and in half-duplex mode, sets the dummy bit if RX phase exist