Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:11d8781f1013, committed 2015-02-16
- Comitter:
- clemounet
- Date:
- Mon Feb 16 16:30:36 2015 +0000
- Child:
- 1:ee7a5f05513d
- Commit message:
- My Helpers = (MyThread,...)
Changed in this revision
| MyThread.cpp | Show annotated file Show diff for this revision Revisions of this file |
| MyThread.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MyThread.cpp Mon Feb 16 16:30:36 2015 +0000
@@ -0,0 +1,38 @@
+
+#include "MyThreads.h"
+
+void MainTrampoline(void const *args){
+ MyThread *mt = (MyThread*) args;
+ mt->Main();
+ mt->t->signal_set(ENDSIG);
+ mt->t->terminate();
+}
+
+MyThread::MyThread(const char* name){
+ tName = (const char*) malloc (sizeof(char)*strlen(name)+1);
+ strcpy((char*)tName,name);
+}
+
+MyThread::~MyThread() {
+ free((char*)tName);
+}
+
+void MyThread::Start(void){
+ running = true;
+}
+
+void MyThread::Stop(void){
+ running = false;
+}
+
+void MyThread::Run(void){
+ t = new Thread(MainTrampoline,this);
+}
+
+void MyThread::Wait(int32_t ms){
+ t->wait(ms);
+}
+
+void MyThread::WaitEnd(){
+ t->signal_wait(ENDSIG);
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MyThread.h Mon Feb 16 16:30:36 2015 +0000
@@ -0,0 +1,25 @@
+
+#ifndef MYTHREADS_H
+#define MYTHREADS_H
+
+#include "mbed.h"
+#include "rtos.h"
+
+#define ENDSIG 0x01
+
+class MyThread{
+public:
+ const char* tName;
+ bool running;
+ Thread *t;
+ MyThread(const char* name);
+ virtual ~MyThread();
+ virtual void Start();
+ virtual void Stop();
+ virtual void Run();
+ virtual void Main(void) = 0;
+ virtual void Wait(int32_t ms);
+ virtual void WaitEnd();
+};
+
+#endif
\ No newline at end of file