hi

Dependencies:   FreescaleIAP mbed-rtos mbed

Committer:
cholletisaik777
Date:
Wed Dec 16 09:06:59 2015 +0000
Revision:
0:bcbd76c86cde
nnb

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cholletisaik777 0:bcbd76c86cde 1 #include "mbed.h"
cholletisaik777 0:bcbd76c86cde 2 #include "rtos.h"
cholletisaik777 0:bcbd76c86cde 3 #include "pinconfig.h"
cholletisaik777 0:bcbd76c86cde 4 #include "cdms_sd.h"
cholletisaik777 0:bcbd76c86cde 5 #include "structure.h"
cholletisaik777 0:bcbd76c86cde 6 #include "i2c.h"
cholletisaik777 0:bcbd76c86cde 7 #include "cdms_rtc.h"
cholletisaik777 0:bcbd76c86cde 8 #include "main_funcs.h"
cholletisaik777 0:bcbd76c86cde 9 #include "TMTC.h"
cholletisaik777 0:bcbd76c86cde 10
cholletisaik777 0:bcbd76c86cde 11 Serial pc(USBTX,USBRX);
cholletisaik777 0:bcbd76c86cde 12
cholletisaik777 0:bcbd76c86cde 13 Thread *ptr_t_sc_data;
cholletisaik777 0:bcbd76c86cde 14 Thread *ptr_t_tmtc;
cholletisaik777 0:bcbd76c86cde 15
cholletisaik777 0:bcbd76c86cde 16 InterruptIn pl_sc_data(PIN81);
cholletisaik777 0:bcbd76c86cde 17
cholletisaik777 0:bcbd76c86cde 18 /* only for sd testing*/
cholletisaik777 0:bcbd76c86cde 19 uint8_t write_to_sd[512];
cholletisaik777 0:bcbd76c86cde 20 uint8_t read_from_sd[512];
cholletisaik777 0:bcbd76c86cde 21 /*end*/
cholletisaik777 0:bcbd76c86cde 22
cholletisaik777 0:bcbd76c86cde 23 Base_tc *tc_test = new Long_tc;
cholletisaik777 0:bcbd76c86cde 24 Base_tm *tm_test = new Long_tm;
cholletisaik777 0:bcbd76c86cde 25
cholletisaik777 0:bcbd76c86cde 26 void TSC_HK_BAE_CDMS_PL_MODE(void const *args)
cholletisaik777 0:bcbd76c86cde 27 {
cholletisaik777 0:bcbd76c86cde 28 BAE_HK();
cholletisaik777 0:bcbd76c86cde 29 CDMS_HK();
cholletisaik777 0:bcbd76c86cde 30 PL_MODE();
cholletisaik777 0:bcbd76c86cde 31 }
cholletisaik777 0:bcbd76c86cde 32
cholletisaik777 0:bcbd76c86cde 33 void BAE_HK()
cholletisaik777 0:bcbd76c86cde 34 {
cholletisaik777 0:bcbd76c86cde 35 printf("\n\rBAE_HK Function Executed\r\n");
cholletisaik777 0:bcbd76c86cde 36 }
cholletisaik777 0:bcbd76c86cde 37
cholletisaik777 0:bcbd76c86cde 38 void CDMS_HK()
cholletisaik777 0:bcbd76c86cde 39 {
cholletisaik777 0:bcbd76c86cde 40 printf("\n\rCDMS_HK Function Executed\r\n");
cholletisaik777 0:bcbd76c86cde 41 uint64_t time = FCTN_CDMS_RD_RTC();
cholletisaik777 0:bcbd76c86cde 42 printf("\n\r0x%016llx\n\r", time);
cholletisaik777 0:bcbd76c86cde 43 disk_write(write_to_sd,4);
cholletisaik777 0:bcbd76c86cde 44 disk_read(read_from_sd,4);
cholletisaik777 0:bcbd76c86cde 45 for(int i=0;i<512;i++)
cholletisaik777 0:bcbd76c86cde 46 {
cholletisaik777 0:bcbd76c86cde 47 printf("%d",read_from_sd[i]);
cholletisaik777 0:bcbd76c86cde 48 }
cholletisaik777 0:bcbd76c86cde 49 }
cholletisaik777 0:bcbd76c86cde 50
cholletisaik777 0:bcbd76c86cde 51 void PL_MODE()
cholletisaik777 0:bcbd76c86cde 52 {
cholletisaik777 0:bcbd76c86cde 53 printf("\n\rPL_MODE Function Executed\r\n");
cholletisaik777 0:bcbd76c86cde 54 ptr_t_tmtc->signal_set(0x3);
cholletisaik777 0:bcbd76c86cde 55 }
cholletisaik777 0:bcbd76c86cde 56
cholletisaik777 0:bcbd76c86cde 57 void T_CDMS_RLY_TMTC(void const *args)
cholletisaik777 0:bcbd76c86cde 58 {
cholletisaik777 0:bcbd76c86cde 59 while(1)
cholletisaik777 0:bcbd76c86cde 60 {
cholletisaik777 0:bcbd76c86cde 61 Thread::signal_wait(0x3);
cholletisaik777 0:bcbd76c86cde 62 printf("\rin T_CDMS_RLY_TM\r\n");
cholletisaik777 0:bcbd76c86cde 63 tc_test->TC_string[0] = 43;
cholletisaik777 0:bcbd76c86cde 64 tc_test->TC_string[1] = 81;
cholletisaik777 0:bcbd76c86cde 65 tc_test->TC_string[2] = 97;
cholletisaik777 0:bcbd76c86cde 66 tc_test->TC_string[3] = 80;
cholletisaik777 0:bcbd76c86cde 67 for(int i=4;i < 135 ; i++)
cholletisaik777 0:bcbd76c86cde 68 tc_test->TC_string[i] = 43;
cholletisaik777 0:bcbd76c86cde 69 printf("%s", tc_test->TC_string);
cholletisaik777 0:bcbd76c86cde 70 tm_test = FCTN_CDMS_RLY_TMTC(tc_test);
cholletisaik777 0:bcbd76c86cde 71 printf("%s", tm_test->TM_string);
cholletisaik777 0:bcbd76c86cde 72 // for(int i =0;i<134;i++)\
cholletisaik777 0:bcbd76c86cde 73 // {
cholletisaik777 0:bcbd76c86cde 74 // printf("ack");
cholletisaik777 0:bcbd76c86cde 75 // printf("%c", tm_test->TM_string[i]);
cholletisaik777 0:bcbd76c86cde 76 // }
cholletisaik777 0:bcbd76c86cde 77 //FUNC_CDMS_RLY_TM();
cholletisaik777 0:bcbd76c86cde 78 }
cholletisaik777 0:bcbd76c86cde 79 }
cholletisaik777 0:bcbd76c86cde 80
cholletisaik777 0:bcbd76c86cde 81 void T_PL_RCV_SC_DATA(void const *args)
cholletisaik777 0:bcbd76c86cde 82 {
cholletisaik777 0:bcbd76c86cde 83 while(1)
cholletisaik777 0:bcbd76c86cde 84 {
cholletisaik777 0:bcbd76c86cde 85 Thread::signal_wait(0x1);
cholletisaik777 0:bcbd76c86cde 86 FCTN_PL_RCV_SC_DATA();
cholletisaik777 0:bcbd76c86cde 87 FCTN_COM_COMP_SC_DATA();
cholletisaik777 0:bcbd76c86cde 88 FCTN_CDMS_RD_RTC();
cholletisaik777 0:bcbd76c86cde 89 disk_write(write_to_sd,2);
cholletisaik777 0:bcbd76c86cde 90 disk_read(read_from_sd,2);
cholletisaik777 0:bcbd76c86cde 91 for(int i=0;i<512;i++)
cholletisaik777 0:bcbd76c86cde 92 {
cholletisaik777 0:bcbd76c86cde 93 printf("%d",read_from_sd[i]);
cholletisaik777 0:bcbd76c86cde 94 }
cholletisaik777 0:bcbd76c86cde 95 }
cholletisaik777 0:bcbd76c86cde 96 }
cholletisaik777 0:bcbd76c86cde 97
cholletisaik777 0:bcbd76c86cde 98 void ISR_PL_RCV_SC_DATA()
cholletisaik777 0:bcbd76c86cde 99 {
cholletisaik777 0:bcbd76c86cde 100 ptr_t_sc_data->signal_set(0x1);
cholletisaik777 0:bcbd76c86cde 101 }
cholletisaik777 0:bcbd76c86cde 102
cholletisaik777 0:bcbd76c86cde 103 void FCTN_PL_RCV_SC_DATA()
cholletisaik777 0:bcbd76c86cde 104 {
cholletisaik777 0:bcbd76c86cde 105 printf("\n\rFCTN_PL_RCV_SC_DATA Function Executed\r\n");
cholletisaik777 0:bcbd76c86cde 106 }
cholletisaik777 0:bcbd76c86cde 107
cholletisaik777 0:bcbd76c86cde 108 void FCTN_COM_COMP_SC_DATA()
cholletisaik777 0:bcbd76c86cde 109 {
cholletisaik777 0:bcbd76c86cde 110 printf("\n\rFCTN_COM_COMP_SC_DATA Function Executed\r\n");
cholletisaik777 0:bcbd76c86cde 111 }
cholletisaik777 0:bcbd76c86cde 112
cholletisaik777 0:bcbd76c86cde 113 void FCTN_CDMS_WR_SD()
cholletisaik777 0:bcbd76c86cde 114 {
cholletisaik777 0:bcbd76c86cde 115 printf("\n\rFCTN_CDMS_WR_SD Function Executed\r\n");
cholletisaik777 0:bcbd76c86cde 116 }
cholletisaik777 0:bcbd76c86cde 117
cholletisaik777 0:bcbd76c86cde 118 int main()
cholletisaik777 0:bcbd76c86cde 119 {
cholletisaik777 0:bcbd76c86cde 120 printf("\n\r CDMS Activated \r\n");
cholletisaik777 0:bcbd76c86cde 121 initialise_card();
cholletisaik777 0:bcbd76c86cde 122 disk_initialize();
cholletisaik777 0:bcbd76c86cde 123 FCTN_CDMS_INIT_RTC();
cholletisaik777 0:bcbd76c86cde 124 for(int i=0;i<512;i++)
cholletisaik777 0:bcbd76c86cde 125 {
cholletisaik777 0:bcbd76c86cde 126 write_to_sd[i] = i;
cholletisaik777 0:bcbd76c86cde 127 }
cholletisaik777 0:bcbd76c86cde 128 RtosTimer TIMER_HK_ACQ(TSC_HK_BAE_CDMS_PL_MODE,osTimerPeriodic);
cholletisaik777 0:bcbd76c86cde 129 TIMER_HK_ACQ.start(10000);
cholletisaik777 0:bcbd76c86cde 130 ptr_t_tmtc = new Thread (T_CDMS_RLY_TMTC);
cholletisaik777 0:bcbd76c86cde 131 ptr_t_sc_data = new Thread (T_PL_RCV_SC_DATA);
cholletisaik777 0:bcbd76c86cde 132 pl_sc_data.rise(&ISR_PL_RCV_SC_DATA);
cholletisaik777 0:bcbd76c86cde 133
cholletisaik777 0:bcbd76c86cde 134 while(1);
cholletisaik777 0:bcbd76c86cde 135 }