Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

C in a tabell

Altera_Forum
Honored Contributor II
1,697 Views

#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; 

 

 

 

0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
524 Views

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
0 Kudos
Altera_Forum
Honored Contributor II
524 Views

yes, no, 42, elephant

0 Kudos
Altera_Forum
Honored Contributor II
524 Views

indata from the keybord Leds Nr Light (7-0) 

 

 

 

 

 

 

 

 

0 no  

1 1 

2 2 

3-8 3-8 

9 all 10 no
0 Kudos
Reply