From da365c95e4460bda1f5b49a2e55ae144da1faf3f Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 16 Nov 2007 13:14:30 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@93 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-GCC/Makefile | 13 +++++---- demos/ARM7-LPC214x-GCC/Makefile.thumb | 11 ++++---- demos/ARM7-LPC214x-GCC/main.c | 53 +++++++++++++++++++++++++++++------ 3 files changed, 58 insertions(+), 19 deletions(-) (limited to 'demos') diff --git a/demos/ARM7-LPC214x-GCC/Makefile b/demos/ARM7-LPC214x-GCC/Makefile index eb9cf9bc7..b078b8f88 100644 --- a/demos/ARM7-LPC214x-GCC/Makefile +++ b/demos/ARM7-LPC214x-GCC/Makefile @@ -62,12 +62,15 @@ UDEFS = UADEFS = # List ARM-mode C source files here -ASRC = chcore.c main.c buzzer.c mmcsd.c ../../src/lib/evtimer.c ../../test/test.c \ - ../../ports/ARM7-LPC214x/GCC/vic.c ../../ports/ARM7-LPC214x/GCC/lpc214x_serial.c \ - ../../ports/ARM7-LPC214x/GCC/lpc214x_ssp.c \ +ASRC = chcore.c \ ../../src/chinit.c ../../src/chdebug.c ../../src/chlists.c ../../src/chdelta.c \ ../../src/chschd.c ../../src/chthreads.c ../../src/chsem.c ../../src/chevents.c \ - ../../src/chmsg.c ../../src/chsleep.c ../../src/chqueues.c ../../src/chserial.c + ../../src/chmsg.c ../../src/chsleep.c ../../src/chqueues.c ../../src/chserial.c \ + ../../ports/ARM7-LPC214x/GCC/vic.c ../../ports/ARM7-LPC214x/GCC/lpc214x_serial.c \ + ../../ports/ARM7-LPC214x/GCC/lpc214x_ssp.c \ + ../../src/lib/evtimer.c ../../test/test.c \ + buzzer.c mmcsd.c main.c + # List THUMB-mode C sources here # NOTE: If any module is compiled in thumb mode then -mthumb-interwork is @@ -99,7 +102,7 @@ TOPT = -mthumb -D THUMB # increases the code size. OPT = -O2 -ggdb -fomit-frame-pointer -fno-strict-aliasing #OPT += -ffixed-r7 -#OPT += -falign-functions=16 +OPT += -falign-functions=16 # Define warning options here WARN = -Wall -Wstrict-prototypes diff --git a/demos/ARM7-LPC214x-GCC/Makefile.thumb b/demos/ARM7-LPC214x-GCC/Makefile.thumb index 3840c1738..8c6147f15 100644 --- a/demos/ARM7-LPC214x-GCC/Makefile.thumb +++ b/demos/ARM7-LPC214x-GCC/Makefile.thumb @@ -67,12 +67,13 @@ ASRC = chcore.c # List THUMB-mode C sources here # NOTE: If any module is compiled in thumb mode then -mthumb-interwork is # enabled for all modules and that lowers performance. -TSRC = main.c buzzer.c mmcsd.c ../../src/lib/evtimer.c ../../test/test.c \ +TSRC = ../../src/chinit.c ../../src/chdebug.c ../../src/chlists.c ../../src/chdelta.c \ + ../../src/chschd.c ../../src/chthreads.c ../../src/chsem.c ../../src/chevents.c \ + ../../src/chmsg.c ../../src/chsleep.c ../../src/chqueues.c ../../src/chserial.c \ ../../ports/ARM7-LPC214x/GCC/vic.c ../../ports/ARM7-LPC214x/GCC/lpc214x_serial.c \ ../../ports/ARM7-LPC214x/GCC/lpc214x_ssp.c \ - ../../src/chinit.c ../../src/chdebug.c ../../src/chlists.c ../../src/chdelta.c \ - ../../src/chschd.c ../../src/chthreads.c ../../src/chsem.c ../../src/chevents.c \ - ../../src/chmsg.c ../../src/chsleep.c ../../src/chqueues.c ../../src/chserial.c + ../../src/lib/evtimer.c ../../test/test.c \ + buzzer.c mmcsd.c main.c # List ASM source files here ASMSRC = crt0.s chcore2.s @@ -99,7 +100,7 @@ TOPT = -mthumb -D THUMB # increases the code size. OPT = -O2 -ggdb -fomit-frame-pointer -fno-strict-aliasing #OPT += -ffixed-r7 -#OPT += -falign-functions=16 +OPT += -falign-functions=16 # Define warning options here WARN = -Wall -Wstrict-prototypes diff --git a/demos/ARM7-LPC214x-GCC/main.c b/demos/ARM7-LPC214x-GCC/main.c index c9afab898..a889706e6 100644 --- a/demos/ARM7-LPC214x-GCC/main.c +++ b/demos/ARM7-LPC214x-GCC/main.c @@ -25,8 +25,13 @@ #include "buzzer.h" #include "evtimer.h" -static BYTE8 waThread1[UserStackSize(32)]; +static BYTE8 waIdleThread[UserStackSize(16)]; +static t_msg IdleThread(void *arg) { + + chSysPause(); +} +static BYTE8 waThread1[UserStackSize(32)]; static t_msg Thread1(void *arg) { while (TRUE) { @@ -43,7 +48,6 @@ static t_msg Thread1(void *arg) { } static BYTE8 waThread2[UserStackSize(32)]; - static t_msg Thread2(void *arg) { while (TRUE) { @@ -94,7 +98,7 @@ static void RemoveHandler(t_eventid id) { PlaySoundWait(1000, 100); } -static BYTE8 waThread3[UserStackSize(256)]; +/*static BYTE8 waThread3[UserStackSize(256)];*/ static EvTimer evt; static t_evhandler evhndl[] = { TimerHandler, @@ -102,7 +106,7 @@ static t_evhandler evhndl[] = { RemoveHandler }; -static t_msg Thread3(void *arg) { +/*static t_msg Thread3(void *arg) { struct EventListener el0, el1, el2; evtInit(&evt, 500); @@ -114,20 +118,51 @@ static t_msg Thread3(void *arg) { while (TRUE) chEvtWait(ALL_EVENTS, evhndl); return 0; -} +}*/ int main(int argc, char **argv) { + struct EventListener el0, el1, el2; + /* + * The main() function becomes a thread here, ChibiOS/RT goes live. + */ chSysInit(); + + /* + * This thread has the lowest priority in the system, its role is just to + * execute the chSysPause() and serve interrupts in its context. + * In ChibiOS/RT at least one thread in the system *must* execute + * chThdPause(), it can be done in a dedicated thread or in the main() + * function (that would never exit the call). + */ + chThdCreate(IDLEPRIO, 0, waIdleThread, sizeof(waIdleThread), IdleThread, NULL); + /* - * If a button is pressed during the reset then the blinking leds are not - * started in order to make accurate benchmarks. + * If a button is pressed during the reset then the blinking leds threads + * are not started in order to make accurate benchmarks. */ if ((IO0PIN & 0x00018000) == 0x00018000) { chThdCreate(NORMALPRIO, 0, waThread1, sizeof(waThread1), Thread1, NULL); chThdCreate(NORMALPRIO, 0, waThread2, sizeof(waThread2), Thread2, NULL); } - chThdCreate(NORMALPRIO, 0, waThread3, sizeof(waThread3), Thread3, NULL); - chSysPause(); + + /* + * Allows the other threads to run by lowering the priority, remember, + * the priority is set to the maximum in the \p chSysInit(). + */ + chThdSetPriority(NORMALPRIO); + + /* + * Normal main() activity, in this demo it server events incoming from + * various sources. + */ + evtInit(&evt, 500); /* Initializes an event timer object. */ + evtRegister(&evt, &el0, 0); /* Registers on the timer event source. */ + evtStart(&evt); /* Starts the event timer. */ + mmcStartPolling(); /* Starts the MMC connector polling. */ + chEvtRegister(&MMCInsertEventSource, &el1, 1); + chEvtRegister(&MMCRemoveEventSource, &el2, 2); + while (TRUE) /* Just serve events. */ + chEvtWait(ALL_EVENTS, evhndl); return 0; } -- cgit v1.2.3