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 4:eef83534b19e, committed 2015-04-14
- Comitter:
- clemounet
- Date:
- Tue Apr 14 13:07:53 2015 +0000
- Parent:
- 3:9d3aebd62b82
- Commit message:
- .add CallBack
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MyOsHelpers.cpp Tue Apr 14 13:07:53 2015 +0000
@@ -0,0 +1,72 @@
+
+#include "MyOsHelpers.h"
+
+
+#define __DEBUG__ 5
+#ifndef __MODULE__
+#define __MODULE__ "MyOsHelpers.c"
+#endif
+#include "MyDebug.h"
+
+//extern void *os_active_TCB[];
+#include "RTX_Conf.h"
+
+/* List head of chained ready tasks */
+extern struct OS_XCB os_rdy;
+/* List head of chained delay tasks */
+extern struct OS_XCB os_dly;
+
+void PrintThreadInfo(P_TCB ptcb) {
+ uint32_t r = ptcb->tsk_stack - (int32_t)(ptcb->stack);
+ DBG("T[%d][%03d] %s | %05d | %p | %08x | %05d", ptcb->cb_type, ptcb->task_id, StateLabelForInt(ptcb->state), ptcb->priv_stack, ptcb->stack, ptcb->tsk_stack, ptcb->priv_stack-r);
+}
+
+void PrintActiveThreads(void) {
+ P_TCB ptask;
+ uint16_t i = 0;
+ while(1) {
+ ptask = (P_TCB)os_active_TCB[i];
+ //DBG("%p",ptask);
+ if(ptask == NULL)
+ break;
+ else
+ PrintThreadInfo(ptask);
+ i++;
+ }
+}
+
+void PrintRDYThreads(void) {
+ DBG("=== Print RDY ===");
+ P_TCB ptcb = os_rdy.p_lnk;
+ while(ptcb) {
+ PrintThreadInfo(ptcb);
+ // go next
+ ptcb = ptcb->p_lnk;
+ }
+}
+
+void PrintDLYThreads(void) {
+ DBG("=== Print DLY ===");
+ P_TCB ptcb = os_dly.p_dlnk;
+ while(ptcb) {
+ PrintThreadInfo(ptcb);
+ // go next
+ ptcb = ptcb->p_dlnk;
+ }
+}
+
+const char *StateLabelForInt(uint8_t s) {
+ switch(s){
+ case INACTIVE: return INACTIVE_LBL;
+ case READY: return READY_LBL;
+ case RUNNING: return RUNNING_LBL;
+ case WAIT_DLY: return WAIT_DLY_LBL;
+ case WAIT_ITV: return WAIT_ITV_LBL;
+ case WAIT_OR: return WAIT_OR_LBL;
+ case WAIT_AND: return WAIT_AND_LBL;
+ case WAIT_SEM: return WAIT_SEM_LBL;
+ case WAIT_MBX: return WAIT_MBX_LBL;
+ case WAIT_MUT: return WAIT_MUT_LBL;
+ default: return "UNKNOWN";
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MyOsHelpers.h Tue Apr 14 13:07:53 2015 +0000
@@ -0,0 +1,47 @@
+
+
+#ifndef MY_OS_HELPERS_H
+#define MY_OS_HELPERS_H
+
+#include "rtos.h"
+//#include "rt_TypeDef.h"
+
+/* Values for 'state' */
+#define INACTIVE 0
+#define READY 1
+#define RUNNING 2
+#define WAIT_DLY 3
+#define WAIT_ITV 4
+#define WAIT_OR 5
+#define WAIT_AND 6
+#define WAIT_SEM 7
+#define WAIT_MBX 8
+#define WAIT_MUT 9
+
+#define INACTIVE_LBL "INACTIVE"
+#define READY_LBL "READY "
+#define RUNNING_LBL "RUNNING "
+#define WAIT_DLY_LBL "WAIT DLY"
+#define WAIT_ITV_LBL "WAIT_ITV"
+#define WAIT_OR_LBL "WAIT_OR "
+#define WAIT_AND_LBL "WAIT_AND"
+#define WAIT_SEM_LBL "WAIT_SEM"
+#define WAIT_MBX_LBL "WAIT_MBX"
+#define WAIT_MUT_LBL "WAIT_MUT"
+
+typedef struct OS_XCB {
+ U8 cb_type; /* Control Block Type */
+ struct OS_TCB *p_lnk; /* Link pointer for ready/sem. wait list */
+ struct OS_TCB *p_rlnk; /* Link pointer for sem./mbx lst backwards */
+ struct OS_TCB *p_dlnk; /* Link pointer for delay list */
+ struct OS_TCB *p_blnk; /* Link pointer for delay list backwards */
+ U16 delta_time; /* Time until time out */
+} *P_XCB;
+
+void PrintThreadInfo(P_TCB ptcb);
+void PrintActiveThreads(void);
+void PrintRDYThreads(void);
+void PrintDLYThreads(void);
+const char *StateLabelForInt(uint8_t s);
+
+#endif // MY_OS_HELPERS_H
\ No newline at end of file
--- a/MyThread.cpp Thu Apr 02 07:33:38 2015 +0000 +++ b/MyThread.cpp Tue Apr 14 13:07:53 2015 +0000 @@ -2,7 +2,7 @@ #include "MyThread.h" #include "MyLibc.h" -#define __DEBUG__ 5 +#define __DEBUG__ 0 #ifndef __MODULE__ #define __MODULE__ "MyThread.cpp" #endif