git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@216 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2008-03-05 15:56:12 +00:00
parent 5e64a9fec2
commit 8c39bfc93d
4 changed files with 50 additions and 23 deletions

View File

@ -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/chevents.c ../../src/chmsg.c ../../src/chsleep.c ../../src/chqueues.c \
../../src/chserial.c \ ../../src/chserial.c \
../../src/lib/evtimer.c \ ../../src/lib/evtimer.c \
../../test/test.c \
board.c main.c board.c main.c

View File

@ -18,6 +18,8 @@
*/ */
#include <ch.h> #include <ch.h>
#include <evtimer.h>
#include <avr_serial.h>
#include <avr/io.h> #include <avr/io.h>
@ -35,7 +37,19 @@ static msg_t Thread1(void *arg) {
return 0; 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) { int main(int argc, char **argv) {
static EvTimer evt;
static evhandler_t handlers[1] = {
TimerHandler
};
static EventListener el0;
hwinit(); hwinit();
@ -45,13 +59,20 @@ int main(int argc, char **argv) {
*/ */
chSysInit(); 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. * Starts the LED blinker thread.
*/ */
chThdCreate(NORMALPRIO, 0, waThread1, sizeof(waThread1), Thread1, NULL); chThdCreate(NORMALPRIO, 0, waThread1, sizeof(waThread1), Thread1, NULL);
while(TRUE) while(TRUE)
chThdSleep(1000); chEvtWait(ALL_EVENTS, handlers);
return 0; return 0;
} }

View File

@ -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 it, the change was required because the type names were the main concern of
some users. some users.
- Implemented a serial driver in the AVR port. - 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 - MSVC demo dropped, it is still possible to use the MinGW demo as simulator
in Win32. in Win32.
- Fixed a minor error in sam7x_serial.h and lpc214x_serial.h. - 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 *** *** 0.5.5 ***
- Added an AVRmega128 port. The previous AT90CANx port is still present but - Added an AVRmega128 port. The previous AT90CANx port is still present but

View File

@ -51,7 +51,7 @@ static void wait(void) {
chThdWait(t5); chThdWait(t5);
} }
static void printn(unsigned int n) { static void printn(uint32_t n) {
char buf[16], *p; char buf[16], *p;
if (!n) if (!n)
@ -59,7 +59,7 @@ static void printn(unsigned int n) {
else { else {
p = buf; p = buf;
while (n) while (n)
*p++ = (n % 10) + '0', n /= 10; *p++ = (n % 10) + '0', n /= 10;
while (p > buf) while (p > buf)
chFDDPut(comp, *--p); chFDDPut(comp, *--p);
} }
@ -137,13 +137,13 @@ msg_t Thread4(void *p) {
msg_t Thread6(void *p) { msg_t Thread6(void *p) {
while (!chThdShouldTerminate()) while (!chThdShouldTerminate())
chMsgRelease(chMsgWait() + 1); chMsgRelease(chMsgWait());
return 0; return 0;
} }
msg_t Thread7(void *p) { msg_t Thread7(void *p) {
return (unsigned int)p + 1; return (msg_t)NULL;
} }
void testrdy1(void) { void testrdy1(void) {
@ -380,12 +380,13 @@ void testmsg1(void) {
__attribute__((noinline)) __attribute__((noinline))
unsigned int msg_loop_test(Thread *tp) { unsigned int msg_loop_test(Thread *tp) {
unsigned int i; uint32_t i;
systime_t time = wait_tick() + 1000; systime_t time = wait_tick() + 1000;
i = 0; i = 0;
while (chSysGetTime() < time) { while (chSysGetTime() < time) {
i = chMsgSend(tp, i); (void)chMsgSend(tp, 0);
i++;
#if defined(WIN32) #if defined(WIN32)
ChkIntSources(); ChkIntSources();
#endif #endif
@ -395,7 +396,7 @@ unsigned int msg_loop_test(Thread *tp) {
__attribute__((noinline)) __attribute__((noinline))
void precache(void) { void precache(void) {
unsigned int i; uint32_t i;
println("\r\nPreparing for benchmarks\r\n"); println("\r\nPreparing for benchmarks\r\n");
t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread6, 0); t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread6, 0);
@ -406,7 +407,7 @@ void precache(void) {
__attribute__((noinline)) __attribute__((noinline))
void bench1(void) { void bench1(void) {
unsigned int i; uint32_t i;
println("*** Kernel Benchmark, context switch test #1 (optimal):"); println("*** Kernel Benchmark, context switch test #1 (optimal):");
t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread6, 0); t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread6, 0);
@ -422,7 +423,7 @@ void bench1(void) {
__attribute__((noinline)) __attribute__((noinline))
void bench2(void) { void bench2(void) {
unsigned int i; uint32_t i;
println("*** Kernel Benchmark, context switch test #2 (no threads in ready list):"); println("*** Kernel Benchmark, context switch test #2 (no threads in ready list):");
t1 = chThdCreate(chThdGetPriority()+1, 0, wsT1, sizeof(wsT1), Thread6, 0); t1 = chThdCreate(chThdGetPriority()+1, 0, wsT1, sizeof(wsT1), Thread6, 0);
@ -439,7 +440,7 @@ chMsgSend(t1, 0);
__attribute__((noinline)) __attribute__((noinline))
void bench3(void) { void bench3(void) {
unsigned int i; uint32_t i;
println("*** Kernel Benchmark, context switch test #3 (04 threads in ready list):"); println("*** Kernel Benchmark, context switch test #3 (04 threads in ready list):");
t1 = chThdCreate(chThdGetPriority()+1, 0, wsT1, sizeof(wsT1), Thread6, "A"); t1 = chThdCreate(chThdGetPriority()+1, 0, wsT1, sizeof(wsT1), Thread6, "A");
@ -460,15 +461,16 @@ chMsgSend(t1, 0);
__attribute__((noinline)) __attribute__((noinline))
void bench4(void) { void bench4(void) {
unsigned int i; uint32_t i;
systime_t time; systime_t time;
println("*** Kernel Benchmark, threads creation/termination:"); println("*** Kernel Benchmark, threads creation/termination:");
time = wait_tick() + 1000; time = wait_tick() + 1000;
i = 0; i = 0;
while (chSysGetTime() < time) { while (chSysGetTime() < time) {
t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread7, (void *)i); t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread7, NULL);
i = chThdWait(t1); chThdWait(t1);
i++;
#if defined(WIN32) #if defined(WIN32)
ChkIntSources(); ChkIntSources();
#endif #endif
@ -482,7 +484,7 @@ __attribute__((noinline))
void bench5(void) { void bench5(void) {
static uint8_t ib[16]; static uint8_t ib[16];
static Queue iq; static Queue iq;
unsigned int i; uint32_t i;
systime_t time; systime_t time;
println("*** Kernel Benchmark, I/O Queues throughput:"); println("*** Kernel Benchmark, I/O Queues throughput:");
@ -490,14 +492,14 @@ void bench5(void) {
time = wait_tick() + 1000; time = wait_tick() + 1000;
i = 0; i = 0;
while (chSysGetTime() < time) { while (chSysGetTime() < time) {
chIQPutI(&iq, i >> 24); chIQPutI(&iq, 0);
chIQPutI(&iq, i >> 16); chIQPutI(&iq, 1);
chIQPutI(&iq, i >> 8); chIQPutI(&iq, 2);
chIQPutI(&iq, i); chIQPutI(&iq, 3);
i = chIQGet(&iq) << 24; (void)chIQGet(&iq);
i |= chIQGet(&iq) << 16; (void)chIQGet(&iq);
i |= chIQGet(&iq) << 8; (void)chIQGet(&iq);
i |= chIQGet(&iq); (void)chIQGet(&iq);
i++; i++;
#if defined(WIN32) #if defined(WIN32)
ChkIntSources(); ChkIntSources();