CVS: libraries/include/mspgcc eventhandler.h, 1.2, 1.3

Chris Liechti <[email protected]> Mon, 24 Mar 2008 09:04:37 -0700
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/libraries/include/mspgcc
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv2440/include/mspgcc

Modified Files:
	eventhandler.h 
Log Message:
- provinde and alternate way to find event bits
- commandline lib fix


Index: eventhandler.h
===================================================================
RCS file: /cvsroot/mspgcc/libraries/include/mspgcc/eventhandler.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- eventhandler.h	5 Apr 2006 18:39:48 -0000	1.2
+++ eventhandler.h	24 Mar 2008 16:04:32 -0000	1.3
@@ -76,8 +76,12 @@
  *         {0} //sentinel, marks end of list
  *     };
  * 
- * It is recomended to make defines for each of these events, so that events
- * are lauched by their name. This makes it easier to refactor code later and
+ * There are two ways to find and lauch the events.
+ * - manually by defines
+ * - search at run-time
+ *
+ * Manually make defines for each of these events, so that events can be
+ * lauched by their name. This makes it easier to refactor code later and
  * keep them in sync with the "eventhandler_table".
  *
  *     #define EVENT_timer      EVENT00_bits
@@ -88,9 +92,26 @@
  *     wakeup interrupt(WDT_VECTOR) intervallTimer(void) {
  *         EVENTHANDLER_LAUNCH(EVENT_timer);
  *     }
+ *
+ * The second variant is to use ::eventhandler_find to determine the event
+ * bit at run-time:
+ *
+ *      EVENTHANDLER_LAUNCH(eventhandler_find(event_timer));
+ *
+ * The disatvantage is that it consumes time at run-time, however it eleminates
+ * the list of defines that has to be kept in sync and is thus less error
+ * prone.
  */
 typedef void (*EVENTHANDLER_TABLE)(void);
 
+/**
+ * Determine the event bit for the given function pointer.
+ * 
+ * @param event_function        Function pointer to a function that is registered
+ *                              in the ::eventhandler_table.
+ * @return event bit (value > 0) or 0 if function is not found in the table.
+ */
+unsigned short eventhandler_find(EVENTHANDLER_TABLE event_function);
 
 
 /**


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/