diff --git a/demos/LPC214x-GCC/Makefile b/demos/LPC214x-GCC/Makefile index 7f75b31b2..8400d8f82 100644 --- a/demos/LPC214x-GCC/Makefile +++ b/demos/LPC214x-GCC/Makefile @@ -63,7 +63,7 @@ UADEFS = # List ARM-mode C source files here ASRC = chcore.c main.c buzzer.c \ - ../../ports/ARM7-LPC214x/GCC/lpc214x_serial.c \ + ../../test/test.c ../../ports/ARM7-LPC214x/GCC/lpc214x_serial.c \ ../../src/chinit.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 diff --git a/demos/LPC214x-GCC/main.c b/demos/LPC214x-GCC/main.c index c925671e9..0183b276b 100644 --- a/demos/LPC214x-GCC/main.c +++ b/demos/LPC214x-GCC/main.c @@ -53,15 +53,22 @@ static t_msg Thread2(void *arg) { return 0; } -static BYTE8 waThread3[UserStackSize(32)]; +static BYTE8 waThread3[UserStackSize(64)]; static t_msg Thread3(void *arg) { - + t_msg TestThread(void *p); + while (TRUE) { - if (!(IO0PIN & 0x00008000)) // Button 1 - PlaySound(1000, 100); - if (!(IO0PIN & 0x00010000)) // Button 2 - chFDDWrite(&COM1, (BYTE8 *)"Hello World!\r\n", 14); + if (!(IO0PIN & 0x00018000)) { + TestThread(&COM1); + PlaySound(500, 100); + } + else { + if (!(IO0PIN & 0x00008000)) // Button 1 + PlaySound(1000, 100); + if (!(IO0PIN & 0x00010000)) // Button 2 + chFDDWrite(&COM1, (BYTE8 *)"Hello World!\r\n", 14); + } chThdSleep(500); } return 0; diff --git a/demos/LPC214x-GCC/readme.txt b/demos/LPC214x-GCC/readme.txt index c39f179d2..f55f5b4c6 100644 --- a/demos/LPC214x-GCC/readme.txt +++ b/demos/LPC214x-GCC/readme.txt @@ -11,7 +11,8 @@ members of the LPC2000 family should be an easy task. The demo blinks the leds on the board by using multiple threads. By pressing the buttons on the board it is possible to activate the buzzer and send a -message over the serial ports. +message over the serial ports. Pressing both buttons activates the test +procedure on the serial port 1. See main.c for details. Buzzer.c contains an interesting device driver example that uses a physical timer for the waveform generation and a virtual timer for the sound duration. diff --git a/readme.txt b/readme.txt index e76cbe524..c9bf70540 100644 --- a/readme.txt +++ b/readme.txt @@ -2,19 +2,20 @@ *** Directories structure *** ***************************************************************************** -./readme.txt - This file. -./license.txt - GPL3 license file. -./src/ - ChibiOS/RT portable kernel source files. -./src/include/ - ChibiOS/RT include files. -./src/templates/ - ChibiOS/RT non portable source templates, new ports are - started by copying the templates into a new directory - under ./demos/. -./ports/ - Architecture/compiler specific portable files. -./demos/ - Demo programs for specific archtectures/boards. -./docs/Doxifile - Doxigen project file. -./docs/index.html - ChibiOS/RT documentation (after running doxigen). The - documentation is also available on the project web - page: http://chibios.sourceforge.net/ +./readme.txt - This file. +./license.txt - GPL3 license file. +./src/ - ChibiOS/RT portable kernel source files. +./src/include/ - ChibiOS/RT include files. +./src/templates/ - ChibiOS/RT non portable source templates, new ports + are started by copying the templates into a new + directory under ./demos/. +./ports/ - Architecture/compiler specific portable files. +./demos/ - Demo programs for specific archtectures/boards. +./test/ - Test code, used by some demos. +./docs/Doxifile - Doxigen project file. +./docs/html/index.html - ChibiOS/RT documentation (after running doxigen). + The documentation is also available on the project + web page: http://chibios.sourceforge.net/ Current ports under ./demos: @@ -33,8 +34,9 @@ LPC214x-GCC - ChibiOS/RT port for ARM7 LPC2148, the demo targets the ***************************************************************************** *** 0.3.1 *** -- Test program added to the MinGW and MSVS demos. Telnet the demo and type - "test" at the "ch>" prompt. The test performs integrity tests on the main +- Test program added to the demos. Telnet the MinGW and MSVS demos and type + "test" at the "ch>" prompt. On the LPC214x demo the test is activated by + pressing both the board. The test performs integrity tests on the main ChibiOS/RT functionalities. The test code is also a good example of APIs usage and ChibiOS/RT behavior. - Fixed bug in chEvtWaitTimeout(), the timeout code performed an useless diff --git a/test/test.c b/test/test.c index deed9a08c..4351e79a2 100644 --- a/test/test.c +++ b/test/test.c @@ -75,34 +75,6 @@ t_msg Thread3(void *p) { } t_msg Thread4(void *p) { - - chSemWait(&sem1); - chFDDPut(comp, *(BYTE8 *)p); - /* - * NOTE: chSemSignalWait() is not the same of chSemSignal()+chSemWait(). - * The former is performed atomically, try it. - */ - chSemSignalWait(&sem1, &sem2); -// chSemSignal(&sem1); -// chSemWait(&sem2); - chFDDPut(comp, *(BYTE8 *)p); - chSemSignal(&sem2); - return 0; -} - -t_msg Thread5(void *p) { - - chSemWait(&sem1); - chFDDPut(comp, *(BYTE8 *)p); - chSemRaisePrioSignalWait(&sem1, &sem2); -// chSemSignal(&sem1); -// chSemRaisePrioWait(&sem2); - chFDDPut(comp, *(BYTE8 *)p); - chSemLowerPrioSignal(&sem2); - return 0; -} - -t_msg Thread6(void *p) { t_msg msg; int i; @@ -114,7 +86,7 @@ t_msg Thread6(void *p) { return 0; } -t_msg Thread7(void *p) { +t_msg Thread5(void *p) { // NOTE, this thread does not serve messages this causes the client to // timeout. @@ -130,6 +102,10 @@ t_msg TestThread(void *p) { int i; comp = p; + println("*****************************"); + println("*** ChibiOS/RT test suite ***"); + println("*****************************"); + println(""); /* * Ready list ordering test. @@ -169,6 +145,7 @@ t_msg TestThread(void *p) { wait(); println(""); println("*** Semaphores, priority enqueuing test #1, you should read ABCDE:"); + chSemInit(&sem1, 0); t5 = chThdCreate(NORMALPRIO+1, 0, wsT5, sizeof(wsT5), Thread3, "E"); t4 = chThdCreate(NORMALPRIO+2, 0, wsT4, sizeof(wsT4), Thread3, "D"); t3 = chThdCreate(NORMALPRIO+3, 0, wsT3, sizeof(wsT3), Thread3, "C"); @@ -182,6 +159,7 @@ t_msg TestThread(void *p) { wait(); println(""); println("*** Semaphores, priority enqueuing test #2, you should read ABCDE:"); + chSemInit(&sem1, 0); t4 = chThdCreate(NORMALPRIO+2, 0, wsT4, sizeof(wsT4), Thread3, "D"); t5 = chThdCreate(NORMALPRIO+1, 0, wsT5, sizeof(wsT5), Thread3, "E"); t1 = chThdCreate(NORMALPRIO+5, 0, wsT1, sizeof(wsT1), Thread3, "A"); @@ -194,50 +172,6 @@ t_msg TestThread(void *p) { chSemLowerPrioSignal(&sem1); wait(); println(""); - println("*** Semaphores, atomicity test #1, you should read ABCDEABCDE:"); - chSemInit(&sem1, 0); - chSemInit(&sem2, 1); - t1 = chThdCreate(NORMALPRIO+1, 0, wsT1, sizeof(wsT1), Thread4, "A"); - t2 = chThdCreate(NORMALPRIO+2, 0, wsT2, sizeof(wsT2), Thread4, "B"); - t3 = chThdCreate(NORMALPRIO+3, 0, wsT3, sizeof(wsT3), Thread4, "C"); - t4 = chThdCreate(NORMALPRIO+4, 0, wsT4, sizeof(wsT4), Thread4, "D"); - t5 = chThdCreate(NORMALPRIO+5, 0, wsT5, sizeof(wsT5), Thread4, "E"); - chSemSignal(&sem1); - wait(); - println(""); - println("*** Semaphores, atomicity test #2, you should read ABCDEABCDE:"); - chSemInit(&sem1, 0); - chSemInit(&sem2, 1); - t1 = chThdCreate(NORMALPRIO+1, 0, wsT1, sizeof(wsT1), Thread4, "A"); - t2 = chThdCreate(NORMALPRIO+5, 0, wsT2, sizeof(wsT2), Thread4, "B"); - t3 = chThdCreate(NORMALPRIO+2, 0, wsT3, sizeof(wsT3), Thread4, "C"); - t4 = chThdCreate(NORMALPRIO+4, 0, wsT4, sizeof(wsT4), Thread4, "D"); - t5 = chThdCreate(NORMALPRIO+3, 0, wsT5, sizeof(wsT5), Thread4, "E"); - chSemSignal(&sem1); - wait(); - println(""); - println("*** Semaphores, atomicity test #3, you should read AABBCCDDEE:"); - chSemInit(&sem1, 0); - chSemInit(&sem2, 1); - t1 = chThdCreate(NORMALPRIO+1, 0, wsT1, sizeof(wsT1), Thread5, "A"); - t2 = chThdCreate(NORMALPRIO+2, 0, wsT2, sizeof(wsT2), Thread5, "B"); - t3 = chThdCreate(NORMALPRIO+3, 0, wsT3, sizeof(wsT3), Thread5, "C"); - t4 = chThdCreate(NORMALPRIO+4, 0, wsT4, sizeof(wsT4), Thread5, "D"); - t5 = chThdCreate(NORMALPRIO+5, 0, wsT5, sizeof(wsT5), Thread5, "E"); - chSemSignal(&sem1); - wait(); - println(""); - println("*** Semaphores, atomicity test #4, you should read AABBCCDDEE:"); - chSemInit(&sem1, 0); - chSemInit(&sem2, 1); - t1 = chThdCreate(NORMALPRIO+1, 0, wsT1, sizeof(wsT1), Thread5, "A"); - t2 = chThdCreate(NORMALPRIO+5, 0, wsT2, sizeof(wsT2), Thread5, "B"); - t3 = chThdCreate(NORMALPRIO+2, 0, wsT3, sizeof(wsT3), Thread5, "C"); - t4 = chThdCreate(NORMALPRIO+4, 0, wsT4, sizeof(wsT4), Thread5, "D"); - t5 = chThdCreate(NORMALPRIO+3, 0, wsT5, sizeof(wsT5), Thread5, "E"); - chSemSignal(&sem1); - wait(); - println(""); println("*** Semaphores, timeout test, you should read ABCDE (slowly):"); chSemInit(&sem1, 0); for (i = 0; i < 5; i++) { @@ -250,7 +184,7 @@ t_msg TestThread(void *p) { * Messages test. */ println("*** Messages, dispatch test, you should read AABBCCDDEE:"); - t1 = chThdCreate(NORMALPRIO-1, 0, wsT1, sizeof(wsT1), Thread6, chThdSelf()); + t1 = chThdCreate(NORMALPRIO-1, 0, wsT1, sizeof(wsT1), Thread4, chThdSelf()); do { chMsgRelease(msg = chMsgWait()); if (msg) @@ -259,7 +193,7 @@ t_msg TestThread(void *p) { chThdWait(t1); println(""); println("*** Messages, timeout test, you should read ABCDE (slowly):"); - t1 = chThdCreate(NORMALPRIO-1, 0, wsT1, sizeof(wsT1), Thread7, chThdSelf()); + t1 = chThdCreate(NORMALPRIO-1, 0, wsT1, sizeof(wsT1), Thread5, chThdSelf()); for (i = 0; i < 5; i++) { chFDDPut(comp, 'A'+i); chMsgSendTimeout(t1, 'A'+i, 500);