diff Small_CPU/Src/spi.c @ 277:580822b5d3d1 IPC_Sync_Improvment_3

Rework SPI error handling. SPI_Start_single_TxRx_with_Master evaluated the incoming data for a condition to send device instead of life data. In case of invalid input data this may cause unintended transmission of device data => now lifedata is send if incoming data is expected to be invalid The SPI timeout monitoring was done at the beginning of the mode loop. A timeout may have been detected even if meanwhile valid data was received (this is evaluated at x20ms) => Moved the timeout monitoring after the handling of incoming data
author ideenmodellierer
date Sun, 28 Apr 2019 10:16:38 +0200
parents b3685fbada3b
children 2fc08a0d1ec3
line wrap: on
line diff
--- a/Small_CPU/Src/spi.c	Sun Apr 28 10:06:27 2019 +0200
+++ b/Small_CPU/Src/spi.c	Sun Apr 28 10:16:38 2019 +0200
@@ -358,9 +358,10 @@
 				HAL_SPI_Abort_IT(&hspi1);
 				Scheduler_Request_sync_with_SPI(SPI_SYNC_METHOD_HARD);
 			}
-			 else
-			 {
-			 }
+			else
+			{
+			}
+			SPI_Start_single_TxRx_with_Master();
 		}
 		else
 		{
@@ -386,6 +387,7 @@
 					global.dataSendToMaster.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_OFFLINE;
 					resettimeout = 0;
 				}
+				HAL_SPI_TransmitReceive_DMA(&hspi1,(uint8_t*) &(global.dataSendToMaster),(uint8_t*) &(global.dataSendToSlave), EXCHANGE_BUFFERSIZE);
 		}
 
 		global.dataSendToMaster.power_on_reset = 0;
@@ -393,8 +395,6 @@
 
 		scheduleSpecial_Evaluate_DataSendToSlave();
 
-		SPI_Start_single_TxRx_with_Master();
-
 		if(resettimeout)
 		{
 				global.check_sync_not_running = 0;