- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
#include
<stdio.h> #include
"altera_avalon_pio_regs.h" #include
"system.h" int
main() { int
rx_char; char
line[100]; #define
PERIPH_SYS_LEDS_PIO_BASE PIO_0_BASE #ifdef
NEEK_ID_NAME #define
PATTERN1 0x02 #define
PATTERN2 0x03 // clears LEDs #define
PATTERN3 0x03 // clears LEDs #define
PATTERN4 0x01 #define
NULL_PATTERN 0x03 // clears LEDs #else #define
PATTERN1 0x03 #define
PATTERN2 0x0C #define
PATTERN3 0x30 #define
PATTERN4 0xC0 #define
NULL_PATTERN 0x00 // clears LEDs #endif IOWR_ALTERA_AVALON_PIO_DATA(PERIPH_SYS_LEDS_PIO_BASE,NULL_PATTERN); // Clear LEDs // Print the message to STDOUT... printf
("This is Lab1b for the nios II Software Development class\n\n"); #ifdef
NEEK_ID_NAME printf( "\nPlease choose an LED pattern: Press 1 or 4\n"); printf( "Note: Only LEDs 1 and 4 are connected on NEEK Board!\n"); #else printf
("\nPlease choose an LED pattern: Press 1 to 4\n"); #endif while
(1) { printf
("\nType Value Now (followed by Enter):"); fgets
(line, sizeof(line),stdin); sscanf
(line,"%d",&rx_char); switch
(rx_char) { case
4: printf
("\nLED Pattern 4\n"); IOWR_ALTERA_AVALON_PIO_DATA(PERIPH_SYS_LEDS_PIO_BASE,PATTERN4); break
; case
3: printf
("\nLED Pattern 3\n"); IOWR_ALTERA_AVALON_PIO_DATA(PERIPH_SYS_LEDS_PIO_BASE,PATTERN3); break
; case
2: printf
("\nLED Pattern 2\n"); IOWR_ALTERA_AVALON_PIO_DATA(PERIPH_SYS_LEDS_PIO_BASE,PATTERN2); break
; case
1: printf
("\nLED Pattern 1\n"); IOWR_ALTERA_AVALON_PIO_DATA(PERIPH_SYS_LEDS_PIO_BASE,PATTERN1); break
; default
: printf
("Please enter an integer value from 1 to 4\n"); break
; } } return
0; }
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
indata from keyboard
leds nr light[7..0] 0 no 1 1 2 2 3-8 3-8 9 alla 10 - no can someone help me- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes, no, 42, elephant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
indata from the keybord Leds Nr Light (7-0)
0 no 1 1 2 2 3-8 3-8 9 all 10 no
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page