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