Attach interrupt to I2S clock

michikite
Posts: 16
Joined: Thu Oct 22, 2020 1:35 am

Attach interrupt to I2S clock

Postby michikite » Fri May 21, 2021 2:17 am

Is it possible to attach an interrupt to the i2s ws clock?
I tried the below, but it never gets called.

Code: Select all

void IRAM_ATTR test_isr(void *arg)
{
    printf("TEST");
}

#define SAMPLE_RATE 8000
#define MIC_SAMPLES_BUF 256
#define DMA_BUF_SPEAKER_CNT 5

void i2s_init_test(void)
{

  i2s_config_t i2s_config_TX = {
        .mode = I2S_MODE_MASTER | I2S_MODE_TX,
        .sample_rate = SAMPLE_RATE,
        .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT, 
        .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
        .communication_format = I2S_COMM_FORMAT_I2S,
        .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
        .dma_buf_count = DMA_BUF_SPEAKER_CNT,
        .dma_buf_len = MIC_SAMPLES_BUF,
        .use_apll = false,
        .tx_desc_auto_clear= true,  // new in V1.0.1
        .fixed_mclk=0
    };

  const i2s_pin_config_t pin_config_2 = {
    .bck_io_num = 13,  
    .ws_io_num = 12,   
    .data_out_num = 17,
    .data_in_num = -1   
  };

  i2s_driver_install(I2S_NUM_0, &i2s_config_TX, 0, NULL);

  i2s_zero_dma_buffer(I2S_NUM_0);
  i2s_set_pin(I2S_NUM_0, &pin_config_2);

  gpio_isr_handler_add(12, &test_isr, NULL);
  gpio_set_intr_type(12, GPIO_INTR_NEGEDGE); 
}

Who is online

Users browsing this forum: Majestic-12 [Bot] and 350 guests