portENTER_CRITICAL(&reasonSpinlock);
reason[xPortGetCoreID()]=0;
portEXIT_CRITICAL(&reasonSpinlock);
+ esp_err_t err;
if (xPortGetCoreID()==0) {
- esp_intr_alloc(ETS_FROM_CPU_INTR0_SOURCE, ESP_INTR_FLAG_IRAM, esp_crosscore_isr, (void*)&reason[xPortGetCoreID()], NULL);
+ err = esp_intr_alloc(ETS_FROM_CPU_INTR0_SOURCE, ESP_INTR_FLAG_IRAM, esp_crosscore_isr, (void*)&reason[xPortGetCoreID()], NULL);
} else {
- esp_intr_alloc(ETS_FROM_CPU_INTR1_SOURCE, ESP_INTR_FLAG_IRAM, esp_crosscore_isr, (void*)&reason[xPortGetCoreID()], NULL);
+ err = esp_intr_alloc(ETS_FROM_CPU_INTR1_SOURCE, ESP_INTR_FLAG_IRAM, esp_crosscore_isr, (void*)&reason[xPortGetCoreID()], NULL);
}
+ assert(err == ESP_OK);
}
void esp_crosscore_int_send_yield(int coreId) {
*
* The interrupt will always be allocated on the core that runs this function.
*
+ * If ESP_INTR_FLAG_IRAM flag is used, and handler address is not in IRAM or
+ * RTC_FAST_MEM, then ESP_ERR_INVALID_ARG is returned.
+ *
* @param source The interrupt source. One of the ETS_*_INTR_SOURCE interrupt mux
* sources, as defined in soc/soc.h, or one of the internal
* ETS_INTERNAL_*_INTR_SOURCE sources as defined in this header.
}
#endif
-#endif
\ No newline at end of file
+#endif
if ((flags&ESP_INTR_FLAG_SHARED) && (!handler || source<0)) return ESP_ERR_INVALID_ARG;
//Statusreg should have a mask
if (intrstatusreg && !intrstatusmask) return ESP_ERR_INVALID_ARG;
+ //If the ISR is marked to be IRAM-resident, the handler must not be in the cached region
+ if ((flags&ESP_INTR_FLAG_IRAM) &&
+ (ptrdiff_t) handler >= 0x400C0000 &&
+ (ptrdiff_t) handler < 0x50000000 ) {
+ return ESP_ERR_INVALID_ARG;
+ }
//Default to prio 1 for shared interrupts. Default to prio 1, 2 or 3 for non-shared interrupts.
if ((flags&ESP_INTR_FLAG_LEVELMASK)==0) {
{
timer_test(ESP_INTR_FLAG_SHARED);
}
+
+TEST_CASE("Can allocate IRAM int only with an IRAM handler", "[esp32]")
+{
+ void dummy(void* arg)
+ {
+ }
+ IRAM_ATTR void dummy_iram(void* arg)
+ {
+ }
+ RTC_IRAM_ATTR void dummy_rtc(void* arg)
+ {
+ }
+ intr_handle_t ih;
+ esp_err_t err = esp_intr_alloc(ETS_INTERNAL_PROFILING_INTR_SOURCE,
+ ESP_INTR_FLAG_IRAM, &dummy, NULL, &ih);
+ TEST_ASSERT_EQUAL_INT(ESP_ERR_INVALID_ARG, err);
+ err = esp_intr_alloc(ETS_INTERNAL_PROFILING_INTR_SOURCE,
+ ESP_INTR_FLAG_IRAM, &dummy_iram, NULL, &ih);
+ TEST_ESP_OK(err);
+ err = esp_intr_free(ih);
+ TEST_ESP_OK(err);
+ err = esp_intr_alloc(ETS_INTERNAL_PROFILING_INTR_SOURCE,
+ ESP_INTR_FLAG_IRAM, &dummy_rtc, NULL, &ih);
+ TEST_ESP_OK(err);
+ err = esp_intr_free(ih);
+ TEST_ESP_OK(err);
+}