You can chat about native SDK questions and issues here.

User avatar
By 2ni
#74101 I'm trying to work with a timer and wait for it to trigger. Tirggering works so far, I could test that. But how can I wait for the interrupt to complete? Or is there a better method to do that?

My code looks as follows:
Code: Select allvolatile int tmr_done;
static os_timer_t tmr;

void tmrfc(void *arg) {
  ETS_GPIO_INTR_DISABLE();

  tmr_done = 1;
  //*((int *)arg) = 1;
  printf("tmr triggered!\n\r");

  ETS_GPIO_INTR_ENABLE();
}

float test() {
  tmr_done = 0;
  printf("waiting for tm...\n\r");
  os_timer_disarm(&tmr);
  os_timer_setfn(&tmr, (os_timer_func_t *)tmrfc, ready);
  os_timer_arm(&tmr, 1000, 0); // ms

  while(tmr_done != 1) {
      system_soft_wdt_feed();
      os_delay_us(10000); // avoid watchdog
  }

  printf("tmr was delivered!\n\r");
}