diff Discovery/Src/data_exchange_main.c @ 115:3834b6272ee5 FlipDisplay

Merge with 68181cd61f2069d061621c2cd2a6afddb7486f5e
author Ideenmodellierer
date Thu, 03 Jan 2019 19:59:36 +0100
parents 65a6e352ce08 22a1094545f3
children acc98f5bd8c4
line wrap: on
line diff
--- a/Discovery/Src/data_exchange_main.c	Thu Jan 03 18:35:11 2019 +0100
+++ b/Discovery/Src/data_exchange_main.c	Thu Jan 03 19:59:36 2019 +0100
@@ -167,7 +167,7 @@
 void DataEX_init(void)
 {
 	SDiveState * pStateReal = stateRealGetPointerWrite();
-	pStateReal->data_old__lost_connection_to_slave = 1;
+	pStateReal->data_old__lost_connection_to_slave = 0; //initial value
 	data_old__lost_connection_to_slave_counter_temp = 0;
 	data_old__lost_connection_to_slave_counter_total = 0;
 
@@ -306,8 +306,8 @@
 	uint8_t SPI_DMA_answer = 0;
 	
 	HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_SET);
-	delayMicros(10);
-
+	delayMicros(20); //~exchange time(+20% reserve)
+	HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_RESET);
 	/* one cycle with NotChipSelect true to clear slave spi buffer */
 
 	if(data_old__lost_connection_to_slave_counter_temp >= 3)
@@ -315,10 +315,10 @@
 		data_old__lost_connection_to_slave_counter_temp = 0;
 		data_old__lost_connection_to_slave_counter_retry++;
 	}
-	else
-	{
-		HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_RESET);
-	}
+//	else
+//	{
+//		HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_RESET);
+//	}
 
 	DataEx_call_helper_requests();
 
@@ -326,15 +326,42 @@
 
 //HAL_GPIO_WritePin(OSCILLOSCOPE2_GPIO_PORT,OSCILLOSCOPE2_PIN,GPIO_PIN_RESET); /* only for testing with Oscilloscope */
 
-	SPI_DMA_answer = HAL_SPI_TransmitReceive_DMA(&cpu2DmaSpi, (uint8_t *)&dataOut, (uint8_t *)&dataIn, EXCHANGE_BUFFERSIZE+1);
+	SPI_DMA_answer = HAL_SPI_TransmitReceive_DMA(&cpu2DmaSpi, (uint8_t *)&dataOut, (uint8_t *)&dataIn, EXCHANGE_BUFFERSIZE);
+//	HAL_Delay(3);
 	if(SPI_DMA_answer != HAL_OK)
     DataEX_Error_Handler(SPI_DMA_answer);
+//	HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_SET);
 //HAL_Delay(3);
 //HAL_GPIO_WritePin(OSCILLOSCOPE2_GPIO_PORT,OSCILLOSCOPE2_PIN,GPIO_PIN_SET); /* only for testing with Oscilloscope */
 
 	return 1;
 }
 
+
+uint32_t SPI_CALLBACKS;
+uint32_t get_num_SPI_CALLBACKS(void){
+	return SPI_CALLBACKS;
+}
+
+SDataExchangeSlaveToMaster* get_dataInPointer(void){
+	return &dataIn;
+}
+
+
+void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi)
+{
+
+
+	if(hspi == &cpu2DmaSpi)
+	{
+		SPI_CALLBACKS+=1;
+	}
+}
+
+
+
+
+
 void DateEx_copy_to_dataOut(void)
 {
 	const SDiveState * pStateReal = stateRealGetPointer();
@@ -431,9 +458,9 @@
         return;
 	if(stateUsed == stateRealGetPointer())
 		pStateUsed = stateRealGetPointerWrite();
-	else
+	else{
 		pStateUsed = stateSimGetPointerWrite();
-
+	}
 
 		if(decoLock == DECO_CALC_init_as_is_start_of_dive)
 		{