From 8c39bfc93d6c68e5d64707916558b6316f611be2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 5 Mar 2008 15:56:12 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@216 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/AVR-ATmega128-GCC/Makefile | 1 + demos/AVR-ATmega128-GCC/main.c | 23 +++++++++++++++++++- readme.txt | 3 +++ test/test.c | 46 +++++++++++++++++++++------------------- 4 files changed, 50 insertions(+), 23 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 +#include +#include #include @@ -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(); @@ -45,13 +59,20 @@ 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; } diff --git a/readme.txt b/readme.txt index 11dbbac36..ff827878b 100644 --- a/readme.txt +++ b/readme.txt @@ -75,9 +75,12 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not complete yet, scheduled it, the change was required because the type names were the main concern of some users. - Implemented a serial driver in the AVR port. +- Modified the test suite to be compatible with 8 bit micros. - MSVC demo dropped, it is still possible to use the MinGW demo as simulator in Win32. - Fixed a minor error in sam7x_serial.h and lpc214x_serial.h. +- The kernel is *unchanged* compared to version 0.5.3 except for the type + names but the change is important enough to make this a recommended update. *** 0.5.5 *** - Added an AVRmega128 port. The previous AT90CANx port is still present but diff --git a/test/test.c b/test/test.c index 4a714931d..c01e6a89c 100644 --- a/test/test.c +++ b/test/test.c @@ -51,7 +51,7 @@ static void wait(void) { chThdWait(t5); } -static void printn(unsigned int n) { +static void printn(uint32_t n) { char buf[16], *p; if (!n) @@ -59,7 +59,7 @@ static void printn(unsigned int n) { else { p = buf; while (n) - *p++ = (n % 10) + '0', n /= 10; + *p++ = (n % 10) + '0', n /= 10; while (p > buf) chFDDPut(comp, *--p); } @@ -137,13 +137,13 @@ msg_t Thread4(void *p) { msg_t Thread6(void *p) { while (!chThdShouldTerminate()) - chMsgRelease(chMsgWait() + 1); + chMsgRelease(chMsgWait()); return 0; } msg_t Thread7(void *p) { - return (unsigned int)p + 1; + return (msg_t)NULL; } void testrdy1(void) { @@ -380,12 +380,13 @@ void testmsg1(void) { __attribute__((noinline)) unsigned int msg_loop_test(Thread *tp) { - unsigned int i; + uint32_t i; systime_t time = wait_tick() + 1000; i = 0; while (chSysGetTime() < time) { - i = chMsgSend(tp, i); + (void)chMsgSend(tp, 0); + i++; #if defined(WIN32) ChkIntSources(); #endif @@ -395,7 +396,7 @@ unsigned int msg_loop_test(Thread *tp) { __attribute__((noinline)) void precache(void) { - unsigned int i; + uint32_t i; println("\r\nPreparing for benchmarks\r\n"); t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread6, 0); @@ -406,7 +407,7 @@ void precache(void) { __attribute__((noinline)) void bench1(void) { - unsigned int i; + uint32_t i; println("*** Kernel Benchmark, context switch test #1 (optimal):"); t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread6, 0); @@ -422,7 +423,7 @@ void bench1(void) { __attribute__((noinline)) void bench2(void) { - unsigned int i; + uint32_t i; println("*** Kernel Benchmark, context switch test #2 (no threads in ready list):"); t1 = chThdCreate(chThdGetPriority()+1, 0, wsT1, sizeof(wsT1), Thread6, 0); @@ -439,7 +440,7 @@ chMsgSend(t1, 0); __attribute__((noinline)) void bench3(void) { - unsigned int i; + uint32_t i; println("*** Kernel Benchmark, context switch test #3 (04 threads in ready list):"); t1 = chThdCreate(chThdGetPriority()+1, 0, wsT1, sizeof(wsT1), Thread6, "A"); @@ -460,15 +461,16 @@ chMsgSend(t1, 0); __attribute__((noinline)) void bench4(void) { - unsigned int i; + uint32_t i; systime_t time; println("*** Kernel Benchmark, threads creation/termination:"); time = wait_tick() + 1000; i = 0; while (chSysGetTime() < time) { - t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread7, (void *)i); - i = chThdWait(t1); + t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread7, NULL); + chThdWait(t1); + i++; #if defined(WIN32) ChkIntSources(); #endif @@ -482,7 +484,7 @@ __attribute__((noinline)) void bench5(void) { static uint8_t ib[16]; static Queue iq; - unsigned int i; + uint32_t i; systime_t time; println("*** Kernel Benchmark, I/O Queues throughput:"); @@ -490,14 +492,14 @@ void bench5(void) { time = wait_tick() + 1000; i = 0; while (chSysGetTime() < time) { - chIQPutI(&iq, i >> 24); - chIQPutI(&iq, i >> 16); - chIQPutI(&iq, i >> 8); - chIQPutI(&iq, i); - i = chIQGet(&iq) << 24; - i |= chIQGet(&iq) << 16; - i |= chIQGet(&iq) << 8; - i |= chIQGet(&iq); + chIQPutI(&iq, 0); + chIQPutI(&iq, 1); + chIQPutI(&iq, 2); + chIQPutI(&iq, 3); + (void)chIQGet(&iq); + (void)chIQGet(&iq); + (void)chIQGet(&iq); + (void)chIQGet(&iq); i++; #if defined(WIN32) ChkIntSources(); -- cgit v1.2.3