diff Discovery/Src/tHome.c @ 208:9fc06e1e0f66 ImprovmentSPI

Update SPI error display and handling For easier identification of a communication problem the RX state of Main and RTE is displayed in the debug view. Also error reactions are now handles based on this state. E.g. RTE resets its DMA incase Main reports a data shift which can not be resolved by Main itself In addition the timeout for error detection has been decreased to have a faster reaction
author ideenmodellierer
date Sun, 24 Mar 2019 22:57:28 +0100
parents cdbdb4458520
children b2a9e9b02df0
line wrap: on
line diff
--- a/Discovery/Src/tHome.c	Sun Mar 24 22:53:17 2019 +0100
+++ b/Discovery/Src/tHome.c	Sun Mar 24 22:57:28 2019 +0100
@@ -425,12 +425,15 @@
 
 uint8_t tHome_show_lost_connection_count(GFX_DrawCfgScreen *ScreenToWriteOn)
 {
+	static uint8_t LastKnowRTEState = SPI_RX_STATE_INVALID;
+
 	if(!SPI_MIN_ERROR_SHOW) return 0;
 	if(DataEX_lost_connection_count()>=SPI_MIN_ERROR_SHOW && SPI_SHOW_SYNC_STATS){
 
     char text[64];
 
     SDataExchangeSlaveToMaster* dataIn=get_dataInPointer();
+    SDataReceiveFromMaster* pDataOut = dataOutGetPointer();
 
     snprintf(text,32,"spi err:\002 %i/%i",DataEX_lost_connection_count(),get_num_SPI_CALLBACKS());
     Gfx_write_label_var(ScreenToWriteOn,  100,300, 0,&FontT24,CLUT_ButtonSymbols,text);
@@ -438,7 +441,18 @@
 //    snprintf(text,32,"header:\002%X%X%X%X",dataIn->header.checkCode[0],dataIn->header.checkCode[1],dataIn->header.checkCode[2],dataIn->header.checkCode[3]);
 //    Gfx_write_label_var(ScreenToWriteOn,  350,550, 0,&FontT24,CLUT_ButtonSymbols,text);
 
-    snprintf(text,32,"footer:\002%X%X%X%X",dataIn->footer.checkCode[0],dataIn->footer.checkCode[1],dataIn->footer.checkCode[2],dataIn->footer.checkCode[3]);
+    //snprintf(text,32,"footer:\002%X%X%X%X",dataIn->footer.checkCode[0],dataIn->footer.checkCode[1],dataIn->footer.checkCode[2],dataIn->footer.checkCode[3]);
+
+    /* data shifted => ignore received data */
+    if((pDataOut->header.checkCode[SPI_HEADER_INDEX_RX_STATE] == SPI_RX_STATE_SHIFTED) || (pDataOut->header.checkCode[SPI_HEADER_INDEX_RX_STATE] == SPI_RX_STATE_OFFLINE))
+    {
+    	dataIn->header.checkCode[SPI_HEADER_INDEX_RX_STATE] = LastKnowRTEState;
+    }
+    else
+    {
+    	LastKnowRTEState =dataIn->header.checkCode[SPI_HEADER_INDEX_RX_STATE];
+    }
+    snprintf(text,32,"RX State M|R:\002%X|%X",pDataOut->header.checkCode[SPI_HEADER_INDEX_RX_STATE], dataIn->header.checkCode[SPI_HEADER_INDEX_RX_STATE] );
     Gfx_write_label_var(ScreenToWriteOn,  600,800, 0,&FontT24,CLUT_ButtonSymbols,text);
     }