Disclaimer: The code and project was tested with the following versions of the sw:
- Xtensa Xplorer 9.0.20
- Xtensa OCD 15.03
- Core Configuration: hifi3z_lark_RI_2022_10
- Xtensa Build Tools: RI 2022_10
- Lark SDK 3.3.1
The following code snippet shows how to configure an interupt using the ADAU1860 SDK. For a full implementation please download the code attached.
The code also shows how to use the generated c-files from Lark Studio to load a FDSP program using the Hifi3z Core.
/*
* First is to configure the pin that want to be used as an interrupt source
*/
err = adi_lark_mp_set_pin_mode(&device, gpio_number, API_LARK_MP_MODE_IRQ_IN);
/*
* Now we configure it if we want active high/low/rising/falling edge
* and we configure the time debounce to avoid multiple signals
*/
err = adi_lark_int_set_mp_input_irq_mode(&device, IRQ1, 2); //0 = Active Low; 1 = Active High; 2 = Rising Edge; 3 = Falling Edge
LARK_ERROR_RETURN(err);
err = adi_lark_mp_set_irq_input_debounce(&device, API_LARK_MP_DEBOUNCE_5MS);
LARK_ERROR_RETURN(err);
/*
* The interrupts can be linked to 3 different channels MP_IRQ_IN 1, 2 or 3.
* In this case we are linking it with the IRQ1. Multiple pins can be linked
* to the same IRQ
*/
err = adi_lark_int_enable_mp_input_irq(&device, IRQ1, (1 << gpio_number), 1);
LARK_ERROR_RETURN(err);
/*
* Then we get the id of the interrupt.
*/
err = adi_lark_int_get_soc_irq_id(&device, API_LARK_SOC_IRQ_MP_IN_IRQ1, &button_irq_id);
LARK_ERROR_RETURN(err);
/*
* We clear the interrupt flag before enabling the interrupt
*/
err = adi_lark_int_clr_mp_input_irq(&device, IRQ1);
LARK_ERROR_RETURN(err);
/*
* Finally we enable the interrupt.
* the interrupt is linked with the handler button_irq_handler() that was defined before
*/
_xtos_set_interrupt_handler_arg(button_irq_id, button_irq_handler, NULL);
_xtos_interrupt_enable(button_irq_id);