diff options
Diffstat (limited to 'demos/AVR-ATmega128-GCC/main.c')
-rw-r--r-- | demos/AVR-ATmega128-GCC/main.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/demos/AVR-ATmega128-GCC/main.c b/demos/AVR-ATmega128-GCC/main.c index 48b263f3c..29a19701b 100644 --- a/demos/AVR-ATmega128-GCC/main.c +++ b/demos/AVR-ATmega128-GCC/main.c @@ -18,6 +18,8 @@ */
#include <ch.h>
+#include <evtimer.h>
+#include <avr_serial.h>
#include <avr/io.h>
@@ -35,7 +37,19 @@ static msg_t Thread1(void *arg) { return 0;
}
+static void TimerHandler(eventid_t id) {
+ msg_t TestThread(void *p);
+
+ if (!(PORTA & PORTA_BUTTON1))
+ TestThread(&SER2);
+}
+
int main(int argc, char **argv) {
+ static EvTimer evt;
+ static evhandler_t handlers[1] = {
+ TimerHandler
+ };
+ static EventListener el0;
hwinit();
@@ -46,12 +60,19 @@ int main(int argc, char **argv) { chSysInit();
/*
+ * Event Timer initialization.
+ */
+ evtInit(&evt, 500); /* Initializes an event timer object. */
+ evtStart(&evt); /* Starts the event timer. */
+ chEvtRegister(&evt.et_es, &el0, 0); /* Registers on the timer event source. */
+
+ /*
* Starts the LED blinker thread.
*/
chThdCreate(NORMALPRIO, 0, waThread1, sizeof(waThread1), Thread1, NULL);
while(TRUE)
- chThdSleep(1000);
+ chEvtWait(ALL_EVENTS, handlers);
return 0;
}
|