Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * "Hello World" example.
- *
- * This example prints 'Hello from Nios II' to the STDOUT stream. It runs on
- * the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example
- * designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT
- * device in your system's hardware.
- * The memory footprint of this hosted application is ~69 kbytes by default
- * using the standard reference design.
- *
- * For a reduced footprint version of this template, and an explanation of how
- * to reduce the memory footprint for a given application, see the
- * "small_hello_world" template.
- *
- */
- #include <stdio.h>
- #include <io.h>
- #include <system.h>
- #include "alt_types.h"
- #include "altera_avalon_pio_regs.h"
- #include "sys/alt_irq.h"
- //#include "sys/alt_timestamp.h"
- #include <unistd.h>
- #include "definition.h"
- struct interrupt_data
- {
- volatile int * leds_addr;
- volatile int * hex_addr;
- volatile int * sw_addr;
- };
- static void handle_sliders_interrupt(struct interrupt_data * data)
- {
- int sw = IORD(data->sw_addr,0);
- IOWR(data->leds_addr,0,sw);
- }
- int main()
- {
- volatile int *sliders = (int*) SW_SLIDERS_BASE;
- volatile int *leds = (int*) LEDS_BASE;
- struct interrupt_data data;
- data.leds_addr = leds;
- data.sw_addr = sliders;
- IOWR_ALTERA_AVALON_PIO_IRQ_MASK(SW_SLIDERS_BASE,0xf);
- alt_ic_isr_register(SW_SLIDERS_IRQ_INTERRUPT_CONTROLLER_ID, SW_SLIDERS_IRQ ,handle_sliders_interrupt,&data, 0x0);
- alt_ic_irq_enable(SW_SLIDERS_IRQ_INTERRUPT_CONTROLLER_ID, SW_SLIDERS_IRQ);
- printf("Hello from Nios II!\n");
- while(1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement