Repository for CDMS code
Dependencies: SimpleDMA mbed-rtos mbed eeprom
Fork of COM_MNG_TMTC_SIMPLE by
Diff: CDMS_HK.h
- Revision:
- 346:204497974293
- Parent:
- 342:77b0d59897f7
- Child:
- 348:8e6b2b4d244e
diff -r 77b0d59897f7 -r 204497974293 CDMS_HK.h --- a/CDMS_HK.h Thu Jan 05 17:38:21 2017 +0000 +++ b/CDMS_HK.h Fri Jan 13 08:00:33 2017 +0000 @@ -52,11 +52,14 @@ gHK_THREAD->signal_wait(HK_SIGNAL); gPC.printf("checking mutex in HK\n\r"); gMutex.lock(); + SCI_LED1 =1; gPC.printf("locked mutex, entered in HK \n\r"); if(hk_count == 1 || hk_count == 2) { FCTN_CDMS_PL_MAIN((void const *)NULL); hk_count--; gPC.printf("releasing mutex for HK_PL \n\r"); + SCI_LED1 =0; + PL_GPIO_1_STATUS=1; gMutex.unlock(); continue; } else if(hk_count == 0) { @@ -70,7 +73,9 @@ CDMS_HK_MAIN_STATUS = 0x01; CDMS_HK_MAIN_COUNTER++; + FCTN_CDMS_HK(); //collects temperatures + if(!COM_RSSI_SET) { RSSI_VOLTAGE = COMRX_RSSI_VOLTAGE.read() * 3.3;//to be checked @@ -126,8 +131,13 @@ gPC.printf("\t\t%d/%d/%d ",((time & 0x003E0000)>>17),((time & 0x03C00000)>>22),((time & 0x0C000000)>>26)+2016); gPC.printf("%d:%d:%d\n",((time & 0x0001F000)>>12),((time & 0x00000FC0)>>6),(time & 0x0000003F)); - - FCTN_SD_MNGR(); //Adding FSC & TMID to TM frame + if(CDMS_HK_SD_DATA_READY==1||BAE_HK_SD_DATA_READY==1) + { + FCTN_SD_MNGR(); + gPC.printf("endHK_SD"); + } + // gPC.printf("endHK_SD"); //Adding FSC & TMID to TM frame + CDMS_HK_FRAME[0] = 0x20; CDMS_HK_FRAME[1] = (FSC_CURRENT[4]+1) >> 16; CDMS_HK_FRAME[2] = (FSC_CURRENT[4]+1) >> 8; @@ -149,21 +159,31 @@ interleave(convoluted_CDMS_HK , interleave_CDMS_HK); interleave(convoluted_CDMS_HK +135, interleave_CDMS_HK + 144); //gPC.printf("\n\r reached here"); + // gPC.printf("enterdHK_SD"); + + if(CDMS_HK_SD_DATA_READY==1) + { for(int i=0; i<288; i++) CDMS_HEALTH_FINAL[i] = interleave_CDMS_HK[i]; //gPC.printf("\n\r reached here"); sd_stat = SD_WRITE(CDMS_HEALTH_FINAL,FSC_CURRENT[4]+1,4); + if(sd_stat) { gPC.puts("sd write failure $*&^@!~!"); - // break; + } } +// } + CDMS_HK_SD_DATA_READY=1; + // gPC.printf("Completed CDMS HK\t"); /*---------------------------------- BAE HK --------------------------------------------*/ - + + // gPC.printf("endHK_SD2"); BAE_HK_I2C = FCTN_I2C_READ(BAE_HK,134); - // gPC.printf("Entering BAE HK\t"); + // gPC.printf("\nEntering BAE HK\t"); if(BAE_HK_I2C == 0) { + // gPC.printf("BAE_HK_"); crc = crc16_gen((unsigned char *)BAE_HK,132); if(crc == ((uint16_t)BAE_HK[132] << 8) | (uint16_t)BAE_HK[133]) { //gPC.printf("BAE HK data recieved through I2C\t"); @@ -186,13 +206,22 @@ BAE_HEALTH.convolutionEncode(BAE_HK_FRAME + 67, convoluted_BAE_HK + 135); interleave(convoluted_BAE_HK , interleave_BAE_HK); interleave(convoluted_BAE_HK +135, interleave_BAE_HK + 144); + + // gPC.printf("enterHK_SD3"); + + if(BAE_HK_SD_DATA_READY==1) + { + for(int i=0; i<288; i++) BAE_HEALTH_FINAL[i] = interleave_BAE_HK[i]; sd_stat = SD_WRITE(BAE_HEALTH_FINAL,FSC_CURRENT[5]+1,5); if(sd_stat) { - gPC.puts("sd write failure"); + gPC.puts("BAE_HK sd write fail"); //break; } + } + BAE_HK_SD_DATA_READY = 1; + // gPC.printf("endHK_SD4"); } } else { @@ -249,7 +278,8 @@ gPC.printf("long Bcn not sent\r\n"); //gPC.printf("\rCompleted Beacon\n"); gPC.printf("\rreleasing mutex for HK_MAIN \n\r"); - gMutex.unlock(); + SCI_LED1 =0; + gMutex.unlock(); } }