Digital Signal Processing Reference
In-Depth Information
#include "rpds_de_test.h"
int main( void ) {
volatile int function = 0;
int ret_val;
while(1) {
switch( function ) {
case 0x1: /* Test the LCD display */
ret_val = test_lcd();
break;
case 0x2: /* Test the SRAM */
ret_val = test_sram();
break;
case 0x4: /* Test the Flash memory */
ret_val = test_flash();
break;
case 0x8: /* Test the SDRAM */
ret_val = test_sdram();
break;
default: /* Do nothing */
break;
}
function = 0;
usleep( 50000 ); /* Wait 50 ms */
}
return(0);
}
Figure 16.11 This is the beginning of your C program's main source file.
Create your program's main C source file by selecting the rpds_de_test item in
the Nios II C/C++ Projects pane. Choose File New File . When the dialog
box appears, enter rpds_de_test.c for the File name and click Finish to
continue.
Start your program by including the rpds_de_test.h header file and typing the
code shown in Figure 16.11.
16.10 Handling Interrupts
Inputs can be evaluated using two methods—polling and interrupts. To poll an
input, your code can periodically check the value of the input device and
determine if the value has changed. If a change has occurred, then the
appropriate action should be taken to evaluate the input. An interrupt-driven
input, however, works differently. When the value of the input changes, an
interrupt signal is activated and the processor is alerted. The processor
immediately performs a jump into a section of code known as the interrupt
handler. This code determines which interrupt has occurred (most processors
support multiple interrupt signals) and calls the appropriate interrupt service
Search WWH ::




Custom Search