Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. /*
  2. * "Hello World" example.
  3. *
  4. * This example prints 'Hello from Nios II' to the STDOUT stream. It runs on
  5. * the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example
  6. * designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT
  7. * device in your system's hardware.
  8. * The memory footprint of this hosted application is ~69 kbytes by default
  9. * using the standard reference design.
  10. *
  11. * For a reduced footprint version of this template, and an explanation of how
  12. * to reduce the memory footprint for a given application, see the
  13. * "small_hello_world" template.
  14. *
  15. */
  16.  
  17. #include <stdio.h>
  18. #include <io.h>
  19. #include "definition.h"
  20. #include <system.h>
  21. #include <altera_avalon_mutex.h>
  22.  
  23. #define ZERO SEGA | SEGB | SEGC | SEGD |SEGE | SEGF
  24. #define ONE SEGB | SEGC
  25. #define TWO SEGA | SEGB | SEGG | SEGE | SEGD
  26. #define THREE SEGA | SEGB | SEGC | SEGD | SEGG
  27. #define FOUR SEGB | SEGC | SEGF | SEGG
  28. #define FIVE SEGG | SEGC | SEGA | SEGD | SEGF
  29. #define SIX SEGA | SEGC | SEGD | SEGE | SEGF | SEGG
  30. #define SEVEN SEGB | SEGC | SEGA
  31. #define EIGHT SEGB | SEGC | SEGA | SEGD | SEGE | SEGF | SEGG
  32. #define NINE SEGB | SEGC | SEGA | SEGD | SEGF | SEGG
  33. #define E SEGA | SEGD | SEGE | SEGF | SEGG
  34. #define R SEGE | SEGG
  35.  
  36. int main()
  37. {
  38. alt_mutex_dev* mutex = altera_avalon_mutex_open("/dev/mutex_0");
  39. int sw = 0;
  40. while(1){
  41. altera_avalon_mutex_lock(mutex, 1);
  42. sw = IORD(SHARED_MEMORY_BASE,0);
  43. printf("sw = %d\n", sw);
  44. altera_avalon_mutex_unlock(mutex);
  45. IOWR(LEDS_BASE, 0, sw);
  46. }
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement