gpio isr on both cpu question
Posted: Mon May 01, 2017 8:33 pm
Can I set two ISRs for gpios running on both CPUs simultaneously?
Code: Select all
static void IRAM_ATTR gpioIsr_appCpu(void* arg)
{
//Low latency needed here
uint32_t gpioIntStatusL = GPIO.acpu_int; // read status to get interrupt status for GPIO0-31
uint32_t gpioIntStatusH = GPIO.acpu_int1.intr; // read status1 to get interrupt status for GPIO32-39
if( shortCircuitDetectMask & gpioIntStatusH )
{
//reload timer and alarm
TIMERG1.hw_timer[0].load_high = 0;
TIMERG1.hw_timer[0].load_low = 0;
TIMERG1.hw_timer[0].reload = 1;
TIMERG1.hw_timer[0].alarm_high = 0;
TIMERG1.hw_timer[0].alarm_low = shortCircuitDetect_firstPulseWidthThresh_us;
//enable if pin is low (negative edge occurred), disable if high (positive edge occurred)
bool enable = !(shortCircuitDetectMask & GPIO.in1.val);
TIMERG1.hw_timer[0].config.alarm_en = enable;
TIMERG1.int_ena.t0 = enable;
TIMERG1.hw_timer[0].config.enable = enable;
}
GPIO.status_w1tc = gpioIntStatusL; // Clear intr for gpio0-gpio31
GPIO.status1_w1tc.intr_st = gpioIntStatusH; // Clear intr for gpio32-39
}
static void IRAM_ATTR gpioIsr_proCpu(void* arg)
{
uint32_t gpioIntStatusL = GPIO.pcpu_int; // read status to get interrupt status for GPIO0-31
uint32_t gpioIntStatusH = GPIO.pcpu_int1.intr; // read status1 to get interrupt status for GPIO32-39
if( (buttonsMaskL & gpioIntStatusL) || (buttonsMaskH & gpioIntStatusH) )
{
buttonPressed(true);
}
if( encoderMaskA & gpioIntStatusL )
{
encoderATriggered();
}
if( encoderMaskB & gpioIntStatusL )
{
encoderBTriggered();
}
if( rtcTickMask & gpioIntStatusL )
{
POST_EVENT(state_event_rtcTick);
}
GPIO.status_w1tc = gpioIntStatusL; // Clear intr for gpio0-gpio31
GPIO.status1_w1tc.intr_st = gpioIntStatusH; // Clear intr for gpio32-39
}
Code: Select all
gpio_isr_register(gpioIsr_proCpu, NULL, ESP_INTR_FLAG_LEVEL1, NULL)
gpio_isr_register(gpioIsr_appCpu, NULL, ESP_INTR_FLAG_LEVEL2, NULL)