A small library that's provide helpers for programmers

Dependents:   PYRN

Committer:
clemounet
Date:
Tue Apr 14 13:07:53 2015 +0000
Revision:
4:eef83534b19e
.add CallBack

Who changed what in which revision?

UserRevisionLine numberNew contents of line
clemounet 4:eef83534b19e 1
clemounet 4:eef83534b19e 2 #include "MyOsHelpers.h"
clemounet 4:eef83534b19e 3
clemounet 4:eef83534b19e 4
clemounet 4:eef83534b19e 5 #define __DEBUG__ 5
clemounet 4:eef83534b19e 6 #ifndef __MODULE__
clemounet 4:eef83534b19e 7 #define __MODULE__ "MyOsHelpers.c"
clemounet 4:eef83534b19e 8 #endif
clemounet 4:eef83534b19e 9 #include "MyDebug.h"
clemounet 4:eef83534b19e 10
clemounet 4:eef83534b19e 11 //extern void *os_active_TCB[];
clemounet 4:eef83534b19e 12 #include "RTX_Conf.h"
clemounet 4:eef83534b19e 13
clemounet 4:eef83534b19e 14 /* List head of chained ready tasks */
clemounet 4:eef83534b19e 15 extern struct OS_XCB os_rdy;
clemounet 4:eef83534b19e 16 /* List head of chained delay tasks */
clemounet 4:eef83534b19e 17 extern struct OS_XCB os_dly;
clemounet 4:eef83534b19e 18
clemounet 4:eef83534b19e 19 void PrintThreadInfo(P_TCB ptcb) {
clemounet 4:eef83534b19e 20 uint32_t r = ptcb->tsk_stack - (int32_t)(ptcb->stack);
clemounet 4:eef83534b19e 21 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);
clemounet 4:eef83534b19e 22 }
clemounet 4:eef83534b19e 23
clemounet 4:eef83534b19e 24 void PrintActiveThreads(void) {
clemounet 4:eef83534b19e 25 P_TCB ptask;
clemounet 4:eef83534b19e 26 uint16_t i = 0;
clemounet 4:eef83534b19e 27 while(1) {
clemounet 4:eef83534b19e 28 ptask = (P_TCB)os_active_TCB[i];
clemounet 4:eef83534b19e 29 //DBG("%p",ptask);
clemounet 4:eef83534b19e 30 if(ptask == NULL)
clemounet 4:eef83534b19e 31 break;
clemounet 4:eef83534b19e 32 else
clemounet 4:eef83534b19e 33 PrintThreadInfo(ptask);
clemounet 4:eef83534b19e 34 i++;
clemounet 4:eef83534b19e 35 }
clemounet 4:eef83534b19e 36 }
clemounet 4:eef83534b19e 37
clemounet 4:eef83534b19e 38 void PrintRDYThreads(void) {
clemounet 4:eef83534b19e 39 DBG("=== Print RDY ===");
clemounet 4:eef83534b19e 40 P_TCB ptcb = os_rdy.p_lnk;
clemounet 4:eef83534b19e 41 while(ptcb) {
clemounet 4:eef83534b19e 42 PrintThreadInfo(ptcb);
clemounet 4:eef83534b19e 43 // go next
clemounet 4:eef83534b19e 44 ptcb = ptcb->p_lnk;
clemounet 4:eef83534b19e 45 }
clemounet 4:eef83534b19e 46 }
clemounet 4:eef83534b19e 47
clemounet 4:eef83534b19e 48 void PrintDLYThreads(void) {
clemounet 4:eef83534b19e 49 DBG("=== Print DLY ===");
clemounet 4:eef83534b19e 50 P_TCB ptcb = os_dly.p_dlnk;
clemounet 4:eef83534b19e 51 while(ptcb) {
clemounet 4:eef83534b19e 52 PrintThreadInfo(ptcb);
clemounet 4:eef83534b19e 53 // go next
clemounet 4:eef83534b19e 54 ptcb = ptcb->p_dlnk;
clemounet 4:eef83534b19e 55 }
clemounet 4:eef83534b19e 56 }
clemounet 4:eef83534b19e 57
clemounet 4:eef83534b19e 58 const char *StateLabelForInt(uint8_t s) {
clemounet 4:eef83534b19e 59 switch(s){
clemounet 4:eef83534b19e 60 case INACTIVE: return INACTIVE_LBL;
clemounet 4:eef83534b19e 61 case READY: return READY_LBL;
clemounet 4:eef83534b19e 62 case RUNNING: return RUNNING_LBL;
clemounet 4:eef83534b19e 63 case WAIT_DLY: return WAIT_DLY_LBL;
clemounet 4:eef83534b19e 64 case WAIT_ITV: return WAIT_ITV_LBL;
clemounet 4:eef83534b19e 65 case WAIT_OR: return WAIT_OR_LBL;
clemounet 4:eef83534b19e 66 case WAIT_AND: return WAIT_AND_LBL;
clemounet 4:eef83534b19e 67 case WAIT_SEM: return WAIT_SEM_LBL;
clemounet 4:eef83534b19e 68 case WAIT_MBX: return WAIT_MBX_LBL;
clemounet 4:eef83534b19e 69 case WAIT_MUT: return WAIT_MUT_LBL;
clemounet 4:eef83534b19e 70 default: return "UNKNOWN";
clemounet 4:eef83534b19e 71 }
clemounet 4:eef83534b19e 72 }