
FM
Dependencies: SimpleDMA eeprom mbed-rtos mbed FreescaleIAP
Fork of CDMS_CODE by
Revision 353:e1803e801e20, committed 2017-02-21
- Comitter:
- samp1234
- Date:
- Tue Feb 21 06:30:56 2017 +0000
- Parent:
- 352:022c513aee03
- Child:
- 354:0da912441c7b
- Commit message:
- with all final changes
Changed in this revision
--- a/CDMS_HK.h Mon Feb 06 16:36:46 2017 +0000 +++ b/CDMS_HK.h Tue Feb 21 06:30:56 2017 +0000 @@ -60,7 +60,7 @@ hk_count--; gPC.printf("releasing mutex for HK_PL \n\r"); SCI_LED1 =0; - PL_GPIO_1_STATUS=0; + PL_GPIO_3_STATUS=0; gMutex.unlock(); continue; } else if(hk_count == 0) { @@ -107,7 +107,9 @@ // Here: Have to FIT flash data. CDMS_HEALTH_DATA[106] = (EPS_V_A_EN_STATUS<<7) | ((BAE_STATUS<<5)&0x60) | ((SD_STATUS<<3)&0x18) | ((PL_STATUS<<1)&0x06) | (PL_EPS_LATCH_SW_EN & 0x01); - CDMS_HEALTH_DATA[107] = (RTC_INIT_STATUS<<6) | ((CDMS_RTC_DISABLE<<5)&0x20); + // CDMS_HEALTH_DATA[107] = (RTC_INIT_STATUS<<6) | ((CDMS_RTC_DISABLE<<5)&0x20); + CDMS_HEALTH_DATA[107] = (RTC_INIT_STATUS<<6) | ((EN_RTC<<5)&0x20); // changed by samp + gPC.printf("\n\r 0x%08X",EN_RTC); CDMS_HEALTH_DATA[108] = CDMS_RESET_COUNTER >>8; CDMS_HEALTH_DATA[109] = CDMS_RESET_COUNTER; CDMS_HEALTH_DATA[110] = TIME_LATEST_CDSMS_RESET >>24; @@ -273,7 +275,7 @@ beacon_array[132] = crc; beacon_array[133] = crc >> 8; bool y; - y = FCTN_I2C_WRITE((char *)beacon_array,134); + y = FCTN_I2C_WRITE((char *)beacon_array,135); //134 if(y == 0) { TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7; //gPC.printf("long Bcn sent\n\r");
--- a/COM_MNG_TMTC.h Mon Feb 06 16:36:46 2017 +0000 +++ b/COM_MNG_TMTC.h Tue Feb 21 06:30:56 2017 +0000 @@ -362,6 +362,7 @@ //BAE_TC; gPC.printf("Telecommand is for BAE\r\n"); //gPC.printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae + // wait_ms(100); y = FCTN_I2C_WRITE((char*)tc_ptr->TC_string,TC_LONG_SIZE); // Check for SHORT and LONG TC and then send if(y==1) @@ -858,16 +859,17 @@ { //gPC.printf("TC_RST_BAE\r\n"); // call PWR_SWCH_ON function - RST_BAE(); + SW_RST_BAE(); Base_tm *tm_ptr_short = new Short_tm; ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr)); return tm_ptr_short; } + else if(GETpid(tc_ptr)==0x34) { //gPC.printf("TC_RST_PL_BEE\r\n"); // call PWR_SWCH_ON function - - RST_PL_BEE(); + SW_RST_PL_BEE(); + // RST_PL_BEE(); Base_tm *tm_ptr_short = new Short_tm; ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr)); return tm_ptr_short; @@ -880,6 +882,26 @@ Base_tm *tm_ptr_short = new Short_tm; ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr)); } + // added by samp starts here + else if(GETpid(tc_ptr)==0x39) + { + //gPC.printf("TC_RST_BAE\r\n"); // call PWR_SWCH_ON function + + RST_BAE(); + Base_tm *tm_ptr_short = new Short_tm; + ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x3b) + { + //gPC.printf("TC_RST_BAE\r\n"); // call PWR_SWCH_ON function + + RST_PL_BEE(); + Base_tm *tm_ptr_short = new Short_tm; + ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + // added by samp ends here else if(GETpid(tc_ptr)==0x40) { //gPC.printf("RESET_HK_COUNTER\r\n"); // call PWR_SWCH_ON function @@ -1123,6 +1145,7 @@ int poll=0; while(poll<2000 && PL_I2C_Intr==0) { + // gPC.printf("\n\rPL_I2C_Intr is low"); wait_us(10); poll+=1; }
--- a/COM_POWER_ON_TX.h Mon Feb 06 16:36:46 2017 +0000 +++ b/COM_POWER_ON_TX.h Tue Feb 21 06:30:56 2017 +0000 @@ -219,7 +219,7 @@ gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ } } - gPC.puts("swd off BAE\r\n"); + gPC.puts("swd off BCN\r\n"); COM_TX_CNTRL = 1; COM_DATA_fromuC_ENAIN = 1; COM_DATA_fromISO_ENAOUT=1;
--- a/Compression.h Mon Feb 06 16:36:46 2017 +0000 +++ b/Compression.h Tue Feb 21 06:30:56 2017 +0000 @@ -2832,7 +2832,7 @@ position_tm_frame[id] = position_tm_starting[id]; } #endif - //gPC.printf("fsc = %u, %u,%u\n\r", FSC_CURRENT[1],FSC_CURRENT[2],FSC_CURRENT[3]); + gPC.printf("fsc = %u, %u,%u\n\r", FSC_CURRENT[1],FSC_CURRENT[2],FSC_CURRENT[3]); #if test_science dma_packets_info(); #endif
--- a/DefinitionsAndGlobals.h Mon Feb 06 16:36:46 2017 +0000 +++ b/DefinitionsAndGlobals.h Tue Feb 21 06:30:56 2017 +0000 @@ -289,9 +289,9 @@ DigitalIn COMRX_OC_FAULT (PIN68); //DigitalIn COMTX_OC_FAULT (PIN69); DigitalIn BAE_OC_FAULT (PIN92); -DigitalOut PL_GPIO_1_STATUS (PIN71,1); // PYLD EPS CNTRL Signal1 / PYLD_EPS_CNTRL_SIG1 +DigitalOut PL_GPIO_1_STATUS (PIN71); // PYLD EPS CNTRL Signal1 / PYLD_EPS_CNTRL_SIG1 DigitalOut PL_GPIO_2_STATUS (PIN81);//PYLD EPS CNTRL 2 / PYLD_EPS_CNTRL_2 -DigitalOut PL_GPIO_3_STATUS (PIN80);// PYLD EPS CNTRL 3 / PYLD_EPS_CNTRL_3 +DigitalOut PL_GPIO_3_STATUS (PIN80,1);// PYLD EPS CNTRL 3 / PYLD_EPS_CNTRL_3 DigitalIn PL_BEE_SW_OC_FAULT (PIN91); DigitalIn PL_EPS_LATCH_SW_OC_FAULT (PIN5); //DigitalOut EPS_V_C_EN_STATUS (PIN72,1);//COMM RX PWR CNTRL
--- a/EEPROM.h Mon Feb 06 16:36:46 2017 +0000 +++ b/EEPROM.h Tue Feb 21 06:30:56 2017 +0000 @@ -6,7 +6,7 @@ #define check 10 EEPROM e2prom(ee_sda, ee_scl, 0, EEPROM::T24C512); -int32_t INITIAL_EEPROM[32] = {1,1,1,1,1,0,0,0,0,35001,0xff,300,85,20,20,3,80000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +int32_t INITIAL_EEPROM[32] = {1,1,1,1,1,0,0,0,0,35001,0xff,300,85,20,20,3,8000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; uint32_t flasharray_thres[32]; void WRITE_TO_EEPROM(uint32_t address, int32_t data_block) @@ -34,10 +34,10 @@ void INIT_EEPROM() { - int32_t test_buffer; - e2prom.ready(); - e2prom.read(2,test_buffer); - if(test_buffer == 0) + // int32_t test_buffer; + // e2prom.ready(); + // e2prom.read(2,test_buffer); + /* if(test_buffer == 0) { for(int i=0;i<32;i++) WRITE_TO_EEPROM( i, INITIAL_EEPROM[i]); @@ -45,7 +45,7 @@ e2prom.write(2,1); gPC.printf("starting flash"); } - + */ gPC.printf("Reading intial parametrs from flash\n"); EPS_V_A_EN_STATUS = READ_FROM_EERPOM(0); // ok BAE_STATUS = READ_FROM_EERPOM(1); //ok @@ -53,7 +53,8 @@ PL_STATUS = READ_FROM_EERPOM(3); //ok PL_EPS_LATCH_SW_EN = READ_FROM_EERPOM(4); //ok RTC_INIT_STATUS = READ_FROM_EERPOM(5); - // CDMS_RTC_DISABLE = READ_FROM_EERPOM(6); + CDMS_RTC_DISABLE = READ_FROM_EERPOM(6); + EN_RTC = CDMS_RTC_DISABLE&0x01; CDMS_RESET_COUNTER = READ_FROM_EERPOM(7); //ok // TIME_LATEST_CDSMS_RESET = READ_FROM_EERPOM(8); // COM_TC_BYTES_LIMIT = READ_FROM_EERPOM(9); @@ -64,6 +65,16 @@ // COM_SESSION_TIMEOUT = READ_FROM_EERPOM(14); // COM_RSSI_MIN = READ_FROM_EERPOM(15); SD_LIB_BLK_CURRENT = READ_FROM_EERPOM(16); + // added by samp + if (CDMS_RTC_DISABLE ==0) + { + gCS_RTC=0; + spi.write(0x8C); //register address with write flag + spi.write(0x40);//enabling halt bit in the seconds register + gCS_RTC=1; + + } + } #endif \ No newline at end of file
--- a/FMS_all.h Mon Feb 06 16:36:46 2017 +0000 +++ b/FMS_all.h Tue Feb 21 06:30:56 2017 +0000 @@ -107,6 +107,14 @@ gCS_RTC=0; spi.write(0x81); //register address with write flag spi.write(0x00);//disabling stop bit in the seconds register + gCS_RTC=1; + gCS_RTC=0; + spi.write(0x8C); //register address with write flag + spi.write(0x00);//enabling halt bit in the seconds register + gCS_RTC=1; + EN_RTC = 0x01; +// CDMS_RTC_DISABLE =1; + WRITE_TO_EEPROM(6,1); SPI_mutex.unlock(); gPC.printf("sw on rtc\n"); } @@ -118,6 +126,15 @@ gCS_RTC=0; spi.write(0x81); //register address with write flag spi.write(0x80);//enabling stop bit in the seconds register + gCS_RTC=1; + gCS_RTC=0; + spi.write(0x8C); //register address with write flag + spi.write(0x40);//enabling halt bit in the seconds register + gCS_RTC=1; + + EN_RTC = 0x00; +// CDMS_RTC_DISABLE = 0; + WRITE_TO_EEPROM(6,0); SPI_mutex.unlock(); gPC.printf("sw off rtc\n"); } @@ -220,10 +237,10 @@ void SW_RST_BAE() { - BAE_SW_EN_DS = 0; - wait_ms(10); - BAE_SW_EN_DS = 1; - wait_ms(100); + BAE_SW_EN_DS = 0; + wait(5); + BAE_SW_EN_DS = 1; + BAE_STATUS = DEVICE_POWERED; WRITE_TO_EEPROM(1,DEVICE_POWERED); gPC.printf("rst bae\n");
--- a/ThreadsAndFunctions.h Mon Feb 06 16:36:46 2017 +0000 +++ b/ThreadsAndFunctions.h Tue Feb 21 06:30:56 2017 +0000 @@ -53,7 +53,7 @@ //gPAY_SPI->bulkRead_resume(&payload_isr_fun); } // DMA_LED1 = !DMA_LED1; // added by samp - + //__disable_irq(); srp(gPAYLOAD_BUFFER);//skip one apcket when cdms resets uint8_t sd_stat1 = 0; @@ -85,6 +85,7 @@ gPC.printf("\n\rDMA error");*/ gPC.printf("\r\nreleasing mutex for Sci\n\r"); DMA_LED1 =0; + //__enable_irq(); gMutex.unlock(); } } @@ -194,7 +195,7 @@ // DISABLE THREADS HK_counter->stop(); gPAY_SPI->bulkRead_pause(); - PL_GPIO_1_STATUS=1; + PL_GPIO_3_STATUS=1; gFLAGS = gFLAGS | COM_SESSION_FLAG; gSESSION_TIMEOUT.attach(&after_session, COM_SESSION_TIMEOUT); gFLAGS = gFLAGS | COM_RX_FLAG;
--- a/i2c.h Mon Feb 06 16:36:46 2017 +0000 +++ b/i2c.h Tue Feb 21 06:30:56 2017 +0000 @@ -139,17 +139,20 @@ { // gPC.printf("i2C_wr\r\n"); CDMS_I2C_GPIO = 1; + wait_us(1); write_ack = master.write(addr_bae|0x00,data,tc_len2); Thread::wait(1); //As per the tests Thread::wait is not required on master side but its safe to give 1ms pdirw1=PTE->PDIR; uint8_t i2c_count = 0; if(write_ack == 0) { + gPC.printf("\n\r before count loop"); while(((pdirw1 & 0x03000000)!=0x03000000)&& i2c_count<10) { Thread::wait(1); pdirw1=PTE->PDIR; i2c_count++; + } if(((pdirw1 & 0x03000000)==0x03000000)) {
--- a/main.cpp Mon Feb 06 16:36:46 2017 +0000 +++ b/main.cpp Tue Feb 21 06:30:56 2017 +0000 @@ -84,6 +84,7 @@ gCS_RTC = 1; gCS_ADF = 1; + // CDMS_RTC_DISABLE = 1; FCTN_CDMS_INIT_RTC();/* rtc initialization*/ FCTN_CDMS_SD_INIT();/* sd card initialization*/ @@ -93,13 +94,13 @@ WRITE_TO_EEPROM(7,CDMS_RESET_COUNTER); TIME_LATEST_CDSMS_RESET = FCTN_CDMS_RD_RTC() >> 7; WRITE_TO_EEPROM(8,TIME_LATEST_CDSMS_RESET); - /* + uint8_t test[512]; for(int i =0; i<512; i++) test[i] = 0; disk_write(test,8000); - */ + //SD_MNG_SECT = SD_LIB_BLK_CURRENT; FCTN_SD_MNGR();