#ifdef DPORT_ACCESS_BENCHMARK
ccount_start[cpu_id] = XTHAL_GET_CCOUNT();
#endif
- BaseType_t intLvl=portENTER_CRITICAL_NESTED();
- oldInterruptLevel[cpu_id]=intLvl;
+ BaseType_t intLvl = portENTER_CRITICAL_NESTED();
if (dport_access_ref[cpu_id] == 0) {
- portENTER_CRITICAL_ISR(&g_dport_mux);
+ portENTER_CRITICAL_ISR(&g_dport_mux);
+
+ oldInterruptLevel[cpu_id]=intLvl;
dport_access_start[cpu_id] = 0;
dport_access_end[cpu_id] = 0;
}
dport_access_ref[cpu_id]++;
+
+ if (dport_access_ref[cpu_id] > 1) {
+ /* Interrupts are already disabled by the parent, we're nested here. */
+ portEXIT_CRITICAL_NESTED(intLvl);
+ }
#endif /* CONFIG_FREERTOS_UNICORE */
}
dport_access_end[cpu_id] = 1;
portEXIT_CRITICAL_ISR(&g_dport_mux);
+
+ portEXIT_CRITICAL_NESTED(oldInterruptLevel[cpu_id]);
}
-
- portEXIT_CRITICAL_NESTED(oldInterruptLevel[cpu_id]);
#ifdef DPORT_ACCESS_BENCHMARK
ccount_end[cpu_id] = XTHAL_GET_CCOUNT();