As for interrupts in Nios, interrupts are used when the 16c550 needs to be tested in a nios interrupt environment.
Hardware: Add Hardware Pio in Nios, but enable interrupt function. As shown in the following:
System is listed, the connection to PIO is not said. But be aware of two places: Edge type, IRQ type.
The next step is software design:
enable the corresponding interrupt, Iowr_altera_avalon_pio_irq_mask (Intrep_base, 0xff); that is, the mask function corresponds to each bit of the 1-bit enable.
Clear Interrupt flag: Iowr_altera_avalon_pio_edge_cap (Intrep_base, 0x00);
Interrupt Registration function:
Alt_ic_isr_register (intrep_irq_interrupt_controller_id, //defined in system.h
INTREP_IRQ,//defined in system.h
INTRP_ISR,//Interrupt Service sub-function
Isr_context,//null pointer void * Isr_context
0x0//reserved bit, but to write
);
Corresponding Interrupt Service sub-function:
void Intrp_isr (void) {
printf ("have enter the ISR \ n");
Iowr_altera_avalon_pio_edge_cap (Intrep_base, 0x00); Clear Mark Bit
。。。。。。。。。。。。。。
。。。。。。。。。。。。。。。
}
To this hardware and software, the design is complete. As long as the corresponding PIO, the condition of the interruption, in the Nios will respond to interrupts, into the interrupt service sub-function.