Merge branch 'bugfix/spi_master_length' into 'master'

Fix SPI master transmit length

Tx/Rx length fix from https://github.com/espressif/esp-idf/pull/336

I also added an extra commit in to make use of a define instead of a literal, plus fix a (harmless) off-by-one condition.

See merge request !521
This commit is contained in:
Jeroen Domburg 2017-02-22 17:11:00 +08:00
commit c057f067c7

View file

@ -600,7 +600,7 @@ static void IRAM_ATTR spi_intr(void *arg)
} else { } else {
data=trans->rx_buffer; data=trans->rx_buffer;
} }
if (trans->rxlength<THRESH_DMA_TRANS) { if (trans->rxlength <= THRESH_DMA_TRANS) {
//No need for DMA; we'll copy the result out of the work registers directly later. //No need for DMA; we'll copy the result out of the work registers directly later.
} else { } else {
host->hw->user.usr_miso_highpart=0; host->hw->user.usr_miso_highpart=0;
@ -625,9 +625,9 @@ static void IRAM_ATTR spi_intr(void *arg)
} else { } else {
data=(uint32_t *)trans->tx_buffer; data=(uint32_t *)trans->tx_buffer;
} }
if (trans->rxlength < 8*32) { if (trans->length <= THRESH_DMA_TRANS) {
//No need for DMA. //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 //Use memcpy to get around alignment issues for txdata
uint32_t word; uint32_t word;
memcpy(&word, &data[x/32], 4); 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->addr=trans->address & 0xffffffff;
} }
host->hw->user.usr_mosi=(trans->tx_buffer==NULL)?0:1; 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 //Call pre-transmission callback, if any
if (dev->cfg.pre_cb) dev->cfg.pre_cb(trans); if (dev->cfg.pre_cb) dev->cfg.pre_cb(trans);