Pradeep Kotipalli
/
cdms_rtos_summer
hjnjnj
main.cpp@0:0e52cd8d26c8, 2015-06-08 (annotated)
- Committer:
- pradeepvk2208
- Date:
- Mon Jun 08 10:51:30 2015 +0000
- Revision:
- 0:0e52cd8d26c8
high;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pradeepvk2208 | 0:0e52cd8d26c8 | 1 | #include "mbed.h" |
pradeepvk2208 | 0:0e52cd8d26c8 | 2 | #include "rtos.h" |
pradeepvk2208 | 0:0e52cd8d26c8 | 3 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 4 | Serial pc(USBTX, USBRX); |
pradeepvk2208 | 0:0e52cd8d26c8 | 5 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 6 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 7 | Thread *ptr_hk_bae; |
pradeepvk2208 | 0:0e52cd8d26c8 | 8 | Thread *ptr_hk_cdms; |
pradeepvk2208 | 0:0e52cd8d26c8 | 9 | Thread *ptr_hk_payload; |
pradeepvk2208 | 0:0e52cd8d26c8 | 10 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 11 | Timer t1; |
pradeepvk2208 | 0:0e52cd8d26c8 | 12 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 13 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 14 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 15 | void HK_BAE(void const *args) |
pradeepvk2208 | 0:0e52cd8d26c8 | 16 | { |
pradeepvk2208 | 0:0e52cd8d26c8 | 17 | while(1) |
pradeepvk2208 | 0:0e52cd8d26c8 | 18 | { |
pradeepvk2208 | 0:0e52cd8d26c8 | 19 | Thread::signal_wait(0x1); |
pradeepvk2208 | 0:0e52cd8d26c8 | 20 | printf("Entered HK_BAE"); |
pradeepvk2208 | 0:0e52cd8d26c8 | 21 | } |
pradeepvk2208 | 0:0e52cd8d26c8 | 22 | } |
pradeepvk2208 | 0:0e52cd8d26c8 | 23 | void HK_CDMS(void const *args) |
pradeepvk2208 | 0:0e52cd8d26c8 | 24 | { |
pradeepvk2208 | 0:0e52cd8d26c8 | 25 | while(1) |
pradeepvk2208 | 0:0e52cd8d26c8 | 26 | { |
pradeepvk2208 | 0:0e52cd8d26c8 | 27 | Thread::signal_wait(0x2); |
pradeepvk2208 | 0:0e52cd8d26c8 | 28 | printf("Entered HK_CDMS"); |
pradeepvk2208 | 0:0e52cd8d26c8 | 29 | } |
pradeepvk2208 | 0:0e52cd8d26c8 | 30 | } |
pradeepvk2208 | 0:0e52cd8d26c8 | 31 | void HK_PAYLOAD(void const *args) |
pradeepvk2208 | 0:0e52cd8d26c8 | 32 | { |
pradeepvk2208 | 0:0e52cd8d26c8 | 33 | while(1) |
pradeepvk2208 | 0:0e52cd8d26c8 | 34 | { |
pradeepvk2208 | 0:0e52cd8d26c8 | 35 | Thread::signal_wait(0x3); |
pradeepvk2208 | 0:0e52cd8d26c8 | 36 | printf("Entered HK_PAYLOAD"); |
pradeepvk2208 | 0:0e52cd8d26c8 | 37 | } |
pradeepvk2208 | 0:0e52cd8d26c8 | 38 | } |
pradeepvk2208 | 0:0e52cd8d26c8 | 39 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 40 | uint16_t schedcount=1; |
pradeepvk2208 | 0:0e52cd8d26c8 | 41 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 42 | void T_SC(void const *args) |
pradeepvk2208 | 0:0e52cd8d26c8 | 43 | { |
pradeepvk2208 | 0:0e52cd8d26c8 | 44 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 45 | printf("The value of i in scheduler is %d\n",schedcount); |
pradeepvk2208 | 0:0e52cd8d26c8 | 46 | if(schedcount == 65532) //to reset the counter |
pradeepvk2208 | 0:0e52cd8d26c8 | 47 | { |
pradeepvk2208 | 0:0e52cd8d26c8 | 48 | schedcount = 0; |
pradeepvk2208 | 0:0e52cd8d26c8 | 49 | } |
pradeepvk2208 | 0:0e52cd8d26c8 | 50 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 51 | if(schedcount%20==0) |
pradeepvk2208 | 0:0e52cd8d26c8 | 52 | { |
pradeepvk2208 | 0:0e52cd8d26c8 | 53 | ptr_hk_bae -> signal_set(0x1); |
pradeepvk2208 | 0:0e52cd8d26c8 | 54 | ptr_hk_cdms -> signal_set(0x2); |
pradeepvk2208 | 0:0e52cd8d26c8 | 55 | ptr_hk_payload -> signal_set(0x3); |
pradeepvk2208 | 0:0e52cd8d26c8 | 56 | } |
pradeepvk2208 | 0:0e52cd8d26c8 | 57 | schedcount++; |
pradeepvk2208 | 0:0e52cd8d26c8 | 58 | } |
pradeepvk2208 | 0:0e52cd8d26c8 | 59 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 60 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 61 | int main() |
pradeepvk2208 | 0:0e52cd8d26c8 | 62 | { |
pradeepvk2208 | 0:0e52cd8d26c8 | 63 | ptr_hk_bae = new Thread (HK_BAE); |
pradeepvk2208 | 0:0e52cd8d26c8 | 64 | ptr_hk_cdms=new Thread (HK_CDMS); |
pradeepvk2208 | 0:0e52cd8d26c8 | 65 | ptr_hk_payload=new Thread (HK_PAYLOAD); |
pradeepvk2208 | 0:0e52cd8d26c8 | 66 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 67 | ptr_hk_bae->set_priority(osPriorityAboveNormal); |
pradeepvk2208 | 0:0e52cd8d26c8 | 68 | ptr_hk_cdms->set_priority(osPriorityHigh); |
pradeepvk2208 | 0:0e52cd8d26c8 | 69 | ptr_hk_payload->set_priority(osPriorityNormal); |
pradeepvk2208 | 0:0e52cd8d26c8 | 70 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 71 | printf("\n T_HK_BAE priority is %d",ptr_hk_bae->get_priority()); |
pradeepvk2208 | 0:0e52cd8d26c8 | 72 | printf("\n T_HK_CDMS priority is %d",ptr_hk_cdms->get_priority()); |
pradeepvk2208 | 0:0e52cd8d26c8 | 73 | printf("\n T_HK_PAYLOAD priority is %d",ptr_hk_payload->get_priority()); |
pradeepvk2208 | 0:0e52cd8d26c8 | 74 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 75 | RtosTimer t_sc_timer(T_SC,osTimerPeriodic); |
pradeepvk2208 | 0:0e52cd8d26c8 | 76 | t_sc_timer.start(1000); |
pradeepvk2208 | 0:0e52cd8d26c8 | 77 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 78 | while(1) |
pradeepvk2208 | 0:0e52cd8d26c8 | 79 | { |
pradeepvk2208 | 0:0e52cd8d26c8 | 80 | Thread::wait(5000); |
pradeepvk2208 | 0:0e52cd8d26c8 | 81 | } |
pradeepvk2208 | 0:0e52cd8d26c8 | 82 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 83 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 84 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 85 | } |
pradeepvk2208 | 0:0e52cd8d26c8 | 86 | |
pradeepvk2208 | 0:0e52cd8d26c8 | 87 |