I'm having some difficulty with the RTL interrupt support.
I am following the example in RTL-Level Interrupt Support for SHARC and Blackfin Processors. My code fragment looks like this:
adi_result = adi_int_InstallHandler (INTR_PINT2_BLOCK, NULL, /*callback param*/NULL, /*enable*/false);
printf ("adi_int_InstallHandler returned %ld\n", adi_result);
/* Call the RTL-level dispatcher register function to install the custom handler
** to replace the SSL-level dispatched handler.
*/adi_result = adi_rtl_register_dispatched_handler (INTR_PINT2_BLOCK, MyISR, (adi_dispatched_callback_t) NULL);
printf ("adi_rtl_register_dispatched_handler returned %ld\n", adi_result);
/* Enable INTR_PINT2_BLOCK */
adi_result = adi_int_EnableInt (INTR_PINT2_BLOCK, true);
printf ("adi_int_EnableInt returned %ld\n", adi_result);
/* PINT2 can sense activity on Port C and Port A (maps into A and B in Assignment).*/
/* See PINT register definitions in adi_gpio_data_bf70x.c */
/* Map top half of Port A (optos) onto PINT2 byte 1 - B1MAP */
/* Map bottom half of Port C (SW 1-1) onto PINT2 byte 0 B0MAP thereby only requiring 16-bit access */
*pREG_PINT2_ASSIGN = 0x00000100u; // Opto 2 and 1 (pA11, 10) in B1MAP[11..10], SW1-0 PC_07 in B0MAP[7]
*pREG_PINT2_EDGE_SET = 0x00000c80u; // All edge sensitive
// *pREG_PINT2_MSK_SET = 0x00000c80u; // enable all three interrupts
*pREG_PINT2_MSK_SET = 0x00000080u; // enable pin interrupt for switch 0 (PC_07) only for test
I want to register the interrupt for Pin Interrupt block 2 (PINT2) but adi_rtl_register_dispatched_handler() returns -1.
I assume that it's because INTR_PINT2_BLOCK (== 22 decimal) is not a valid value for the parameter 'iid'.
The help says:
adi_int_InstallHandler
iid - Interrupt ID. For system interrupts this is the system interrupt ID (also referred to as peripheral interrupt ID in the Hardware Reference manuals). This is a unique number to identify a particular interrupt. Refer to the Hardware Reference manual for your processor to find the number for a specific interrupt
According the the hardware reference manual for BF706, the interrupt number for PINT2_BLOCK is 22 (table 8-2, p226). It is accepted as a valid 'iid' by both adi_int_InstallHandler() and adi_int_EnableInt() but not by adi_rtl_register_dispatched_handler().
Why not? Or... what is the correct interrupt ID for PINT2?
Many thanks.