vr1.1

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of CDMS_RTOS_v1_1 by Team Fox

Committer:
cholletisaik777
Date:
Mon Jul 06 06:25:14 2015 +0000
Revision:
11:d6dc9074075b
Parent:
9:7ff6d75cc09e
Child:
12:cb3ee1ac3638
changes made

Who changed what in which revision?

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