P2-5 - } int main ( void ) { printf( "\n\rStarting...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Spring 2007 Embedded Systems Programming Project 2-5 Interrupts Happen 1. Download the btn_int.c (Button interrupts) routine. Study the process of an interrupt signaling to the main loop that a button has been pushed. Do you see any problems with this method? Look at bnt_int2.c (Alternate version) for another approach. Do they both suffer from the same problem? Any solutions? 2. Now modify the buttons.c and buttons.h to integrate the ISR and initialization code. 3. Supply code for the handle_buttons() function that demonstrates your chosen interface design. Again, this is the only code that should be in the top level module. /* file: p2_5.c */ #include <stdio.h> #include "sys_clock.h" #include "alive.h" #include "progress.h" #include "dev/buttons.h" void handle_buttons( void ) { // you will need to supply code for demonstration
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } int main ( void ) { printf( "\n\rStarting p2_5.c (ESP N2 V2)\n\r" ); if ( sys_clock_init() != 0 ) { printf ( "No system clock available\n" ); return 4; } buttons_init (); while (1) { // this is where we will eventually do some real work if ( buttons.val ) handle_buttons(); show_progress(); // make it look like we are doing something alive(); // show that we are still alive } return 0; } 4. This module is a very good example of when documentation is necessary. Since the provided code had no documentation the information that you gained from researching the data sheets is what should be included as documentation. Remember, documentation does not make bad code good. Style, function name, and variable names are important. Spring 2007 Embedded Systems Programming Project 2-5 Interrupts Happen...
View Full Document

This document was uploaded on 11/01/2011 for the course EE 492 at Boise State.

Page1 / 2

P2-5 - } int main ( void ) { printf( "\n\rStarting...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online