diff --git a/main/esp32-sequencer.c b/main/esp32-sequencer.c index ca6dfca..640818d 100644 --- a/main/esp32-sequencer.c +++ b/main/esp32-sequencer.c @@ -27,6 +27,8 @@ #define GPIO_MUTATE_BTN (9) // Mutate Button In #define GPIO_TAP_TEMPO_BTN (10) // Tap Tempo Button In +gptimer_handle_t tap_tempo_timer = NULL; + static QueueHandle_t control_event_queue = NULL; /* Outputs */ @@ -109,6 +111,15 @@ static void controls_init(void) { gpio_set_intr_type(GPIO_TAP_TEMPO_BTN, GPIO_INTR_NEGEDGE); // Hook in handler for tap tempo button gpio_isr_handler_add(GPIO_TAP_TEMPO_BTN, gpio_isr_handler, (void *)GPIO_TAP_TEMPO_BTN); + + // Setup tap tempo timer + gptimer_config_t tap_tempo_timer_config = { + .clk_src = GPTIMER_CLK_SRC_DEFAULT, + .direction = GPTIMER_COUNT_UP, + .resolution_hz = 1 * 1000 * 1000 // 1MHz; 1 tick = 1 µs + }; + ESP_ERROR_CHECK(gptimer_new_timer(&tap_tempo_timer_config, &tap_tempo_timer)); + ESP_ERROR_CHECK(gptimer_enable(tap_tempo_timer)); } static void clk_cv_off_alarm_cb(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_data) {