spi: fix a possible concurrency issue

This commit is contained in:
Michael (XIAO Xufeng) 2019-05-31 15:23:10 +08:00
parent b63be2e08e
commit 1d2a9efa55
1 changed files with 6 additions and 4 deletions

View File

@ -467,12 +467,14 @@ static void SPI_SLAVE_ISR_ATTR spi_intr(void *arg)
}
}
//Disable interrupt before checking to avoid concurrency issue.
esp_intr_disable(host->intr);
//Grab next transaction
r = xQueueReceiveFromISR(host->trans_queue, &trans, &do_yield);
if (!r) {
//No packet waiting. Disable interrupt.
esp_intr_disable(host->intr);
} else {
if (r) {
//enable the interrupt again if there is packet to send
esp_intr_enable(host->intr);
//We have a transaction. Send it.
host->hw->slave.trans_done = 0; //clear int bit
host->cur_trans = trans;