Skip to content

Commit 86e04aa

Browse files
committed
add flags to interrupt allocator
1 parent 5c9e1a4 commit 86e04aa

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

cores/esp32/esp32-hal-i2c.c

+8-9
Original file line numberDiff line numberDiff line change
@@ -931,15 +931,14 @@ i2c_err_t i2cProcQueue(i2c_t * i2c, uint32_t *readCount, uint16_t timeOutMillis)
931931
if(!i2c->intr_handle) { // create ISR for either peripheral
932932
// log_i("create ISR %d",i2c->num);
933933
uint32_t ret = 0;
934-
switch(i2c->num) {
935-
case 0:
936-
ret = esp_intr_alloc(ETS_I2C_EXT0_INTR_SOURCE, 0, &i2c_isr_handler_default, i2c, &i2c->intr_handle);
937-
break;
938-
case 1:
939-
ret = esp_intr_alloc(ETS_I2C_EXT1_INTR_SOURCE, 0, &i2c_isr_handler_default, i2c, &i2c->intr_handle);
940-
break;
941-
default :
942-
;
934+
uint32_t flags = ESP_INTR_FLAG_EDGE | //< Edge-triggered interrupt
935+
ESP_INTR_FLAG_IRAM | //< ISR can be called if cache is disabled
936+
ESP_INTR_FLAG_LOWMED; //< Low and medium prio interrupts. These can be handled in C.
937+
938+
if(i2c->num) {
939+
ret = esp_intr_alloc_intrstatus(ETS_I2C_EXT1_INTR_SOURCE, flags, (uint32_t)&i2c->dev->int_status.val, 0x1FFF, &i2c_isr_handler_default,i2c, &i2c->intr_handle);
940+
} else {
941+
ret = esp_intr_alloc_intrstatus(ETS_I2C_EXT0_INTR_SOURCE, flags, (uint32_t)&i2c->dev->int_status.val, 0x1FFF, &i2c_isr_handler_default,i2c, &i2c->intr_handle);
943942
}
944943

945944
if(ret!=ESP_OK) {

0 commit comments

Comments
 (0)