aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-03-28 11:39:30 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-03-28 11:39:30 +0000
commit42a90cc8cebf186c64bbae50a16a90a9979b80f4 (patch)
treedeebba85684cc14dbc44555de36ebcd950f9998a
parentb83cd4a1dc8b3240f821a23c588c8d7d690f70ae (diff)
downloadChibiOS-42a90cc8cebf186c64bbae50a16a90a9979b80f4.tar.gz
ChibiOS-42a90cc8cebf186c64bbae50a16a90a9979b80f4.tar.bz2
ChibiOS-42a90cc8cebf186c64bbae50a16a90a9979b80f4.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@251 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--demos/ARM7-LPC214x-G++/main.cpp10
-rw-r--r--readme.txt4
-rw-r--r--src/lib/ch.cpp9
-rw-r--r--src/lib/ch.hpp24
4 files changed, 37 insertions, 10 deletions
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;
}
diff --git a/readme.txt b/readme.txt
index f6728df02..341fca770 100644
--- a/readme.txt
+++ b/readme.txt
@@ -12,8 +12,8 @@
generic and architecture indipendent.
./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.
+ directory under ./demos/ and/or ./ports/.
+./ports/ - Architecture specific portable files.
./demos/ - Demo programs for specific archtectures/boards.
./test/ - Test code, used by some demos.
./docs/Doxifile - Doxigen project file.
diff --git a/src/lib/ch.cpp b/src/lib/ch.cpp
index d1e739915..653a48dec 100644
--- a/src/lib/ch.cpp
+++ b/src/lib/ch.cpp
@@ -29,12 +29,12 @@ namespace chibios_rt {
chSysInit();
}
- void Lock(void) {
+ void System::Lock(void) {
chSysLock();
}
- void Unlock(void) {
+ void System::Unlock(void) {
chSysUnlock();
}
@@ -125,6 +125,11 @@ namespace chibios_rt {
#endif /* CH_USE_SLEEP */
#ifdef CH_USE_MESSAGES
+ msg_t BaseThread::SendMessage(::Thread* tp, msg_t msg) {
+
+ return chMsgSend(tp, msg);
+ }
+
msg_t BaseThread::SendMessage(msg_t msg) {
return chMsgSend(thread_ref, msg);
diff --git a/src/lib/ch.hpp b/src/lib/ch.hpp
index d9fffc229..177e9bb46 100644
--- a/src/lib/ch.hpp
+++ b/src/lib/ch.hpp
@@ -149,6 +149,11 @@ namespace chibios_rt {
/**
* Sends a message to the thread and returns the answer.
*/
+ static msg_t SendMessage(::Thread *tp, msg_t msg);
+
+ /**
+ * Sends a message to the thread and returns the answer.
+ */
msg_t SendMessage(msg_t msg);
/**
@@ -178,6 +183,25 @@ namespace chibios_rt {
virtual msg_t Main(void);
};
+ /**
+ * Enhanced threads template class. This class introduces thread names
+ * and static working area allocation.
+ */
+ template <int N>
+ class EnhancedThread : public BaseThread {
+ protected:
+ WorkingArea(wa, N); // Thread working area.
+
+ public:
+ const char *name;
+
+ EnhancedThread(const char *tname, tprio_t prio, tmode_t mode) :
+ BaseThread(prio, mode, wa, sizeof wa) {
+
+ name = tname;
+ }
+ };
+
#ifdef CH_USE_SEMAPHORES
/**
* Class encapsulating a /p Semaphore.