Skip to content

Instantly share code, notes, and snippets.

@zarya
Created October 3, 2014 13:28
Show Gist options
  • Save zarya/5557f724005ae8d4a1eb to your computer and use it in GitHub Desktop.
Save zarya/5557f724005ae8d4a1eb to your computer and use it in GitHub Desktop.
static os_timer_t some_timer;
void some_timerfunc(void *arg)
{
uart0_sendStr("Key press\r\n");
os_timer_disarm(&some_timer);
//enable interrupt
gpio_pin_intr_state_set(GPIO_ID_PIN(0), GPIO_PIN_INTR_NEGEDGE);
}
LOCAL void
key_intr_handler(int8_t key)
{
uint32 gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
//disable interrupt
gpio_pin_intr_state_set(GPIO_ID_PIN(0), GPIO_PIN_INTR_DISABLE);
os_timer_setfn(&some_timer, (os_timer_func_t *)some_timerfunc, NULL);
os_timer_arm(&some_timer, 50, 1);
//clear interrupt status
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status & BIT(0));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment