]> granicus.if.org Git - esp-idf/commitdiff
Fix SPI read edges in spi_intr
authorLourens Naudé <lourens@methodmissing.com>
Sun, 12 Feb 2017 22:59:09 +0000 (22:59 +0000)
committerJeroen Domburg <jeroen@espressif.com>
Tue, 21 Feb 2017 10:26:03 +0000 (18:26 +0800)
Signed-off-by: Jeroen Domburg <jeroen@espressif.com>
components/driver/spi_master.c

index f37f7aaf19d0cce27205c58ecab5ea365a71b1ee..4f977c889eaf4ab056508b7f91c3e805de6fb6c6 100644 (file)
@@ -625,9 +625,9 @@ static void IRAM_ATTR spi_intr(void *arg)
             } else {
                 data=(uint32_t *)trans->tx_buffer;
             }
-            if (trans->rxlength < 8*32) {
+            if (trans->length < 8*32) {
                 //No need for DMA.
-                for (int x=0; x < trans->rxlength; x+=32) {
+                for (int x=0; x < trans->length; x+=32) {
                     //Use memcpy to get around alignment issues for txdata
                     uint32_t word;
                     memcpy(&word, &data[x/32], 4);
@@ -656,7 +656,7 @@ static void IRAM_ATTR spi_intr(void *arg)
             host->hw->addr=trans->address & 0xffffffff;
         }
         host->hw->user.usr_mosi=(trans->tx_buffer==NULL)?0:1;
-        host->hw->user.usr_miso=(trans->tx_buffer==NULL)?0:1;
+        host->hw->user.usr_miso=(trans->rx_buffer==NULL)?0:1;
 
         //Call pre-transmission callback, if any
         if (dev->cfg.pre_cb) dev->cfg.pre_cb(trans);