Example #1
0
/** @Function Description:  This function registers an interrupt handler. 
  * If the function is succesful, then the requested interrupt will be enabled
  * upon return. Registering a NULL handler will disable the interrupt.
  *
  * @API Type:              External
  * @param ic_id            Interrupt controller ID
  * @param irq              IRQ ID number
  * @param isr              Pointer to interrupt service routine
  * @param isr_context      Opaque pointer passed to ISR
  * @param flags            
  * @return                 0 if successful, else error (-1)
  */
int alt_iic_isr_register(alt_u32 ic_id, alt_u32 irq, alt_isr_func isr, 
  void *isr_context, void *flags)
{
  int rc = -EINVAL;  
  int id = irq;             /* IRQ interpreted as the interrupt ID. */
  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 = isr;
    alt_irq[id].context = isr_context;

    rc = (isr) ? alt_ic_irq_enable(ic_id, id) : alt_ic_irq_disable(ic_id, id);

    alt_irq_enable_all(status);
  }

  return rc; 
}
Example #2
0
void InitUart()
{
	void* context_uart0_ptr = (void*) &context_uart0;
	InitUart1(UART_0_NEW_BAUD);

	alt_ic_isr_register(UART_0_IRQ_INTERRUPT_CONTROLLER_ID, UART_0_IRQ, IsrUart1, context_uart0_ptr, 0x0); // install UART1 ISR
	alt_ic_irq_enable (UART_0_IRQ_INTERRUPT_CONTROLLER_ID, UART_0_IRQ);
}
Example #3
0
int main()
{
	initTimer(1); //1Hz
	//registra la interrupcion y ata a la funcion timer_isr
	alt_ic_isr_register(TIMER_ECE10243UPB2016_0_IRQ_INTERRUPT_CONTROLLER_ID,TIMER_ECE10243UPB2016_0_IRQ,timer_isr,(void*)NULL, 0);
	alt_ic_irq_enable (TIMER_ECE10243UPB2016_0_IRQ_INTERRUPT_CONTROLLER_ID,TIMER_ECE10243UPB2016_0_IRQ);
	while(1){

	}

  return 0;
}
Example #4
0
// Init interrupt
void n2h_isr_init(N2H_isr_fifo* n2h_isr_fifo)
{
  // Register N2H2 ISR
  if(alt_ic_isr_register(N2H2_CHAN_IRQ_INTERRUPT_CONTROLLER_ID,
			 N2H2_CHAN_IRQ, n2h2_isr, (void*)n2h_isr_fifo, 0) 
     != 0)
    {
      printf("CPU0: registering n2h2_isr failed!\n");
    }
  // Enable interrupt on CPU side     
  if(alt_ic_irq_enable(N2H2_CHAN_IRQ_INTERRUPT_CONTROLLER_ID,
		       N2H2_CHAN_IRQ) != 0)
    {
      printf("CPU0: enabling n2h2 interrupt failed!\n");
    }
  // Enable interrupts on N2H2 side
  IOWR(N2H2_CHAN_BASE, 4, (2 | (IORD(N2H2_CHAN_BASE,4))));
}