vr1.1
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of CDMS_RTOS_v1_1 by
main.cpp@8:607ae92fa6af, 2015-07-04 (annotated)
- Committer:
- cholletisaik777
- Date:
- Sat Jul 04 08:56:34 2015 +0000
- Revision:
- 8:607ae92fa6af
- Parent:
- 7:c270a9e37290
- Child:
- 9:7ff6d75cc09e
cdms_rtos_v1_0_3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cholletisaik777 | 7:c270a9e37290 | 1 | /*Header Files*/ |
cholletisaik777 | 0:d6e3d1e21484 | 2 | #include "mbed.h" |
cholletisaik777 | 0:d6e3d1e21484 | 3 | #include "rtos.h" |
cholletisaik777 | 8:607ae92fa6af | 4 | #include "main.h" |
cholletisaik777 | 8:607ae92fa6af | 5 | #include "Flags.h" |
cholletisaik777 | 8:607ae92fa6af | 6 | #include "all_funcs.h" |
cholletisaik777 | 7:c270a9e37290 | 7 | /*End*/ |
cholletisaik777 | 0:d6e3d1e21484 | 8 | |
cholletisaik777 | 8:607ae92fa6af | 9 | Serial pc(USBTX, USBRX); |
cholletisaik777 | 0:d6e3d1e21484 | 10 | |
cholletisaik777 | 7:c270a9e37290 | 11 | /*All Threads*/ |
cholletisaik777 | 0:d6e3d1e21484 | 12 | void T_CDMS_RLY_TC(void const *args) |
cholletisaik777 | 0:d6e3d1e21484 | 13 | { |
cholletisaik777 | 0:d6e3d1e21484 | 14 | while(1) |
cholletisaik777 | 0:d6e3d1e21484 | 15 | { |
cholletisaik777 | 0:d6e3d1e21484 | 16 | Thread::signal_wait(0x2); |
cholletisaik777 | 0:d6e3d1e21484 | 17 | pc.printf("in T_CDMS_RLY_TC\r\n"); |
cholletisaik777 | 7:c270a9e37290 | 18 | FCTN_CDMS_RLY_TC(); |
cholletisaik777 | 0:d6e3d1e21484 | 19 | } |
cholletisaik777 | 0:d6e3d1e21484 | 20 | } |
cholletisaik777 | 0:d6e3d1e21484 | 21 | |
cholletisaik777 | 0:d6e3d1e21484 | 22 | void T_CDMS_RLY_TM(void const *args) |
cholletisaik777 | 0:d6e3d1e21484 | 23 | { |
cholletisaik777 | 0:d6e3d1e21484 | 24 | while(1) |
cholletisaik777 | 0:d6e3d1e21484 | 25 | { |
cholletisaik777 | 0:d6e3d1e21484 | 26 | Thread::signal_wait(0x3); |
cholletisaik777 | 8:607ae92fa6af | 27 | pc.printf("\rin T_CDMS_RLY_TM\r\n"); |
cholletisaik777 | 7:c270a9e37290 | 28 | FCTN_CDMS_RLY_TM(); |
cholletisaik777 | 0:d6e3d1e21484 | 29 | } |
cholletisaik777 | 0:d6e3d1e21484 | 30 | } |
cholletisaik777 | 0:d6e3d1e21484 | 31 | |
cholletisaik777 | 0:d6e3d1e21484 | 32 | void T_PL_RCV_SC_DATA(void const *args) |
cholletisaik777 | 0:d6e3d1e21484 | 33 | { |
cholletisaik777 | 0:d6e3d1e21484 | 34 | while(1) |
cholletisaik777 | 0:d6e3d1e21484 | 35 | { |
cholletisaik777 | 0:d6e3d1e21484 | 36 | Thread::signal_wait(0x1); |
cholletisaik777 | 8:607ae92fa6af | 37 | pc.printf("\rin T_PL_RCV_SC_DATA\r\n"); |
cholletisaik777 | 7:c270a9e37290 | 38 | FCTN_PL_RCV_SC_DATA(); |
cholletisaik777 | 0:d6e3d1e21484 | 39 | } |
cholletisaik777 | 0:d6e3d1e21484 | 40 | } |
cholletisaik777 | 7:c270a9e37290 | 41 | /*End*/ |
cholletisaik777 | 7:c270a9e37290 | 42 | |
cholletisaik777 | 7:c270a9e37290 | 43 | /*RTOS Scheduler*/ |
cholletisaik777 | 8:607ae92fa6af | 44 | void T_SC(void const *args) |
cholletisaik777 | 0:d6e3d1e21484 | 45 | { |
cholletisaik777 | 8:607ae92fa6af | 46 | sc_timer++; |
cholletisaik777 | 8:607ae92fa6af | 47 | if(sc_timer%18==0) |
cholletisaik777 | 5:c77b49508927 | 48 | { |
cholletisaik777 | 8:607ae92fa6af | 49 | FCTN_CDMS_HK_MAIN; |
cholletisaik777 | 5:c77b49508927 | 50 | } |
cholletisaik777 | 8:607ae92fa6af | 51 | if(sc_timer%9==0) |
cholletisaik777 | 8:607ae92fa6af | 52 | { |
cholletisaik777 | 8:607ae92fa6af | 53 | FCTN_PL_MAIN; |
cholletisaik777 | 8:607ae92fa6af | 54 | } |
cholletisaik777 | 0:d6e3d1e21484 | 55 | } |
cholletisaik777 | 7:c270a9e37290 | 56 | /*End*/ |
cholletisaik777 | 0:d6e3d1e21484 | 57 | |
cholletisaik777 | 7:c270a9e37290 | 58 | /*All ISR's*/ |
cholletisaik777 | 0:d6e3d1e21484 | 59 | void ISR_PL_RCV_SC_DATA() |
cholletisaik777 | 0:d6e3d1e21484 | 60 | { |
cholletisaik777 | 7:c270a9e37290 | 61 | ptr_t_sc_data->signal_set(0x1); //science thread is signalled from here |
cholletisaik777 | 0:d6e3d1e21484 | 62 | } |
cholletisaik777 | 0:d6e3d1e21484 | 63 | |
cholletisaik777 | 0:d6e3d1e21484 | 64 | void ISR_CDMS_RLY_TC() |
cholletisaik777 | 0:d6e3d1e21484 | 65 | { |
cholletisaik777 | 7:c270a9e37290 | 66 | ptr_t_tc->signal_set(0x2); //TC thread is signalled from here |
cholletisaik777 | 0:d6e3d1e21484 | 67 | } |
cholletisaik777 | 0:d6e3d1e21484 | 68 | |
cholletisaik777 | 0:d6e3d1e21484 | 69 | void ISR_CDMS_RLY_TM() |
cholletisaik777 | 0:d6e3d1e21484 | 70 | { |
cholletisaik777 | 7:c270a9e37290 | 71 | ptr_t_tm->signal_set(0x3); //TM thread is signalled from here whenever a interrupt comes from |
cholletisaik777 | 0:d6e3d1e21484 | 72 | } |
cholletisaik777 | 7:c270a9e37290 | 73 | /*End*/ |
cholletisaik777 | 0:d6e3d1e21484 | 74 | |
cholletisaik777 | 7:c270a9e37290 | 75 | /*main thread*/ |
cholletisaik777 | 7:c270a9e37290 | 76 | int main() |
cholletisaik777 | 7:c270a9e37290 | 77 | { |
sakthipriya | 3:0c3f7c3fabc9 | 78 | printf("\n\r CDMS Activated \n"); |
cholletisaik777 | 0:d6e3d1e21484 | 79 | ptr_t_tc = new Thread (T_CDMS_RLY_TC); |
cholletisaik777 | 0:d6e3d1e21484 | 80 | ptr_t_tm = new Thread (T_CDMS_RLY_TM); |
cholletisaik777 | 0:d6e3d1e21484 | 81 | ptr_t_sc_data = new Thread (T_PL_RCV_SC_DATA); |
sakthipriya | 3:0c3f7c3fabc9 | 82 | master.frequency(100000); |
cholletisaik777 | 8:607ae92fa6af | 83 | RtosTimer TIMER_HK_ACQ(T_SC,osTimerPeriodic); |
cholletisaik777 | 7:c270a9e37290 | 84 | TIMER_HK_ACQ.start(10000); |
sakthipriya | 3:0c3f7c3fabc9 | 85 | irpt_2_slv = 1; |
cholletisaik777 | 0:d6e3d1e21484 | 86 | pl_sc_data.rise(&ISR_PL_RCV_SC_DATA); |
cholletisaik777 | 0:d6e3d1e21484 | 87 | cdms_rcv_tc.rise(&ISR_CDMS_RLY_TC); |
cholletisaik777 | 0:d6e3d1e21484 | 88 | bae_tm_rcv.rise(&ISR_CDMS_RLY_TM); |
cholletisaik777 | 0:d6e3d1e21484 | 89 | pl_tm_rcv.rise(&ISR_CDMS_RLY_TM); |
cholletisaik777 | 0:d6e3d1e21484 | 90 | |
cholletisaik777 | 0:d6e3d1e21484 | 91 | pl_spi.format(8,3); // SPI format --> 16 bits, mode = 0 |
cholletisaik777 | 0:d6e3d1e21484 | 92 | pl_spi.frequency(1000000); |
cholletisaik777 | 0:d6e3d1e21484 | 93 | |
cholletisaik777 | 7:c270a9e37290 | 94 | FCTN_CDMS_HK_INIT(); |
cholletisaik777 | 7:c270a9e37290 | 95 | FCTN_INIT_RTC(); |
cholletisaik777 | 7:c270a9e37290 | 96 | int *status_sd = FCTN_INIT_SD(); |
pradeepvk2208 | 2:4c79b3dfef31 | 97 | |
cholletisaik777 | 0:d6e3d1e21484 | 98 | while(1); |
cholletisaik777 | 7:c270a9e37290 | 99 | } |
cholletisaik777 | 7:c270a9e37290 | 100 | /*End*/ |