aboutsummaryrefslogtreecommitdiffstats
path: root/demos/ARM7-LPC214x-G++
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-05-19 09:38:56 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-05-19 09:38:56 +0000
commitedbb1137a3651757e2722a143e60f0a8375e2201 (patch)
tree783fe57209b37d6bf912436f54b5d84f2f1ab3d5 /demos/ARM7-LPC214x-G++
parent071dd3e06c505d46b9332b7be1390b9003952e82 (diff)
downloadChibiOS-edbb1137a3651757e2722a143e60f0a8375e2201.tar.gz
ChibiOS-edbb1137a3651757e2722a143e60f0a8375e2201.tar.bz2
ChibiOS-edbb1137a3651757e2722a143e60f0a8375e2201.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5745 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos/ARM7-LPC214x-G++')
-rw-r--r--demos/ARM7-LPC214x-G++/Makefile5
-rw-r--r--demos/ARM7-LPC214x-G++/main.cpp61
2 files changed, 29 insertions, 37 deletions
diff --git a/demos/ARM7-LPC214x-G++/Makefile b/demos/ARM7-LPC214x-G++/Makefile
index 67b294b7c..95a64eb8c 100644
--- a/demos/ARM7-LPC214x-G++/Makefile
+++ b/demos/ARM7-LPC214x-G++/Makefile
@@ -51,6 +51,7 @@ include $(CHIBIOS)/os/hal/platforms/LPC214x/platform.mk
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/ports/GCC/ARM/LPC214x/port.mk
include $(CHIBIOS)/os/kernel/kernel.mk
+include $(CHIBIOS)/os/various/cpp_wrappers/kernel.mk
include $(CHIBIOS)/test/test.mk
# Define linker script file here
@@ -68,7 +69,8 @@ CSRC = $(PORTSRC) \
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
-CPPSRC = $(CHIBIOS)/os/various/ch.cpp main.cpp
+CPPSRC = $(CHCPPSRC) \
+ main.cpp
# C sources to be compiled in ARM mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
@@ -95,6 +97,7 @@ ASMSRC = $(PORTASM)
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) \
+ $(CHCPPINC) \
$(CHIBIOS)/os/various
#
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;
}