diff Small_CPU/Src/spi.c @ 267:cf6ad20380fb

Merged in Ideenmodellierer/ostc4/IPC_Sync_Improvment_2 (pull request #18) IPC Sync Improvment 2
author heinrichsweikamp <bitbucket@heinrichsweikamp.com>
date Fri, 26 Apr 2019 10:36:11 +0000
parents b3685fbada3b
children 580822b5d3d1
line wrap: on
line diff
--- a/Small_CPU/Src/spi.c	Tue Apr 23 14:21:32 2019 +0000
+++ b/Small_CPU/Src/spi.c	Fri Apr 26 10:36:11 2019 +0000
@@ -317,7 +317,15 @@
 	/* restart SPI */
 	if (hspi == &hspi1)
 	{
-		Scheduler_SyncToSPI();
+		if(SPI_check_header_and_footer_ok())	/* process timestamp provided by main */
+		{
+			Scheduler_SyncToSPI(global.dataSendToSlave.header.checkCode[SPI_HEADER_INDEX_TX_TICK]);
+		}
+		else
+		{
+			Scheduler_SyncToSPI(0); /* => no async will be calculated */
+		}
+
 		SPIDataRX = 1;
 
 		/* stop data exchange? */
@@ -330,9 +338,10 @@
 	}
 }
 
-void SPI_Evaluate_RX_Data()
+uint8_t SPI_Evaluate_RX_Data()
 {
 	uint8_t resettimeout = 1;
+	uint8_t ret = SPIDataRX;
 
 	if ((global.mode != MODE_SHUTDOWN) && ( global.mode != MODE_SLEEP) && (SPIDataRX))
 	{
@@ -385,12 +394,13 @@
 		scheduleSpecial_Evaluate_DataSendToSlave();
 
 		SPI_Start_single_TxRx_with_Master();
+
+		if(resettimeout)
+		{
+				global.check_sync_not_running = 0;
+		}
 	}
-
-	if(resettimeout)
-	{
-			global.check_sync_not_running = 0;
-	}
+	return ret;
 }
 
 static uint8_t SPI_check_header_and_footer_ok(void) {