alt_irq_register is Unable to return normally
alt_irq_register
hello everybody !
I look forward to your help !
The development environment : Quartus II 13.1 (64-bit);
Eclipse IDE for C/C++ Developers(Version: Indigo Service Release 2)
FPGA model :EP4CE75U19I7N
The following code:
int uart_init(void)
{
// printf("Hello from Nios II-3-1!\n");
// usleep(1000*1000);
alt_irq_register(DEVICECTRL_0_IRQ, NULL,Button_Irq_Handler); //1906 line
// usleep(1000*1000);
// printf("Hello from Nios II-3-2!\n");
// usleep(1000*1000);
set_tr_type(0); //End data transfer
printf("Hello from Nios II-3-3!\n");
usleep(1000*1000);
return 0;
}
calling alt_irq_register.c :
int alt_irq_register (alt_u32 id,
void* context,
alt_isr_func handler)
{
int rc = -EINVAL;
alt_irq_context status;
if (id < ALT_NIRQ)
{
/*
* interrupts are disabled while the handler tables are updated to ensure
* that an interrupt doesn't occur while the tables are in an inconsistant
* state.
*/
status = alt_irq_disable_all ();
alt_irq[id].handler = handler;
alt_irq[id].context = context;
rc = (handler) ? alt_irq_enable (id): alt_irq_disable (id); //95 line
alt_irq_enable_all(status);
}
return rc;
}
In alt_IRq_register.c, alt_irq_enable (ID) will be executed when the handle is true,
in line 1906 of Uart.c, call this function alt_irq_register(DEVICECTRL_0_IRQ, NULL,Button_Irq_Handler);
Start registering interrupt functions. According to the definition of this function parameter, the first parameter is IRQ, interrupt priority number,The second argument is null, never mind, and the third argument is the sentence returned by the interrupt function.
Finally stop at alt_irq_enable_all(status);
This function is then called as follows
static ALT_INLINE void ALT_ALWAYS_INLINE
alt_irq_enable_all (alt_irq_context context)
{
#if (NIOS2_NUM_OF_SHADOW_REG_SETS > 0) || (defined NIOS2_EIC_PRESENT) || \
(defined NIOS2_MMU_PRESENT) || (defined NIOS2_MPU_PRESENT)
alt_irq_context status;
NIOS2_READ_STATUS (status);
status &= ~NIOS2_STATUS_PIE_MSK;
status |= (context & NIOS2_STATUS_PIE_MSK);
NIOS2_WRITE_STATUS (status);
#else
NIOS2_WRITE_STATUS (context); // The debug program stops here
#endif
}
that's all.
Thanks in advance.