{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

P2-1 - file...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Spring 2007 Embedded Systems Programming Project 2-1 Simple Devices 1. Download from examples page Basic PIO devices and run. 2. In the NIOS IDE (eclipse) create a folder “dev” and create the following files with the following prototypes. You will need to supply the code for the prototypes. dev/switches.c dev/switches.h dev/buttons.c dev/buttons.h dev/redleds.c dev/redleds.h dev/greenleds.c dev/greenleds.h unsigned int switches_get ( void ); unsigned int buttons_get ( void ); void redleds_set ( unsigned int val); unsigned int redleds_get ( void ); void greenleds_set ( unsigned int val); unsigned int greenleds_get ( void ); 3. When you have completed the device code the following should test the drivers.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: /* file: p2-1.c */ #include <stdio.h> #include "unistd.h" // for usleep #include "dev/buttons.h" #include "dev/switches.h" #include "dev/redleds.h" #include "dev/greenleds.h" int main (void) { int switches, buttons; printf("\n\rStarting p2_1 (ESP N2 V2)\n\r"); while (1) { switches = switches_get(); redleds_set ( switches ); buttons = buttons_get(); greenleds_set ( buttons ); usleep(100000); } return 0; } Note: Almost all of the Altera header files are removed from the top level module. The only header remaining is for usleep....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online