diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-05-12 08:47:26 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-05-12 08:47:26 +0000 |
commit | 4f0b993b4416e13f480ff4b4249244d3b2ac861b (patch) | |
tree | 29ca151f93627eabdfdcd4bf577eb43d91a4ae40 /demos/ARMCM3-STM32F103-G++ | |
parent | fde582b119c3c1f7c780b9b1e9fc9a0954588ca3 (diff) | |
download | ChibiOS-4f0b993b4416e13f480ff4b4249244d3b2ac861b.tar.gz ChibiOS-4f0b993b4416e13f480ff4b4249244d3b2ac861b.tar.bz2 ChibiOS-4f0b993b4416e13f480ff4b4249244d3b2ac861b.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5728 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos/ARMCM3-STM32F103-G++')
-rw-r--r-- | demos/ARMCM3-STM32F103-G++/Makefile | 5 | ||||
-rw-r--r-- | demos/ARMCM3-STM32F103-G++/main.cpp | 53 |
2 files changed, 25 insertions, 33 deletions
diff --git a/demos/ARMCM3-STM32F103-G++/Makefile b/demos/ARMCM3-STM32F103-G++/Makefile index 0556e9719..f7a72b5d6 100644 --- a/demos/ARMCM3-STM32F103-G++/Makefile +++ b/demos/ARMCM3-STM32F103-G++/Makefile @@ -64,6 +64,7 @@ include $(CHIBIOS)/os/hal/platforms/STM32F1xx/platform.mk include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F1xx/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
@@ -82,7 +83,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
@@ -109,6 +111,7 @@ ASMSRC = $(PORTASM) INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) \
+ $(CHCPPINC) \
$(CHIBIOS)/os/various
#
diff --git a/demos/ARMCM3-STM32F103-G++/main.cpp b/demos/ARMCM3-STM32F103-G++/main.cpp index 1aab98265..59ff88986 100644 --- a/demos/ARMCM3-STM32F103-G++/main.cpp +++ b/demos/ARMCM3-STM32F103-G++/main.cpp @@ -17,7 +17,6 @@ #include "ch.hpp"
#include "hal.h"
#include "test.h"
-#include "evtimer.h"
using namespace chibios_rt;
@@ -65,16 +64,16 @@ static const seqop_t LED1_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];
@@ -93,7 +92,7 @@ protected: }
public:
- SequencerThread(const seqop_t *sequence) : EnhancedThread<128>("sequencer") {
+ SequencerThread(const seqop_t *sequence) : BaseStaticThread<128>() {
base = curr = sequence;
}
@@ -102,40 +101,29 @@ public: /*
* Tester thread class. This thread executes the test suite.
*/
-class TesterThread : public EnhancedThread<256> {
+class TesterThread : public BaseStaticThread<256> {
protected:
- virtual msg_t Main(void) {
+ virtual msg_t main(void) {
+
+ setName("tester");
return TestThread(&SD2);
}
public:
- TesterThread(void) : EnhancedThread<256>("tester") {
+ TesterThread(void) : BaseStaticThread<256>() {
}
};
-/*
- * Executed as an event handler at 500mS intervals.
- */
-static void TimerHandler(eventid_t id) {
-
- (void)id;
- if (palReadPad(GPIOA, GPIOA_BUTTON)) {
- TesterThread tester;
- tester.Wait();
- };
-}
+/* Static threads instances.*/
+static TesterThread tester;
+static SequencerThread blinker1(LED1_sequence);
/*
* Application entry point.
*/
int main(void) {
- static const evhandler_t evhndl[] = {
- TimerHandler
- };
- static EvTimer evt;
- struct EventListener el0;
/*
* System initializations.
@@ -145,28 +133,29 @@ int main(void) { * RTOS is active.
*/
halInit();
- System::Init();
+ System::init();
/*
* Activates the serial driver 2 using the driver default configuration.
*/
sdStart(&SD2, 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);
+ blinker1.start(NORMALPRIO + 10);
/*
* Serves timer events.
*/
- while (true)
- Event::Dispatch(evhndl, Event::WaitOne(ALL_EVENTS));
+ while (true) {
+ if (palReadPad(GPIOA, GPIOA_BUTTON)) {
+ tester.start(NORMALPRIO);
+ tester.wait();
+ };
+ BaseThread::sleep(MS2ST(500));
+ }
return 0;
}
|