vr1.1

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of CDMS_RTOS_v1_1 by Team Fox

Committer:
cholletisaik777
Date:
Tue Jun 16 13:06:19 2015 +0000
Revision:
4:cc85cfaa2086
Parent:
3:0c3f7c3fabc9
Child:
5:c77b49508927
WROTE SD FUNCTION

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cholletisaik777 0:d6e3d1e21484 1 #include "mbed.h"
cholletisaik777 0:d6e3d1e21484 2 #include "rtos.h"
cholletisaik777 0:d6e3d1e21484 3 #include "func_head.h"
pradeepvk2208 2:4c79b3dfef31 4 #include "i2c.h"
cholletisaik777 4:cc85cfaa2086 5 #include "SDCard.h"
cholletisaik777 0:d6e3d1e21484 6
cholletisaik777 0:d6e3d1e21484 7 Serial pc(USBTX,USBRX);
cholletisaik777 0:d6e3d1e21484 8
sakthipriya 3:0c3f7c3fabc9 9 extern SPISlave pl_spi ; // mosi, miso, sclk, ssel --> using SPI1
cholletisaik777 0:d6e3d1e21484 10
cholletisaik777 0:d6e3d1e21484 11 InterruptIn pl_sc_data(PTC3);
cholletisaik777 0:d6e3d1e21484 12 InterruptIn cdms_rcv_tc(PTC12);
sakthipriya 3:0c3f7c3fabc9 13 InterruptIn bae_tm_rcv(PTC11);
sakthipriya 3:0c3f7c3fabc9 14 InterruptIn pl_tm_rcv(PTC10);
sakthipriya 3:0c3f7c3fabc9 15 extern I2C master;
sakthipriya 3:0c3f7c3fabc9 16 extern DigitalOut irpt_2_slv;
cholletisaik777 0:d6e3d1e21484 17
sakthipriya 3:0c3f7c3fabc9 18 char i2c_data[25];
pradeepvk2208 2:4c79b3dfef31 19
cholletisaik777 0:d6e3d1e21484 20 /*****************************************************************Threads USed*************************************************************************/
cholletisaik777 0:d6e3d1e21484 21 Thread *ptr_t_hk_acq; //pointer:::::::::to read state of one thread from another
cholletisaik777 0:d6e3d1e21484 22 Thread *ptr_t_sc_data;
cholletisaik777 0:d6e3d1e21484 23 Thread *ptr_t_tc;
cholletisaik777 0:d6e3d1e21484 24 Thread *ptr_t_tm;
cholletisaik777 0:d6e3d1e21484 25 Thread *ptr_t_fault;
cholletisaik777 0:d6e3d1e21484 26 Thread *ptr_t_wdt;
cholletisaik777 0:d6e3d1e21484 27
cholletisaik777 0:d6e3d1e21484 28 void T_CDMS_RLY_TC(void const *args)
cholletisaik777 0:d6e3d1e21484 29 {
cholletisaik777 0:d6e3d1e21484 30 while(1)
cholletisaik777 0:d6e3d1e21484 31 {
cholletisaik777 0:d6e3d1e21484 32 Thread::signal_wait(0x2);
cholletisaik777 0:d6e3d1e21484 33 pc.printf("in T_CDMS_RLY_TC\r\n");
cholletisaik777 0:d6e3d1e21484 34 FUNC_CDMS_RLY_TC();
cholletisaik777 0:d6e3d1e21484 35 }
cholletisaik777 0:d6e3d1e21484 36 }
cholletisaik777 0:d6e3d1e21484 37
cholletisaik777 0:d6e3d1e21484 38 void T_CDMS_RLY_TM(void const *args)
cholletisaik777 0:d6e3d1e21484 39 {
cholletisaik777 0:d6e3d1e21484 40 while(1)
cholletisaik777 0:d6e3d1e21484 41 {
cholletisaik777 0:d6e3d1e21484 42 Thread::signal_wait(0x3);
cholletisaik777 0:d6e3d1e21484 43 pc.printf("in T_CDMS_RLY_TM\r\n");
cholletisaik777 0:d6e3d1e21484 44 FUNC_CDMS_RLY_TM();
cholletisaik777 0:d6e3d1e21484 45 }
cholletisaik777 0:d6e3d1e21484 46 }
cholletisaik777 0:d6e3d1e21484 47
cholletisaik777 0:d6e3d1e21484 48 void T_PL_RCV_SC_DATA(void const *args)
cholletisaik777 0:d6e3d1e21484 49 {
cholletisaik777 0:d6e3d1e21484 50 while(1)
cholletisaik777 0:d6e3d1e21484 51 {
cholletisaik777 0:d6e3d1e21484 52 Thread::signal_wait(0x1);
cholletisaik777 0:d6e3d1e21484 53 pc.printf("in T_PL_RCV_SC_DATA\r\n");
cholletisaik777 0:d6e3d1e21484 54 FUNC_PL_RCV_SC_DATA();
cholletisaik777 0:d6e3d1e21484 55 }
cholletisaik777 0:d6e3d1e21484 56 }
cholletisaik777 0:d6e3d1e21484 57
cholletisaik777 0:d6e3d1e21484 58 void TSC_CDMS_HK_MAIN(void const *args)
cholletisaik777 0:d6e3d1e21484 59 {
sakthipriya 3:0c3f7c3fabc9 60 uint8_t* rtc_data;
cholletisaik777 0:d6e3d1e21484 61 pc.printf("in FUNC_CDMS_HK_MAIN()\r\n");
pradeepvk2208 2:4c79b3dfef31 62 FCTN_MASTER_I2C('h' , i2c_data );
sakthipriya 3:0c3f7c3fabc9 63 rtc_data = FUNC_CDMS_RD_RTC();
sakthipriya 3:0c3f7c3fabc9 64 printf("\n\r rtc exited\n");
cholletisaik777 0:d6e3d1e21484 65 }
cholletisaik777 0:d6e3d1e21484 66
cholletisaik777 0:d6e3d1e21484 67 void ISR_PL_RCV_SC_DATA()
cholletisaik777 0:d6e3d1e21484 68 {
cholletisaik777 0:d6e3d1e21484 69 ptr_t_sc_data->signal_set(0x1);
cholletisaik777 0:d6e3d1e21484 70 }
cholletisaik777 0:d6e3d1e21484 71
cholletisaik777 0:d6e3d1e21484 72 void ISR_CDMS_RLY_TC()
cholletisaik777 0:d6e3d1e21484 73 {
cholletisaik777 0:d6e3d1e21484 74 ptr_t_tc->signal_set(0x2);
cholletisaik777 0:d6e3d1e21484 75 }
cholletisaik777 0:d6e3d1e21484 76
cholletisaik777 0:d6e3d1e21484 77 void ISR_CDMS_RLY_TM()
cholletisaik777 0:d6e3d1e21484 78 {
cholletisaik777 0:d6e3d1e21484 79 ptr_t_tm->signal_set(0x3);
cholletisaik777 0:d6e3d1e21484 80 }
cholletisaik777 0:d6e3d1e21484 81
cholletisaik777 0:d6e3d1e21484 82 int main() {
sakthipriya 3:0c3f7c3fabc9 83 printf("\n\r CDMS Activated \n");
cholletisaik777 0:d6e3d1e21484 84 ptr_t_tc = new Thread (T_CDMS_RLY_TC);
cholletisaik777 0:d6e3d1e21484 85 ptr_t_tm = new Thread (T_CDMS_RLY_TM);
cholletisaik777 0:d6e3d1e21484 86 ptr_t_sc_data = new Thread (T_PL_RCV_SC_DATA);
sakthipriya 3:0c3f7c3fabc9 87 master.frequency(100000);
cholletisaik777 0:d6e3d1e21484 88 RtosTimer TIMER_HK_ACQ(TSC_CDMS_HK_MAIN,osTimerPeriodic);
pradeepvk2208 2:4c79b3dfef31 89 TIMER_HK_ACQ.start(20000);
sakthipriya 3:0c3f7c3fabc9 90 irpt_2_slv = 1;
cholletisaik777 0:d6e3d1e21484 91 pl_sc_data.rise(&ISR_PL_RCV_SC_DATA);
cholletisaik777 0:d6e3d1e21484 92 cdms_rcv_tc.rise(&ISR_CDMS_RLY_TC);
cholletisaik777 0:d6e3d1e21484 93 bae_tm_rcv.rise(&ISR_CDMS_RLY_TM);
cholletisaik777 0:d6e3d1e21484 94 pl_tm_rcv.rise(&ISR_CDMS_RLY_TM);
cholletisaik777 0:d6e3d1e21484 95
cholletisaik777 0:d6e3d1e21484 96 pl_spi.format(8,3); // SPI format --> 16 bits, mode = 0
cholletisaik777 0:d6e3d1e21484 97 pl_spi.frequency(1000000);
cholletisaik777 0:d6e3d1e21484 98
pradeepvk2208 2:4c79b3dfef31 99 FUNC_INIT_RTC();
cholletisaik777 4:cc85cfaa2086 100 int *status_sd = FUNC_INIT_SD();
pradeepvk2208 2:4c79b3dfef31 101
cholletisaik777 0:d6e3d1e21484 102 while(1);
cholletisaik777 0:d6e3d1e21484 103 }