mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-07 05:35:16 +00:00
spi: fix the crash when callbacks are not in the IRAM
Introduced in9c23b8e5
and4f87a62f
. To get higher speed, menuconfig options are added to put ISR and other functions into the IRAM. The interrupt flag ESP_INTR_FLAG_IRAM is also mistakenly set when the ISR is put into the IRAM. However callbacks, which are wrote by the user, are called in the master and slave ISR. The user may not be aware of that these callbacks are not disabled during flash operations. Any cache miss during flash operation will cause panic. Essentially IRAM functions and intrrupt flag ESP_INTR_FLAG_IRAM are different, the latter means not disabling the ISR during flash operations. New bus_config flag intr_flags is offered to help set the interrupt attribute, including priority level, SHARED, IRAM (not disabled during flash operations). It introduced a small BREAK to IDFv3.1 (but the same as IDFv3.0) that the user has to manually set IRAM flag now (therefore he's aware of the IRAM thing) to void the ISR being disabled during flash operations.
This commit is contained in:

committed by
michael

parent
4c881708dc
commit
8cddfa35b8
@@ -44,8 +44,26 @@ typedef struct {
|
||||
uint32_t flags; ///< Bitwise OR of SPI_SLAVE_* flags
|
||||
int queue_size; ///< Transaction queue size. This sets how many transactions can be 'in the air' (queued using spi_slave_queue_trans but not yet finished using spi_slave_get_trans_result) at the same time
|
||||
uint8_t mode; ///< SPI mode (0-3)
|
||||
slave_transaction_cb_t post_setup_cb; ///< Callback called after the SPI registers are loaded with new data
|
||||
slave_transaction_cb_t post_trans_cb; ///< Callback called after a transaction is done
|
||||
slave_transaction_cb_t post_setup_cb; /**< Callback called after the SPI registers are loaded with new data.
|
||||
*
|
||||
* This callback is called within interrupt
|
||||
* context should be in IRAM for best
|
||||
* performance, see "Transferring Speed"
|
||||
* section in the SPI Master documentation for
|
||||
* full details. If not, the callback may crash
|
||||
* during flash operation when the driver is
|
||||
* initialized with ESP_INTR_FLAG_IRAM.
|
||||
*/
|
||||
slave_transaction_cb_t post_trans_cb; /**< Callback called after a transaction is done.
|
||||
*
|
||||
* This callback is called within interrupt
|
||||
* context should be in IRAM for best
|
||||
* performance, see "Transferring Speed"
|
||||
* section in the SPI Master documentation for
|
||||
* full details. If not, the callback may crash
|
||||
* during flash operation when the driver is
|
||||
* initialized with ESP_INTR_FLAG_IRAM.
|
||||
*/
|
||||
} spi_slave_interface_config_t;
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user