mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-01 23:51:49 +01:00
spi: fix the crash when callbacks are not in the IRAM
Introduced in9c23b8e5and4f87a62f. 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
@@ -87,6 +87,11 @@ typedef struct {
|
||||
int quadhd_io_num; ///< GPIO pin for HD (HolD) signal which is used as D3 in 4-bit communication modes, or -1 if not used.
|
||||
int max_transfer_sz; ///< Maximum transfer size, in bytes. Defaults to 4094 if 0.
|
||||
uint32_t flags; ///< Abilities of bus to be checked by the driver. Or-ed value of ``SPICOMMON_BUSFLAG_*`` flags.
|
||||
int intr_flags; /**< Interrupt flag for the bus to set the priority, and IRAM attribute, see
|
||||
* ``esp_intr_alloc.h``. Note that the EDGE, INTRDISABLED attribute are ignored
|
||||
* by the driver. Note that if ESP_INTR_FLAG_IRAM is set, ALL the callbacks of
|
||||
* the driver, and their callee functions, should be put in the IRAM.
|
||||
*/
|
||||
} spi_bus_config_t;
|
||||
|
||||
|
||||
|
||||
@@ -79,8 +79,26 @@ typedef struct {
|
||||
int spics_io_num; ///< CS GPIO pin for this device, or -1 if not used
|
||||
uint32_t flags; ///< Bitwise OR of SPI_DEVICE_* flags
|
||||
int queue_size; ///< Transaction queue size. This sets how many transactions can be 'in the air' (queued using spi_device_queue_trans but not yet finished using spi_device_get_trans_result) at the same time
|
||||
transaction_cb_t pre_cb; ///< Callback to be called before a transmission is started. This callback is called within interrupt context.
|
||||
transaction_cb_t post_cb; ///< Callback to be called after a transmission has completed. This callback is called within interrupt context.
|
||||
transaction_cb_t pre_cb; /**< Callback to be called before a transmission is started.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
transaction_cb_t post_cb; /**< Callback to be called after a transmission has completed.
|
||||
*
|
||||
* 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_device_interface_config_t;
|
||||
|
||||
|
||||
|
||||
@@ -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