vr1.1
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of CDMS_RTOS_v1_1 by
main.cpp@16:7428828a5da2, 2015-07-17 (annotated)
- Committer:
- cholletisaik777
- Date:
- Fri Jul 17 06:35:40 2015 +0000
- Revision:
- 16:7428828a5da2
- Parent:
- 12:cb3ee1ac3638
COM INTEGRATION
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 | 11:d6dc9074075b | 11 | /*CDMS INIT*/ |
cholletisaik777 | 11:d6dc9074075b | 12 | void FCTN_CDMS_INIT() |
cholletisaik777 | 11:d6dc9074075b | 13 | { |
cholletisaik777 | 11:d6dc9074075b | 14 | all_flags = all_flags|CDMS_INIT_STATUS; //setting the CDMS_INIT_STATUS Flag |
cholletisaik777 | 12:cb3ee1ac3638 | 15 | |
cholletisaik777 | 12:cb3ee1ac3638 | 16 | /*Configuring pins*/ |
cholletisaik777 | 12:cb3ee1ac3638 | 17 | InterruptIn pl_sc_data(PTC3); //interrupt from payload to send science data |
cholletisaik777 | 12:cb3ee1ac3638 | 18 | InterruptIn cdms_rcv_tc(PTC12); //interrupt from comm b4 sending tc |
cholletisaik777 | 12:cb3ee1ac3638 | 19 | InterruptIn bae_tm_rcv(PTC11); //interrupt from bae b4 sending tm |
cholletisaik777 | 12:cb3ee1ac3638 | 20 | InterruptIn pl_tm_rcv(PTC10); //interrupt from bae b4 sending tm |
cholletisaik777 | 12:cb3ee1ac3638 | 21 | /*End*/ |
cholletisaik777 | 11:d6dc9074075b | 22 | |
cholletisaik777 | 11:d6dc9074075b | 23 | master.frequency(100000); //I2C master frequency initializing |
cholletisaik777 | 11:d6dc9074075b | 24 | irpt_2_slv = 1; //Interrupt pin to be pulled down in the beginning |
cholletisaik777 | 11:d6dc9074075b | 25 | |
cholletisaik777 | 11:d6dc9074075b | 26 | /*All Interrupt pin configuration*/ |
cholletisaik777 | 11:d6dc9074075b | 27 | pl_sc_data.rise(&ISR_PL_RCV_SC_DATA); |
cholletisaik777 | 11:d6dc9074075b | 28 | cdms_rcv_tc.rise(&ISR_CDMS_RLY_TC); |
cholletisaik777 | 11:d6dc9074075b | 29 | bae_tm_rcv.rise(&ISR_CDMS_RLY_TM); |
cholletisaik777 | 11:d6dc9074075b | 30 | pl_tm_rcv.rise(&ISR_CDMS_RLY_TM); |
cholletisaik777 | 11:d6dc9074075b | 31 | /*End*/ |
cholletisaik777 | 11:d6dc9074075b | 32 | |
cholletisaik777 | 11:d6dc9074075b | 33 | /*Initializing PYLD SPI*/ |
cholletisaik777 | 11:d6dc9074075b | 34 | pl_spi.format(8,3); // SPI format --> 16 bits, mode = 0 |
cholletisaik777 | 11:d6dc9074075b | 35 | pl_spi.frequency(1000000); |
cholletisaik777 | 11:d6dc9074075b | 36 | /*End*/ |
cholletisaik777 | 11:d6dc9074075b | 37 | |
cholletisaik777 | 11:d6dc9074075b | 38 | FCTN_CDMS_HK_INIT(); |
cholletisaik777 | 12:cb3ee1ac3638 | 39 | FCTN_INIT_RTC(); |
cholletisaik777 | 12:cb3ee1ac3638 | 40 | FCTN_INIT_SD(); |
cholletisaik777 | 12:cb3ee1ac3638 | 41 | all_flags = all_flags&(~CDMS_INIT_STATUS); |
cholletisaik777 | 11:d6dc9074075b | 42 | } |
cholletisaik777 | 11:d6dc9074075b | 43 | /*End*/ |
cholletisaik777 | 11:d6dc9074075b | 44 | |
cholletisaik777 | 7:c270a9e37290 | 45 | /*All Threads*/ |
cholletisaik777 | 0:d6e3d1e21484 | 46 | void T_CDMS_RLY_TC(void const *args) |
cholletisaik777 | 0:d6e3d1e21484 | 47 | { |
cholletisaik777 | 0:d6e3d1e21484 | 48 | while(1) |
cholletisaik777 | 0:d6e3d1e21484 | 49 | { |
cholletisaik777 | 0:d6e3d1e21484 | 50 | Thread::signal_wait(0x2); |
cholletisaik777 | 0:d6e3d1e21484 | 51 | pc.printf("in T_CDMS_RLY_TC\r\n"); |
cholletisaik777 | 7:c270a9e37290 | 52 | FCTN_CDMS_RLY_TC(); |
cholletisaik777 | 0:d6e3d1e21484 | 53 | } |
cholletisaik777 | 0:d6e3d1e21484 | 54 | } |
cholletisaik777 | 0:d6e3d1e21484 | 55 | |
cholletisaik777 | 0:d6e3d1e21484 | 56 | void T_CDMS_RLY_TM(void const *args) |
cholletisaik777 | 0:d6e3d1e21484 | 57 | { |
cholletisaik777 | 0:d6e3d1e21484 | 58 | while(1) |
cholletisaik777 | 0:d6e3d1e21484 | 59 | { |
cholletisaik777 | 0:d6e3d1e21484 | 60 | Thread::signal_wait(0x3); |
cholletisaik777 | 8:607ae92fa6af | 61 | pc.printf("\rin T_CDMS_RLY_TM\r\n"); |
cholletisaik777 | 7:c270a9e37290 | 62 | FCTN_CDMS_RLY_TM(); |
cholletisaik777 | 0:d6e3d1e21484 | 63 | } |
cholletisaik777 | 0:d6e3d1e21484 | 64 | } |
cholletisaik777 | 0:d6e3d1e21484 | 65 | |
cholletisaik777 | 0:d6e3d1e21484 | 66 | void T_PL_RCV_SC_DATA(void const *args) |
cholletisaik777 | 0:d6e3d1e21484 | 67 | { |
cholletisaik777 | 0:d6e3d1e21484 | 68 | while(1) |
cholletisaik777 | 0:d6e3d1e21484 | 69 | { |
cholletisaik777 | 0:d6e3d1e21484 | 70 | Thread::signal_wait(0x1); |
cholletisaik777 | 8:607ae92fa6af | 71 | pc.printf("\rin T_PL_RCV_SC_DATA\r\n"); |
cholletisaik777 | 7:c270a9e37290 | 72 | FCTN_PL_RCV_SC_DATA(); |
cholletisaik777 | 0:d6e3d1e21484 | 73 | } |
cholletisaik777 | 0:d6e3d1e21484 | 74 | } |
cholletisaik777 | 7:c270a9e37290 | 75 | /*End*/ |
cholletisaik777 | 7:c270a9e37290 | 76 | |
cholletisaik777 | 7:c270a9e37290 | 77 | /*RTOS Scheduler*/ |
cholletisaik777 | 8:607ae92fa6af | 78 | void T_SC(void const *args) |
cholletisaik777 | 0:d6e3d1e21484 | 79 | { |
cholletisaik777 | 8:607ae92fa6af | 80 | sc_timer++; |
cholletisaik777 | 8:607ae92fa6af | 81 | if(sc_timer%18==0) |
cholletisaik777 | 5:c77b49508927 | 82 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 83 | FCTN_CDMS_HK_MAIN(); |
cholletisaik777 | 5:c77b49508927 | 84 | } |
cholletisaik777 | 8:607ae92fa6af | 85 | if(sc_timer%9==0) |
cholletisaik777 | 8:607ae92fa6af | 86 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 87 | FCTN_PL_MAIN(); |
cholletisaik777 | 8:607ae92fa6af | 88 | } |
cholletisaik777 | 0:d6e3d1e21484 | 89 | } |
cholletisaik777 | 7:c270a9e37290 | 90 | /*End*/ |
cholletisaik777 | 0:d6e3d1e21484 | 91 | |
cholletisaik777 | 7:c270a9e37290 | 92 | /*All ISR's*/ |
cholletisaik777 | 0:d6e3d1e21484 | 93 | void ISR_PL_RCV_SC_DATA() |
cholletisaik777 | 0:d6e3d1e21484 | 94 | { |
cholletisaik777 | 7:c270a9e37290 | 95 | ptr_t_sc_data->signal_set(0x1); //science thread is signalled from here |
cholletisaik777 | 0:d6e3d1e21484 | 96 | } |
cholletisaik777 | 0:d6e3d1e21484 | 97 | |
cholletisaik777 | 0:d6e3d1e21484 | 98 | void ISR_CDMS_RLY_TC() |
cholletisaik777 | 0:d6e3d1e21484 | 99 | { |
cholletisaik777 | 7:c270a9e37290 | 100 | ptr_t_tc->signal_set(0x2); //TC thread is signalled from here |
cholletisaik777 | 0:d6e3d1e21484 | 101 | } |
cholletisaik777 | 0:d6e3d1e21484 | 102 | |
cholletisaik777 | 0:d6e3d1e21484 | 103 | void ISR_CDMS_RLY_TM() |
cholletisaik777 | 0:d6e3d1e21484 | 104 | { |
cholletisaik777 | 7:c270a9e37290 | 105 | ptr_t_tm->signal_set(0x3); //TM thread is signalled from here whenever a interrupt comes from |
cholletisaik777 | 0:d6e3d1e21484 | 106 | } |
cholletisaik777 | 7:c270a9e37290 | 107 | /*End*/ |
cholletisaik777 | 0:d6e3d1e21484 | 108 | |
cholletisaik777 | 7:c270a9e37290 | 109 | /*main thread*/ |
cholletisaik777 | 7:c270a9e37290 | 110 | int main() |
cholletisaik777 | 7:c270a9e37290 | 111 | { |
sakthipriya | 3:0c3f7c3fabc9 | 112 | printf("\n\r CDMS Activated \n"); |
cholletisaik777 | 11:d6dc9074075b | 113 | |
cholletisaik777 | 11:d6dc9074075b | 114 | /*Initializing the threads*/ |
cholletisaik777 | 11:d6dc9074075b | 115 | ptr_t_tc = new Thread (T_CDMS_RLY_TC); |
cholletisaik777 | 0:d6e3d1e21484 | 116 | ptr_t_tm = new Thread (T_CDMS_RLY_TM); |
cholletisaik777 | 0:d6e3d1e21484 | 117 | ptr_t_sc_data = new Thread (T_PL_RCV_SC_DATA); |
cholletisaik777 | 11:d6dc9074075b | 118 | /*End*/ |
cholletisaik777 | 0:d6e3d1e21484 | 119 | |
cholletisaik777 | 11:d6dc9074075b | 120 | RtosTimer TIMER_HK_ACQ(T_SC,osTimerPeriodic); //Initializing RTOS Timer |
cholletisaik777 | 11:d6dc9074075b | 121 | TIMER_HK_ACQ.start(1000); //1 second RTOS Timer |
cholletisaik777 | 0:d6e3d1e21484 | 122 | |
cholletisaik777 | 11:d6dc9074075b | 123 | void FCTN_CDMS_INIT(); |
pradeepvk2208 | 2:4c79b3dfef31 | 124 | |
cholletisaik777 | 0:d6e3d1e21484 | 125 | while(1); |
cholletisaik777 | 7:c270a9e37290 | 126 | } |
cholletisaik777 | 7:c270a9e37290 | 127 | /*End*/ |