Forum Discussion
Altera_Forum
Honored Contributor
17 years agouCLinux
Hi everyone I really need some help! I try to install uClinux on my development board from Altera (it is a DE1 development board). I do not want to use the design files but my own system. So I bui...
Altera_Forum
Honored Contributor
17 years agoAgain thank you parrrado
I have another question. I made a program to handle the interrupts when I worked without µClinux in Nios IDE. Do I have to made modifications so that µClinux can read this program and do what I want my nios to do? Here is my program:# include "alt_types.h"# include "altera_avalon_pio_regs.h"# include "sys/alt_irq.h"# include "system.h"# include <stdio.h># include <unistd.h> volatile int edge_capture; # ifdef GPIO_A0_BASE# ifdef SORTIE_GPIO_1_BASE static void handle_button_interrupts(void* context, alt_u32 id) { /* Cast context to edge_capture's type. It is important that this be * declared volatile to avoid unwanted compiler optimization. */ volatile int *edge_capture_ptr = (volatile int*) context; /* Store the value in the PIO's edge capture register in *context. */ *edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(GPIO_A0_BASE); IOWR_ALTERA_AVALON_PIO_DATA(SORTIE_GPIO_1_BASE,1); /* Reset the PIO's edge capture register. */ IOWR_ALTERA_AVALON_PIO_EDGE_CAP(GPIO_A0_BASE, 0); IORD_ALTERA_AVALON_PIO_EDGE_CAP(GPIO_A0_BASE); //An extra read call to clear of delay through the bridge IOWR_ALTERA_AVALON_PIO_DATA(SORTIE_GPIO_1_BASE,0); } /* Initialize the GPIO_INPUT. */ static void init_GPIO_A0() { /* Recast the edge_capture pointer to match the alt_irq_register() function * prototype. */ void* edge_capture_ptr = (void*) &edge_capture; /* Enable the PIO interrupt. */ IOWR_ALTERA_AVALON_PIO_IRQ_MASK(GPIO_A0_BASE, 0xf); /* Reset the edge capture register. */ IOWR_ALTERA_AVALON_PIO_EDGE_CAP(GPIO_A0_BASE, 0x0); /* Register the interrupt handler. */ alt_irq_register( GPIO_A0_IRQ, edge_capture_ptr, handle_button_interrupts ); }# endif# endif int main(void) { # ifdef GPIO_A0_BASE init_GPIO_A0(); # endif while(1) { if (edge_capture!=0) { # ifdef LED_R_BASE IOWR_ALTERA_AVALON_PIO_DATA(LED_R_BASE,1); usleep(10); IOWR_ALTERA_AVALON_PIO_DATA(LED_R_BASE,0); # endif edge_capture=0; } } return 0; }