Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Diff: OBSRS.h
- Revision:
- 199:9f03d6ca94c9
- Parent:
- 195:6a549c0e9287
- Child:
- 200:05ff11766d9a
diff -r 17200a427e71 -r 9f03d6ca94c9 OBSRS.h
--- a/OBSRS.h Thu Jun 30 13:01:42 2016 +0000
+++ b/OBSRS.h Thu Jun 30 21:38:54 2016 +0000
@@ -44,12 +44,12 @@
uint8_t SID ;
unsigned char buffer_112[112];
uint32_t FSC;
-uint8_t read_success = 0;
+uint16_t read_success = false;
uint16_t counter_buffer_112=0, counter_EoS=0,T_frames_sent=0;
uint16_t counter_interleavedata=0;
uint16_t counter_buffer_512=0;
uint16_t max_segments = 65415/(48+T_frames_in_segment*159);
-uint8_t ack_code = 0xA0;
+uint16_t ack_code = 0xA0;
uint8_t segments_sent = 0;
uint8_t counter_SCH40 = 0;
uint8_t counter_FCCH80 = 0;
@@ -92,7 +92,19 @@
}
void restart_adf(){
-
+ /*go to phy off and and py on then phy TX again */
+ gCS_ADF = 0;
+ spi.write(0xB1);/*phy_on */
+ gCS_ADF = 1;
+ gCS_ADF = 0;
+ spi.write(0xB0);/*phy_off */
+ gCS_ADF = 1;
+ gCS_ADF = 0;
+ spi.write(0xB1);/*phy_on */
+ gCS_ADF = 1;
+ gCS_ADF = 0;
+ spi.write(0xB5);/*start transmission*/
+ gCS_ADF = 1;
}
int diff_prev;
@@ -107,7 +119,8 @@
}
#define check_PA_temp {\
-/* return 0 or 1*/\
+/* pending temperature check function*/\
+/* return 0 or 1*/\
PA_HOT=0;\
}
@@ -138,7 +151,7 @@
enable_FCCH = false;\
enable_DS = false;\
half_buffer = 0;\
- read_success = 0;\
+ read_success = false;\
counter_buffer_112=0;\
counter_EoS=0;\
T_frames_sent=0;\
@@ -201,7 +214,6 @@
TM_sent =false;\
T_frames_sent = T_frames_sent +2;\
if(repeat_last_2T_frames){\
- memset(interleave_data, 0, sizeof(interleave_data));\
enable_SCH = true;\
/*gPC.printf("repeated last 2 tframes\r\n");*/\
/*cout<<"T_frames_sent = "<<T_frames_sent<<ENDL;*/\
@@ -248,6 +260,7 @@
enable_ackandcallsign = false;\
stop =true;\
last_buffer = true;\
+ send_EoS_and_stop = false;\
}\
}\
else if(adf_limit){\
@@ -273,7 +286,7 @@
if(counter_S_frame == 48){\
enable_new_segment=false;\
counter_S_frame = 0;\
- /*cout<<"S_frame_sent"<<ENDL;*/\
+ gPC.printf("S_frame_sent\r\n");\
if(new_OBSRS_TC){\
enable_call_sign = true;\
new_OBSRS_TC = false;\
@@ -427,6 +440,9 @@
enable_read_block = false;
enable_T_frame = false;
enable_ackandcallsign = true;
+ /*putting execution status */
+ uint8_t temp2 = TC_STATE_SUCCESSFULLY_EXECUTED;
+ PUTexec_status(current_obsrs_tc, temp2);
create_Ack_andcallsign = true;
if(T_frames_sent == T_frames_in_segment){
if(segments_sent + 1>= max_segments){
@@ -501,16 +517,13 @@
if(create_Ack_andcallsign){
/* gPC.printf("cr ack\r\n");*/
enable_SCH = true;
- uint8_t temp2 = TC_STATE_SUCCESSFULLY_EXECUTED; // see all the possible cases
- PUTexec_status(current_obsrs_tc, temp2);
+
if( (GETexec_status(current_obsrs_tc) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_obsrs_tc) == 1) ){
gMASTER_STATE = TCL_STATE_ABORTED;
}
else if( GETpacket_seq_count(current_obsrs_tc) == (gTOTAL_VALID_TC-1) ){
gMASTER_STATE = TCL_STATE_COMPLETED;
}
-
-
create_Ack_andcallsign = false;
Base_tm *ack_and_callsign = NULL;
Base_tm *ack_head = NULL;
@@ -545,6 +558,14 @@
/* gPC.printf("ex cr ack\r\n");*/
}
send_Ack_andcallsign;
+ if(last_buffer){
+ // delete ack_head;
+// while(ack_and_callsign != NULL){
+// Base_tm *temp = ack_and_callsign->next_TM;
+// delete ack_and_callsign;
+// ack_and_callsign = temp;
+ }
+
}
else if(last_buffer){
// delete ack_head;
@@ -578,15 +599,12 @@
// for(int i=0;i<512;i++){
// printf("0x%02X,",write_buffer[i]);
// }
- int write_success = SD_WRITE(write_buffer,FSC + block_counter,SID);
+ //int write_success = SD_WRITE(write_buffer,FSC + block_counter,SID);
// wait_ms(8);
- ack_code = SD_READ(buffer_512, FSC + block_counter,SID);
- for(int i = 0; i<512;i++)
- if(write_buffer[i] != buffer_512[i])
- gPC.printf("incorrect");
-
- gPC.printf("read block %d \n\r",read_success);
- }
+ //ack_code = SD_READ(buffer_512, FSC + block_counter,SID);
+/* gPC.printf("read block %d \n\r",read_success);*/
+ ack_code = 0xA0;
+ }
else{
ack_code = SD_READ(buffer_512, list_of_FSC[block_counter],SID);
}
@@ -596,7 +614,7 @@
}
enable_read_block = false;
if(ack_code == 0xA0){
- gPC.puts("read one block successfully");
+ /*gPC.puts("read one block successfully")*/;
enable_T_frame = true;
enable_SCH = true;
}
@@ -620,6 +638,8 @@
}
}
if((PA_HOT || (!valid_SID)|| (gFLAGS & COM_SESSION_TIMEOUT_FLAG) ||(read_success != 0))&&(!enable_ackandcallsign)){
+ uint8_t temp2 = TC_STATE_EXECUTION_FAILED;
+ PUTexec_status(current_obsrs_tc, temp2);
enable_ackandcallsign = true;
create_Ack_andcallsign = true;
enable_T_frame = false;
