diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-03-05 15:56:12 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-03-05 15:56:12 +0000 |
commit | 8c39bfc93d6c68e5d64707916558b6316f611be2 (patch) | |
tree | 8729960805d80d3b11a6384f68a809a90a5a2d92 /demos | |
parent | 5e64a9fec2e17d008b9488faa027d2beaa130a88 (diff) | |
download | ChibiOS-8c39bfc93d6c68e5d64707916558b6316f611be2.tar.gz ChibiOS-8c39bfc93d6c68e5d64707916558b6316f611be2.tar.bz2 ChibiOS-8c39bfc93d6c68e5d64707916558b6316f611be2.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@216 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos')
-rw-r--r-- | demos/AVR-ATmega128-GCC/Makefile | 1 | ||||
-rw-r--r-- | demos/AVR-ATmega128-GCC/main.c | 23 |
2 files changed, 23 insertions, 1 deletions
diff --git a/demos/AVR-ATmega128-GCC/Makefile b/demos/AVR-ATmega128-GCC/Makefile index 66cc846c7..e2b5dd8cc 100644 --- a/demos/AVR-ATmega128-GCC/Makefile +++ b/demos/AVR-ATmega128-GCC/Makefile @@ -86,6 +86,7 @@ SRC = ../../ports/AVR/chcore.c ../../ports/AVR/avr_serial.c \ ../../src/chevents.c ../../src/chmsg.c ../../src/chsleep.c ../../src/chqueues.c \
../../src/chserial.c \
../../src/lib/evtimer.c \
+ ../../test/test.c \
board.c main.c
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;
}
|