Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Simply blink a led with uCLinux

Hi i want to blink a led inside my linux, i can do it without problems using NIOS2-IDE but not inside Linux! What do i need to enable in makemenuconfig?

Thanks.

This is my program..

#include <stdio.h># include </home/aprado/LinuxFPGA/NOMMU/nios2-linux/uClinux-dist/linux-2.6.x/include/asm-nios2/nios2.h>
int main(void)
{
 printf("hello world\n");
while(1){
*na_led_green = 1;
};
}

the error i get

In file included from hello.c:2:
/home/aprado/LinuxFPGA/NOMMU/nios2-linux/uClinux-dist/linux-2.6.x/include/asm-nios2/nios2.h:82:28: asm/pio_struct.h: No such file or directory
hello.c: In function `main':
hello.c:7: error: `np_pio' undeclared (first use in this function)
hello.c:7: error: (Each undeclared identifier is reported only once
hello.c:7: error: for each function it appears in.)
hello.c:7: error: syntax error before ')' token

what is inside my ASM-NIOS2

$ ls
asm-offsets.h  nios2.h

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Problem solved

    
    # include <stdio.h># define led_green (char*) 0x00681080 // Base adress in SOPC Builder
    int main(void)
    {
      int tempo,i;
      printf("time to keep led on\n");
      scanf("%i",&tempo);
      for (i=0; i<tempo; i++)
      {
        *led_green='1';
        usleep(1000);
      }
      *led_green = 0;
      return 0;
    }
    

    my code