vr1.1

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of CDMS_RTOS_v1_1 by Team Fox

Committer:
cholletisaik777
Date:
Mon Jun 15 12:16:59 2015 +0000
Revision:
0:d6e3d1e21484
Child:
2:4c79b3dfef31
CDMS-RTOSv0.1

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"
cholletisaik777 0:d6e3d1e21484 4
cholletisaik777 0:d6e3d1e21484 5 Serial pc(USBTX,USBRX);
cholletisaik777 0:d6e3d1e21484 6
cholletisaik777 0:d6e3d1e21484 7 SPISlave pl_spi(PTD6, PTD7, PTD5, PTD4 ); // mosi, miso, sclk, ssel --> using SPI1
cholletisaik777 0:d6e3d1e21484 8
cholletisaik777 0:d6e3d1e21484 9 InterruptIn pl_sc_data(PTC3);
cholletisaik777 0:d6e3d1e21484 10 InterruptIn cdms_rcv_tc(PTC12);
cholletisaik777 0:d6e3d1e21484 11 InterruptIn bae_tm_rcv(PTA4);
cholletisaik777 0:d6e3d1e21484 12 InterruptIn pl_tm_rcv(PTA5);
cholletisaik777 0:d6e3d1e21484 13
cholletisaik777 0:d6e3d1e21484 14 /*****************************************************************Threads USed*************************************************************************/
cholletisaik777 0:d6e3d1e21484 15 Thread *ptr_t_hk_acq; //pointer:::::::::to read state of one thread from another
cholletisaik777 0:d6e3d1e21484 16 Thread *ptr_t_sc_data;
cholletisaik777 0:d6e3d1e21484 17 Thread *ptr_t_tc;
cholletisaik777 0:d6e3d1e21484 18 Thread *ptr_t_tm;
cholletisaik777 0:d6e3d1e21484 19 Thread *ptr_t_fault;
cholletisaik777 0:d6e3d1e21484 20 Thread *ptr_t_wdt;
cholletisaik777 0:d6e3d1e21484 21
cholletisaik777 0:d6e3d1e21484 22 void T_CDMS_RLY_TC(void const *args)
cholletisaik777 0:d6e3d1e21484 23 {
cholletisaik777 0:d6e3d1e21484 24 while(1)
cholletisaik777 0:d6e3d1e21484 25 {
cholletisaik777 0:d6e3d1e21484 26 Thread::signal_wait(0x2);
cholletisaik777 0:d6e3d1e21484 27 pc.printf("in T_CDMS_RLY_TC\r\n");
cholletisaik777 0:d6e3d1e21484 28 FUNC_CDMS_RLY_TC();
cholletisaik777 0:d6e3d1e21484 29 }
cholletisaik777 0:d6e3d1e21484 30 }
cholletisaik777 0:d6e3d1e21484 31
cholletisaik777 0:d6e3d1e21484 32 void T_CDMS_RLY_TM(void const *args)
cholletisaik777 0:d6e3d1e21484 33 {
cholletisaik777 0:d6e3d1e21484 34 while(1)
cholletisaik777 0:d6e3d1e21484 35 {
cholletisaik777 0:d6e3d1e21484 36 Thread::signal_wait(0x3);
cholletisaik777 0:d6e3d1e21484 37 pc.printf("in T_CDMS_RLY_TM\r\n");
cholletisaik777 0:d6e3d1e21484 38 FUNC_CDMS_RLY_TM();
cholletisaik777 0:d6e3d1e21484 39 }
cholletisaik777 0:d6e3d1e21484 40 }
cholletisaik777 0:d6e3d1e21484 41
cholletisaik777 0:d6e3d1e21484 42 void T_PL_RCV_SC_DATA(void const *args)
cholletisaik777 0:d6e3d1e21484 43 {
cholletisaik777 0:d6e3d1e21484 44 while(1)
cholletisaik777 0:d6e3d1e21484 45 {
cholletisaik777 0:d6e3d1e21484 46 Thread::signal_wait(0x1);
cholletisaik777 0:d6e3d1e21484 47 pc.printf("in T_PL_RCV_SC_DATA\r\n");
cholletisaik777 0:d6e3d1e21484 48 FUNC_PL_RCV_SC_DATA();
cholletisaik777 0:d6e3d1e21484 49 }
cholletisaik777 0:d6e3d1e21484 50 }
cholletisaik777 0:d6e3d1e21484 51
cholletisaik777 0:d6e3d1e21484 52 void TSC_CDMS_HK_MAIN(void const *args)
cholletisaik777 0:d6e3d1e21484 53 {
cholletisaik777 0:d6e3d1e21484 54 pc.printf("in FUNC_CDMS_HK_MAIN()\r\n");
cholletisaik777 0:d6e3d1e21484 55 }
cholletisaik777 0:d6e3d1e21484 56
cholletisaik777 0:d6e3d1e21484 57 void ISR_PL_RCV_SC_DATA()
cholletisaik777 0:d6e3d1e21484 58 {
cholletisaik777 0:d6e3d1e21484 59 ptr_t_sc_data->signal_set(0x1);
cholletisaik777 0:d6e3d1e21484 60 }
cholletisaik777 0:d6e3d1e21484 61
cholletisaik777 0:d6e3d1e21484 62 void ISR_CDMS_RLY_TC()
cholletisaik777 0:d6e3d1e21484 63 {
cholletisaik777 0:d6e3d1e21484 64 ptr_t_tc->signal_set(0x2);
cholletisaik777 0:d6e3d1e21484 65 }
cholletisaik777 0:d6e3d1e21484 66
cholletisaik777 0:d6e3d1e21484 67 void ISR_CDMS_RLY_TM()
cholletisaik777 0:d6e3d1e21484 68 {
cholletisaik777 0:d6e3d1e21484 69 ptr_t_tm->signal_set(0x3);
cholletisaik777 0:d6e3d1e21484 70 }
cholletisaik777 0:d6e3d1e21484 71
cholletisaik777 0:d6e3d1e21484 72 int main() {
cholletisaik777 0:d6e3d1e21484 73
cholletisaik777 0:d6e3d1e21484 74 ptr_t_tc = new Thread (T_CDMS_RLY_TC);
cholletisaik777 0:d6e3d1e21484 75 ptr_t_tm = new Thread (T_CDMS_RLY_TM);
cholletisaik777 0:d6e3d1e21484 76 ptr_t_sc_data = new Thread (T_PL_RCV_SC_DATA);
cholletisaik777 0:d6e3d1e21484 77
cholletisaik777 0:d6e3d1e21484 78 RtosTimer TIMER_HK_ACQ(TSC_CDMS_HK_MAIN,osTimerPeriodic);
cholletisaik777 0:d6e3d1e21484 79 TIMER_HK_ACQ.start(18000);
cholletisaik777 0:d6e3d1e21484 80
cholletisaik777 0:d6e3d1e21484 81 pl_sc_data.rise(&ISR_PL_RCV_SC_DATA);
cholletisaik777 0:d6e3d1e21484 82 cdms_rcv_tc.rise(&ISR_CDMS_RLY_TC);
cholletisaik777 0:d6e3d1e21484 83 bae_tm_rcv.rise(&ISR_CDMS_RLY_TM);
cholletisaik777 0:d6e3d1e21484 84 pl_tm_rcv.rise(&ISR_CDMS_RLY_TM);
cholletisaik777 0:d6e3d1e21484 85
cholletisaik777 0:d6e3d1e21484 86 pl_spi.format(8,3); // SPI format --> 16 bits, mode = 0
cholletisaik777 0:d6e3d1e21484 87 pl_spi.frequency(1000000);
cholletisaik777 0:d6e3d1e21484 88
cholletisaik777 0:d6e3d1e21484 89 while(1);
cholletisaik777 0:d6e3d1e21484 90 }