From ef14f74f92fb52d0028eb36b7b48b7e7c4ef52c4 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 27 Mar 2008 11:48:28 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@248 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 141 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 demos/ARM7-LPC214x-G++/main.cpp (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp new file mode 100644 index 000000000..b3c4f8e45 --- /dev/null +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -0,0 +1,141 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include +#include + +#include +#include + +using namespace chibios_rt; + +/* + * LED blinking sequences. + */ +#define SLEEP 0 +#define STOP 1 +#define BITCLEAR 2 +#define BITSET 3 + +typedef struct { + uint8_t action; + uint32_t value; +} bitop_t; + +bitop_t LED1_sequence[] = +{ + {BITCLEAR, 0x00000400}, + {SLEEP, 200}, + {BITSET, 0x00000400}, + {SLEEP, 1800} +}; + +bitop_t LED2_sequence[] = +{ + {SLEEP, 1000}, + {BITCLEAR, 0x00000800}, + {SLEEP, 200}, + {BITSET, 0x00000800}, + {SLEEP, 800} +}; + +bitop_t LED3_sequence[] = +{ + {BITCLEAR, 0x80000000}, + {SLEEP, 200}, + {BITSET, 0x80000000}, + {SLEEP, 300} +}; + +/** + * LED blinker thread class. + */ +class BlinkerThread : chibios_rt::BaseThread { +private: + WorkingArea(wa, 64); + bitop_t *base, *curr, *top; + +protected: + virtual msg_t Main(void) { + + while (TRUE) { + switch(curr->action) { + case SLEEP: + Sleep(curr->value); + break; + case STOP: + return 0; + case BITCLEAR: + IO0CLR = curr->value; + break; + case BITSET: + IO0SET = curr->value; + break; + } + if (++curr >= top) + curr = base; + } + } + +public: + BlinkerThread(bitop_t *sequence, int n) : BaseThread(NORMALPRIO, 0, wa, sizeof wa) { + + base = curr = sequence; + top = sequence + n; + } +}; + +extern "C" { + msg_t TestThread(void *p); +} + +/* + * Executed as event handler at 500mS intervals. + */ +static void TimerHandler(eventid_t id) { + + if (!(IO0PIN & 0x00018000)) // Both buttons + TestThread(&COM1); +} + +/* + * Entry point, the interrupts are disabled on entry. + */ +int main(int argc, char **argv) { + static const evhandler_t evhndl[] = { + TimerHandler + }; + static EvTimer evt; + struct EventListener el0; + + System::Init(); + + 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. */ + + BlinkerThread blinker1(LED1_sequence, sizeof(LED1_sequence) / sizeof(bitop_t)); + BlinkerThread blinker2(LED2_sequence, sizeof(LED2_sequence) / sizeof(bitop_t)); + BlinkerThread blinker3(LED3_sequence, sizeof(LED3_sequence) / sizeof(bitop_t)); + + while(1) + Event::Wait(ALL_EVENTS, evhndl); + + return 0; +} -- cgit v1.2.3 From 165bcc4a0708ff3252fe73156eace36b5980dbf9 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 27 Mar 2008 12:33:31 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@249 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 52 ++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 21 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index b3c4f8e45..1d8acfb5e 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -18,7 +18,9 @@ */ #include + #include +#include #include #include @@ -29,9 +31,10 @@ using namespace chibios_rt; * LED blinking sequences. */ #define SLEEP 0 -#define STOP 1 -#define BITCLEAR 2 -#define BITSET 3 +#define GOTO 1 +#define STOP 2 +#define BITCLEAR 3 +#define BITSET 4 typedef struct { uint8_t action; @@ -43,7 +46,8 @@ bitop_t LED1_sequence[] = {BITCLEAR, 0x00000400}, {SLEEP, 200}, {BITSET, 0x00000400}, - {SLEEP, 1800} + {SLEEP, 1800}, + {GOTO, 0} }; bitop_t LED2_sequence[] = @@ -52,7 +56,8 @@ bitop_t LED2_sequence[] = {BITCLEAR, 0x00000800}, {SLEEP, 200}, {BITSET, 0x00000800}, - {SLEEP, 800} + {SLEEP, 1800}, + {GOTO, 1} }; bitop_t LED3_sequence[] = @@ -60,13 +65,14 @@ bitop_t LED3_sequence[] = {BITCLEAR, 0x80000000}, {SLEEP, 200}, {BITSET, 0x80000000}, - {SLEEP, 300} + {SLEEP, 300}, + {GOTO, 0} }; /** - * LED blinker thread class. + * Blinker thread class. It can drive LEDs or other output pins. */ -class BlinkerThread : chibios_rt::BaseThread { +class BlinkerThread : BaseThread { private: WorkingArea(wa, 64); bitop_t *base, *curr, *top; @@ -79,6 +85,9 @@ protected: case SLEEP: Sleep(curr->value); break; + case GOTO: + curr = &base[curr->value]; + continue; case STOP: return 0; case BITCLEAR: @@ -88,23 +97,17 @@ protected: IO0SET = curr->value; break; } - if (++curr >= top) - curr = base; + curr++; } } public: - BlinkerThread(bitop_t *sequence, int n) : BaseThread(NORMALPRIO, 0, wa, sizeof wa) { + BlinkerThread(bitop_t *sequence) : BaseThread(NORMALPRIO, 0, wa, sizeof wa) { base = curr = sequence; - top = sequence + n; } }; -extern "C" { - msg_t TestThread(void *p); -} - /* * Executed as event handler at 500mS intervals. */ @@ -130,11 +133,18 @@ int main(int argc, char **argv) { evtStart(&evt); /* Starts the event timer. */ chEvtRegister(&evt.et_es, &el0, 0); /* Registers on the timer event source. */ - BlinkerThread blinker1(LED1_sequence, sizeof(LED1_sequence) / sizeof(bitop_t)); - BlinkerThread blinker2(LED2_sequence, sizeof(LED2_sequence) / sizeof(bitop_t)); - BlinkerThread blinker3(LED3_sequence, sizeof(LED3_sequence) / sizeof(bitop_t)); - - while(1) + /* + * Starts serveral instances of the BlinkerThread class, each one operating + * on a different LED. + */ + BlinkerThread blinker1(LED1_sequence); + BlinkerThread blinker2(LED2_sequence); + BlinkerThread blinker3(LED3_sequence); + + /* + * Serves timer events. + */ + while (true) Event::Wait(ALL_EVENTS, evhndl); return 0; -- cgit v1.2.3 From b83cd4a1dc8b3240f821a23c588c8d7d690f70ae Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 27 Mar 2008 14:42:48 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@250 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 1d8acfb5e..39b31e89a 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -28,7 +28,8 @@ using namespace chibios_rt; /* - * LED blinking sequences. + * LED blink sequences. + * NOTE: Sequences must always be terminated by a GOTO instruction. */ #define SLEEP 0 #define GOTO 1 @@ -39,9 +40,9 @@ using namespace chibios_rt; typedef struct { uint8_t action; uint32_t value; -} bitop_t; +} seqop_t; -bitop_t LED1_sequence[] = +static const seqop_t LED1_sequence[] = { {BITCLEAR, 0x00000400}, {SLEEP, 200}, @@ -50,7 +51,7 @@ bitop_t LED1_sequence[] = {GOTO, 0} }; -bitop_t LED2_sequence[] = +static const seqop_t LED2_sequence[] = { {SLEEP, 1000}, {BITCLEAR, 0x00000800}, @@ -60,7 +61,7 @@ bitop_t LED2_sequence[] = {GOTO, 1} }; -bitop_t LED3_sequence[] = +static const seqop_t LED3_sequence[] = { {BITCLEAR, 0x80000000}, {SLEEP, 200}, @@ -70,14 +71,16 @@ bitop_t LED3_sequence[] = }; /** - * Blinker thread class. It can drive LEDs or other output pins. + * Sequencer thread class. It can drive LEDs or other output pins. */ -class BlinkerThread : BaseThread { +class SequencerThread : BaseThread { private: - WorkingArea(wa, 64); - bitop_t *base, *curr, *top; + + WorkingArea(wa, 64); // Thread working area. + const seqop_t *base, *curr; // Thread local variables. protected: + virtual msg_t Main(void) { while (TRUE) { @@ -102,7 +105,7 @@ protected: } public: - BlinkerThread(bitop_t *sequence) : BaseThread(NORMALPRIO, 0, wa, sizeof wa) { + SequencerThread(const seqop_t *sequence) : BaseThread(NORMALPRIO, 0, wa, sizeof wa) { base = curr = sequence; } @@ -127,19 +130,19 @@ int main(int argc, char **argv) { static EvTimer evt; struct EventListener el0; - System::Init(); + System::Init(); // ChibiOS/RT goes live here. - 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. */ + 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 serveral instances of the BlinkerThread class, each one operating + * Starts serveral instances of the SequencerThread class, each one operating * on a different LED. */ - BlinkerThread blinker1(LED1_sequence); - BlinkerThread blinker2(LED2_sequence); - BlinkerThread blinker3(LED3_sequence); + SequencerThread blinker1(LED1_sequence); + SequencerThread blinker2(LED2_sequence); + SequencerThread blinker3(LED3_sequence); /* * Serves timer events. -- cgit v1.2.3 From 42a90cc8cebf186c64bbae50a16a90a9979b80f4 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 28 Mar 2008 11:39:30 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@251 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 39b31e89a..b96a8271f 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -73,17 +73,14 @@ static const seqop_t LED3_sequence[] = /** * Sequencer thread class. It can drive LEDs or other output pins. */ -class SequencerThread : BaseThread { +class SequencerThread : EnhancedThread<64> { private: - - WorkingArea(wa, 64); // Thread working area. const seqop_t *base, *curr; // Thread local variables. protected: - virtual msg_t Main(void) { - while (TRUE) { + while (true) { switch(curr->action) { case SLEEP: Sleep(curr->value); @@ -105,7 +102,8 @@ protected: } public: - SequencerThread(const seqop_t *sequence) : BaseThread(NORMALPRIO, 0, wa, sizeof wa) { + SequencerThread(const seqop_t *sequence): + EnhancedThread<64>("sequencer", NORMALPRIO, 0) { base = curr = sequence; } -- cgit v1.2.3 From 64f96a5128c0358044efd962e0bcf7caee917348 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 28 Mar 2008 16:13:17 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@252 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index b96a8271f..37147fe91 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -30,6 +30,8 @@ using namespace chibios_rt; /* * LED blink sequences. * NOTE: Sequences must always be terminated by a GOTO instruction. + * NOTE: The sequencer language could be easily improved but this is outside + * the scope of this demo. */ #define SLEEP 0 #define GOTO 1 @@ -42,6 +44,7 @@ typedef struct { uint32_t value; } seqop_t; +// Flashing sequence for LED1. static const seqop_t LED1_sequence[] = { {BITCLEAR, 0x00000400}, @@ -51,6 +54,7 @@ static const seqop_t LED1_sequence[] = {GOTO, 0} }; +// Flashing sequence for LED2. static const seqop_t LED2_sequence[] = { {SLEEP, 1000}, @@ -61,6 +65,7 @@ static const seqop_t LED2_sequence[] = {GOTO, 1} }; +// Flashing sequence for LED3. static const seqop_t LED3_sequence[] = { {BITCLEAR, 0x80000000}, @@ -70,8 +75,10 @@ static const seqop_t LED3_sequence[] = {GOTO, 0} }; -/** +/* * Sequencer thread class. It can drive LEDs or other output pins. + * Any sequencer is just an instance of this class, all the details are + * totally encapsulated and hidden to the application level. */ class SequencerThread : EnhancedThread<64> { private: @@ -79,7 +86,6 @@ private: protected: virtual msg_t Main(void) { - while (true) { switch(curr->action) { case SLEEP: @@ -102,15 +108,14 @@ protected: } public: - SequencerThread(const seqop_t *sequence): - EnhancedThread<64>("sequencer", NORMALPRIO, 0) { + SequencerThread(const seqop_t *sequence) : EnhancedThread<64>("sequencer") { base = curr = sequence; } }; /* - * Executed as event handler at 500mS intervals. + * Executed as an event handler at 500mS intervals. */ static void TimerHandler(eventid_t id) { @@ -120,6 +125,7 @@ static void TimerHandler(eventid_t id) { /* * Entry point, the interrupts are disabled on entry. + * This is the real "application". */ int main(int argc, char **argv) { static const evhandler_t evhndl[] = { @@ -130,9 +136,9 @@ int main(int argc, char **argv) { System::Init(); // ChibiOS/RT goes live here. - evtInit(&evt, 500); // Initializes an event timer object. + evtInit(&evt, 500); // Initializes an event timer. evtStart(&evt); // Starts the event timer. - chEvtRegister(&evt.et_es, &el0, 0); // Registers on the timer event source. + chEvtRegister(&evt.et_es, &el0, 0); // Registers a listener on the source. /* * Starts serveral instances of the SequencerThread class, each one operating -- cgit v1.2.3 From f44bd871c77406f8e28047d9484cbabafa626040 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 4 Oct 2008 12:00:18 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@459 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 37147fe91..576581b79 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -124,8 +124,8 @@ static void TimerHandler(eventid_t id) { } /* - * Entry point, the interrupts are disabled on entry. - * This is the real "application". + * Entry point, note, the main() function is already a thread in the system + * on entry. */ int main(int argc, char **argv) { static const evhandler_t evhndl[] = { @@ -134,8 +134,6 @@ int main(int argc, char **argv) { static EvTimer evt; struct EventListener el0; - System::Init(); // ChibiOS/RT goes live here. - evtInit(&evt, 500); // Initializes an event timer. evtStart(&evt); // Starts the event timer. chEvtRegister(&evt.et_es, &el0, 0); // Registers a listener on the source. -- cgit v1.2.3 From dae3de6609b9251dbaaa280c1ce886a350c3c0c5 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 7 Dec 2008 10:21:40 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@536 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 576581b79..a269189ab 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -139,7 +139,7 @@ int main(int argc, char **argv) { chEvtRegister(&evt.et_es, &el0, 0); // Registers a listener on the source. /* - * Starts serveral instances of the SequencerThread class, each one operating + * Starts several instances of the SequencerThread class, each one operating * on a different LED. */ SequencerThread blinker1(LED1_sequence); @@ -150,7 +150,7 @@ int main(int argc, char **argv) { * Serves timer events. */ while (true) - Event::Wait(ALL_EVENTS, evhndl); + Event::Dispatch(evhndl, Event::WaitOne(ALL_EVENTS)); return 0; } -- cgit v1.2.3 From 73a6c86af1bb7f4c16f5aaf8d170176adc609fc8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 21 Feb 2009 11:14:24 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@798 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index a269189ab..37d79c04d 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -80,7 +80,7 @@ static const seqop_t LED3_sequence[] = * Any sequencer is just an instance of this class, all the details are * totally encapsulated and hidden to the application level. */ -class SequencerThread : EnhancedThread<64> { +class SequencerThread : EnhancedThread<128> { private: const seqop_t *base, *curr; // Thread local variables. -- cgit v1.2.3 From ac4e799160b05fc1a9f39ce28fde891e749fddbc Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 15 Mar 2009 09:27:36 +0000 Subject: Fixed bug 2687489. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@851 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 37d79c04d..2f89d5dcf 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -108,7 +108,7 @@ protected: } public: - SequencerThread(const seqop_t *sequence) : EnhancedThread<64>("sequencer") { + SequencerThread(const seqop_t *sequence) : EnhancedThread<128>("sequencer") { base = curr = sequence; } -- cgit v1.2.3 From d6eb57b8ea6c73a694cff33ded801af9e25ecff7 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 24 May 2009 13:38:16 +0000 Subject: Fixed bugs 2796065, 2796069 and 2796081. Updated ARM test reports. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@987 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 2f89d5dcf..647dee8a3 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -80,7 +80,7 @@ static const seqop_t LED3_sequence[] = * Any sequencer is just an instance of this class, all the details are * totally encapsulated and hidden to the application level. */ -class SequencerThread : EnhancedThread<128> { +class SequencerThread : public EnhancedThread<128> { private: const seqop_t *base, *curr; // Thread local variables. @@ -114,13 +114,31 @@ public: } }; +/* + * Tester thread class. This thread executes the test suite. + */ +class TesterThread : public EnhancedThread<128> { + +protected: + virtual msg_t Main(void) { + + return TestThread(&COM1); + } + +public: + TesterThread(void) : EnhancedThread<128>("tester") { + } +}; + /* * Executed as an event handler at 500mS intervals. */ static void TimerHandler(eventid_t id) { - if (!(IO0PIN & 0x00018000)) // Both buttons - TestThread(&COM1); + if (!(IO0PIN & 0x00018000)) { // Both buttons + TesterThread tester; + tester.Wait(); + }; } /* -- cgit v1.2.3 From 2a7941ee58016ce7641ab8010aff5fe711e0bedc Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 2 Jun 2009 13:41:38 +0000 Subject: I/O port driver for LPC214x added. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1016 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 647dee8a3..1a50f5936 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -18,11 +18,12 @@ */ #include +#include #include #include -#include +#include #include using namespace chibios_rt; @@ -47,9 +48,9 @@ typedef struct { // Flashing sequence for LED1. static const seqop_t LED1_sequence[] = { - {BITCLEAR, 0x00000400}, + {BITCLEAR, PA_LED1}, {SLEEP, 200}, - {BITSET, 0x00000400}, + {BITSET, PA_LED1}, {SLEEP, 1800}, {GOTO, 0} }; @@ -58,9 +59,9 @@ static const seqop_t LED1_sequence[] = static const seqop_t LED2_sequence[] = { {SLEEP, 1000}, - {BITCLEAR, 0x00000800}, + {BITCLEAR, PA_LED2}, {SLEEP, 200}, - {BITSET, 0x00000800}, + {BITSET, PA_LED2}, {SLEEP, 1800}, {GOTO, 1} }; @@ -68,9 +69,9 @@ static const seqop_t LED2_sequence[] = // Flashing sequence for LED3. static const seqop_t LED3_sequence[] = { - {BITCLEAR, 0x80000000}, + {BITCLEAR, PA_LEDUSB}, {SLEEP, 200}, - {BITSET, 0x80000000}, + {BITSET, PA_LEDUSB}, {SLEEP, 300}, {GOTO, 0} }; @@ -97,10 +98,10 @@ protected: case STOP: return 0; case BITCLEAR: - IO0CLR = curr->value; + chPortClear(IOPORT_A, curr->value); break; case BITSET: - IO0SET = curr->value; + chPortSet(IOPORT_A, curr->value); break; } curr++; @@ -135,7 +136,7 @@ public: */ static void TimerHandler(eventid_t id) { - if (!(IO0PIN & 0x00018000)) { // Both buttons + if (!(chPortRead(IOPORT_A) & (PA_BUTTON1 | PA_BUTTON2))) { // Both buttons TesterThread tester; tester.Wait(); }; -- cgit v1.2.3 From be1e6b03d4a49b6fa16c3368435089f8706fb566 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 7 Jun 2009 17:53:23 +0000 Subject: Adjusted PAL support for LPC214x. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1026 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 1a50f5936..683c2675d 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include @@ -26,6 +26,8 @@ #include #include +#define BOTH_BUTTONS (PAL_PORT_BIT(PA_BUTTON1) | PAL_PORT_BIT(PA_BUTTON2)) + using namespace chibios_rt; /* @@ -48,9 +50,9 @@ typedef struct { // Flashing sequence for LED1. static const seqop_t LED1_sequence[] = { - {BITCLEAR, PA_LED1}, + {BITCLEAR, PAL_PORT_BIT(PA_LED1)}, {SLEEP, 200}, - {BITSET, PA_LED1}, + {BITSET, PAL_PORT_BIT(PA_LED1)}, {SLEEP, 1800}, {GOTO, 0} }; @@ -59,9 +61,9 @@ static const seqop_t LED1_sequence[] = static const seqop_t LED2_sequence[] = { {SLEEP, 1000}, - {BITCLEAR, PA_LED2}, + {BITCLEAR, PAL_PORT_BIT(PA_LED2)}, {SLEEP, 200}, - {BITSET, PA_LED2}, + {BITSET, PAL_PORT_BIT(PA_LED2)}, {SLEEP, 1800}, {GOTO, 1} }; @@ -69,9 +71,9 @@ static const seqop_t LED2_sequence[] = // Flashing sequence for LED3. static const seqop_t LED3_sequence[] = { - {BITCLEAR, PA_LEDUSB}, + {BITCLEAR, PAL_PORT_BIT(PA_LEDUSB)}, {SLEEP, 200}, - {BITSET, PA_LEDUSB}, + {BITSET, PAL_PORT_BIT(PA_LEDUSB)}, {SLEEP, 300}, {GOTO, 0} }; @@ -98,10 +100,10 @@ protected: case STOP: return 0; case BITCLEAR: - chPortClear(IOPORT_A, curr->value); + palClearPort(IOPORT_A, curr->value); break; case BITSET: - chPortSet(IOPORT_A, curr->value); + palSetPort(IOPORT_A, curr->value); break; } curr++; @@ -136,7 +138,7 @@ public: */ static void TimerHandler(eventid_t id) { - if (!(chPortRead(IOPORT_A) & (PA_BUTTON1 | PA_BUTTON2))) { // Both buttons + if (!(palReadPort(IOPORT_A) & BOTH_BUTTONS)) { // Both buttons TesterThread tester; tester.Wait(); }; -- cgit v1.2.3 From 89cd6853e753c32903a9a6d48e3fe26be8999f97 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 21 Aug 2009 09:32:58 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1095 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 683c2675d..b217e86a2 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -19,12 +19,11 @@ #include #include - -#include +#include #include +#include -#include -#include +#include "board.h" #define BOTH_BUTTONS (PAL_PORT_BIT(PA_BUTTON1) | PAL_PORT_BIT(PA_BUTTON2)) @@ -155,6 +154,11 @@ int main(int argc, char **argv) { static EvTimer evt; struct EventListener el0; + /* + * Activates the communication port 1 using the driver default configuration. + */ + sdStart(&COM1, NULL); + evtInit(&evt, 500); // Initializes an event timer. evtStart(&evt); // Starts the event timer. chEvtRegister(&evt.et_es, &el0, 0); // Registers a listener on the source. -- cgit v1.2.3 From 8b55cb9767ce881b7a22c5af34605ed3a261582d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 27 Aug 2009 16:42:07 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1109 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index b217e86a2..b46ccd86e 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -99,10 +99,10 @@ protected: case STOP: return 0; case BITCLEAR: - palClearPort(IOPORT_A, curr->value); + palClearPort(IOPORT1, curr->value); break; case BITSET: - palSetPort(IOPORT_A, curr->value); + palSetPort(IOPORT1, curr->value); break; } curr++; @@ -124,7 +124,7 @@ class TesterThread : public EnhancedThread<128> { protected: virtual msg_t Main(void) { - return TestThread(&COM1); + return TestThread(&SD1); } public: @@ -137,7 +137,7 @@ public: */ static void TimerHandler(eventid_t id) { - if (!(palReadPort(IOPORT_A) & BOTH_BUTTONS)) { // Both buttons + if (!(palReadPort(IOPORT1) & BOTH_BUTTONS)) { // Both buttons TesterThread tester; tester.Wait(); }; @@ -155,9 +155,9 @@ int main(int argc, char **argv) { struct EventListener el0; /* - * Activates the communication port 1 using the driver default configuration. + * Activates the serial driver 2 using the driver default configuration. */ - sdStart(&COM1, NULL); + sdStart(&SD1, NULL); evtInit(&evt, 500); // Initializes an event timer. evtStart(&evt); // Starts the event timer. -- cgit v1.2.3 From e9d7b9de5705a3b5c0b822077fbd165c86087481 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 17 Oct 2009 11:07:15 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1230 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index b46ccd86e..f0268045d 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -137,6 +137,7 @@ public: */ static void TimerHandler(eventid_t id) { + (void)id; if (!(palReadPort(IOPORT1) & BOTH_BUTTONS)) { // Both buttons TesterThread tester; tester.Wait(); @@ -154,6 +155,9 @@ int main(int argc, char **argv) { static EvTimer evt; struct EventListener el0; + (void)argc; + (void)argv; + /* * Activates the serial driver 2 using the driver default configuration. */ -- cgit v1.2.3 From 93fc8b57778f698cbe7e0e202e33b5d56ce09039 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 8 Dec 2009 10:36:29 +0000 Subject: HAL implemented for LPC214x. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1392 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index f0268045d..7b012d004 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -17,13 +17,10 @@ along with this program. If not, see . */ -#include -#include -#include -#include -#include - -#include "board.h" +#include "ch.hpp" +#include "hal.h" +#include "test.h" +#include "evtimer.h" #define BOTH_BUTTONS (PAL_PORT_BIT(PA_BUTTON1) | PAL_PORT_BIT(PA_BUTTON2)) -- cgit v1.2.3 From 157b6f9695e7f72f2d54b231c19cb4045710ed01 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 21 Feb 2010 07:24:53 +0000 Subject: Updated license dates. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1646 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 7b012d004..b6b7c83ba 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From f131e4297dc619b3f3148a079c634f2cec0fd687 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 19 Dec 2010 10:03:11 +0000 Subject: LPC214x board files and demos updated. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2499 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index b6b7c83ba..8a9ca1c05 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -142,8 +142,7 @@ static void TimerHandler(eventid_t id) { } /* - * Entry point, note, the main() function is already a thread in the system - * on entry. + * Application entry point. */ int main(int argc, char **argv) { static const evhandler_t evhndl[] = { @@ -155,6 +154,16 @@ int main(int argc, char **argv) { (void)argc; (void)argv; + /* + * System initializations. + * - HAL initialization, this also initializes the configured device drivers + * and performs the board-specific initializations. + * - Kernel initialization, the main() function becomes a thread and the + * RTOS is active. + */ + halInit(); + System::Init(); + /* * Activates the serial driver 2 using the driver default configuration. */ -- cgit v1.2.3 From f2386f6a22c55842203278c5b1f9691c5ac5f8fd Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 21 Dec 2010 10:30:39 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2515 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 8a9ca1c05..ca99c67ef 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -144,16 +144,13 @@ static void TimerHandler(eventid_t id) { /* * Application entry point. */ -int main(int argc, char **argv) { +int main(void) { static const evhandler_t evhndl[] = { TimerHandler }; static EvTimer evt; struct EventListener el0; - (void)argc; - (void)argv; - /* * System initializations. * - HAL initialization, this also initializes the configured device drivers -- cgit v1.2.3 From e7e79a6ccb4f3e320b2b8b7bad1b14d65218641d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 18 Mar 2011 18:38:08 +0000 Subject: License updated. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2827 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index ca99c67ef..c5f0187ca 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -1,5 +1,6 @@ /* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From de5dcbba856524599a8f06d3a9bdbf1b01db44c2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 21 Jan 2012 14:29:42 +0000 Subject: License text updated with new year. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3846 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index c5f0187ca..454e691b8 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011 Giovanni Di Sirio. + 2011,2012 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 8d9074541c5740eb7ba9ec8313c5c806718e025f Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 28 Oct 2012 07:47:01 +0000 Subject: Fixed bug 3579734. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4787 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 454e691b8..367021213 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -163,7 +163,7 @@ int main(void) { System::Init(); /* - * Activates the serial driver 2 using the driver default configuration. + * Activates the serial driver 1 using the driver default configuration. */ sdStart(&SD1, NULL); -- cgit v1.2.3 From 184a71345c6a36a9a8664eda8fbcc3ea728267a8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 2 Feb 2013 10:58:09 +0000 Subject: Updated license years. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5102 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 367021213..31507d737 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012 Giovanni Di Sirio. + 2011,2012,2013 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 853216256ad4cdacf5f94edb7d6b738c6be165a1 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 30 Mar 2013 10:32:37 +0000 Subject: Relicensing parts of the tree under the Apache 2.0 license. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5521 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 31507d737..6b81f591d 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -1,21 +1,17 @@ /* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012,2013 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - This file is part of ChibiOS/RT. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - ChibiOS/RT is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. + http://www.apache.org/licenses/LICENSE-2.0 - ChibiOS/RT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ #include "ch.hpp" -- cgit v1.2.3 From edbb1137a3651757e2722a143e60f0a8375e2201 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 19 May 2013 09:38:56 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5745 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-G++/main.cpp | 61 +++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 36 deletions(-) (limited to 'demos/ARM7-LPC214x-G++/main.cpp') diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp index 6b81f591d..ec6a323f7 100644 --- a/demos/ARM7-LPC214x-G++/main.cpp +++ b/demos/ARM7-LPC214x-G++/main.cpp @@ -17,7 +17,6 @@ #include "ch.hpp" #include "hal.h" #include "test.h" -#include "evtimer.h" #define BOTH_BUTTONS (PAL_PORT_BIT(PA_BUTTON1) | PAL_PORT_BIT(PA_BUTTON2)) @@ -76,16 +75,16 @@ static const seqop_t LED3_sequence[] = * Any sequencer is just an instance of this class, all the details are * totally encapsulated and hidden to the application level. */ -class SequencerThread : public EnhancedThread<128> { +class SequencerThread : public BaseStaticThread<128> { private: const seqop_t *base, *curr; // Thread local variables. protected: - virtual msg_t Main(void) { + virtual msg_t main(void) { while (true) { switch(curr->action) { case SLEEP: - Sleep(curr->value); + sleep(curr->value); break; case GOTO: curr = &base[curr->value]; @@ -104,7 +103,7 @@ protected: } public: - SequencerThread(const seqop_t *sequence) : EnhancedThread<128>("sequencer") { + SequencerThread(const seqop_t *sequence) : BaseStaticThread<128>() { base = curr = sequence; } @@ -113,40 +112,30 @@ public: /* * Tester thread class. This thread executes the test suite. */ -class TesterThread : public EnhancedThread<128> { +class TesterThread : public BaseStaticThread<256> { protected: - virtual msg_t Main(void) { + virtual msg_t main(void) { - return TestThread(&SD1); + setName("tester"); + + return TestThread(&SD2); } public: - TesterThread(void) : EnhancedThread<128>("tester") { + TesterThread(void) : BaseStaticThread<256>() { } }; -/* - * Executed as an event handler at 500mS intervals. - */ -static void TimerHandler(eventid_t id) { - - (void)id; - if (!(palReadPort(IOPORT1) & BOTH_BUTTONS)) { // Both buttons - TesterThread tester; - tester.Wait(); - }; -} +static TesterThread tester; +static SequencerThread blinker1(LED1_sequence); +static SequencerThread blinker2(LED2_sequence); +static SequencerThread blinker3(LED3_sequence); /* * Application entry point. */ int main(void) { - static const evhandler_t evhndl[] = { - TimerHandler - }; - static EvTimer evt; - struct EventListener el0; /* * System initializations. @@ -156,30 +145,30 @@ int main(void) { * RTOS is active. */ halInit(); - System::Init(); + System::init(); /* * Activates the serial driver 1 using the driver default configuration. */ sdStart(&SD1, NULL); - evtInit(&evt, 500); // Initializes an event timer. - evtStart(&evt); // Starts the event timer. - chEvtRegister(&evt.et_es, &el0, 0); // Registers a listener on the source. - /* * Starts several instances of the SequencerThread class, each one operating * on a different LED. */ - SequencerThread blinker1(LED1_sequence); - SequencerThread blinker2(LED2_sequence); - SequencerThread blinker3(LED3_sequence); + blinker1.start(NORMALPRIO + 10); + blinker2.start(NORMALPRIO + 10); + blinker3.start(NORMALPRIO + 10); /* * Serves timer events. */ - while (true) - Event::Dispatch(evhndl, Event::WaitOne(ALL_EVENTS)); - + while (true) { + if (!(palReadPort(IOPORT1) & BOTH_BUTTONS)) { + tester.start(NORMALPRIO); + tester.wait(); + }; + BaseThread::sleep(MS2ST(500)); + } return 0; } -- cgit v1.2.3