Altera_Forum
Honored Contributor
16 years agoNIOS-II Software Writing
I have write the Nios-II Code (Below) with the help of ready made examples.
please someone clarify the bold underline portion of the code what acutely they are doing.or from where i can get the help related to such type of keywords? #include <stdio.h> #include"system.h" #include"altera_avalon_pio_regs.h" static alt_u8 count; #define ESC 27 #define ESC_TOP_LEFT "[1;0H" #define ESC_COL2_INDENT5 "[2;5H" #define ESC_COL1_INDENT1 "[1;1H" #define ESC_COL1_INDENT5 "[1;5H" #define ESC_COL2_INDENT1 "[2;1H" #define ESC_COL2_INDENT5 "[2;5H" #define ESC_COL2_INDENT10 "[2;10H" #define ESC_COL2_INDENT14 "[2;14H" #define ESC_CLEAR "K" #ifdef lcd_display_base staticvoid lcd_init( FILE *lcd ) { fprintf(lcd, "%c%s Video Coding ", ESC, ESC_TOP_LEFT); #endif staticvoid initial_message() { printf("* Hello from Nios II! *\n"); } #ifdef seven_seg_pio_base staticvoid sevenseg_set_hex(int hex) { static alt_u8 segments[16] = { 0x81, 0xCF, 0x92, 0x86, 0xCC, 0xA4, 0xA0, 0x8F, 0x80, 0x84, 0x88, 0xE0, 0xF2, 0xC2, 0xB0, 0xB8 }; unsignedint data = segments[hex & 15] | (segments[(hex >> 4) & 15] << 8); iowr_altera_avalon_pio_data(seven_seg_pio_base, data); } #endif staticvoid count_sevenseg() { #ifdef seven_seg_pio_base sevenseg_set_hex(count); #endif } staticvoid count_lcd( void* arg ) { #ifdef lcd_display_name FILE *lcd = (FILE*) arg; fprintf(lcd, "%c%s 0x%x\n", ESC, ESC_COL2_INDENT10, count); #endif } int main() { FILE * lcd; int delay; #ifdef lcd_display_name lcd = fopen("/dev/lcd_display", "w"); #endif #ifdef lcd_display_name lcd_init( lcd ); #endif initial_message(); while(1) { usleep(100000); iowr_altera_avalon_pio_data(led_pio_base, count & 0x01); delay = 0; while(delay < 20000) { delay++; } count_sevenseg(); count_lcd(lcd); count++; } fclose(lcd); return 0; }