comparison Small_CPU/Src/spi.c @ 416:bcf447646e07

Merged in Ideenmodellierer/ostc4/Improment_NVM (pull request #37) Improment NVM
author heinrichsweikamp <bitbucket@heinrichsweikamp.com>
date Wed, 15 Jan 2020 10:53:15 +0000
parents 2fc08a0d1ec3
children 84a4e1200726
comparison
equal deleted inserted replaced
403:6f30f2011667 416:bcf447646e07
22 /* Includes ------------------------------------------------------------------*/ 22 /* Includes ------------------------------------------------------------------*/
23 23
24 #include "global_constants.h" 24 #include "global_constants.h"
25 #include "spi.h" 25 #include "spi.h"
26 #include "dma.h" 26 #include "dma.h"
27 #include "batteryGasGauge.h"
28 #include "pressure.h"
27 29
28 //#include "gpio.h" 30 //#include "gpio.h"
29 31
30 /* USER CODE BEGIN 0 */ 32 /* USER CODE BEGIN 0 */
31 #include "scheduler.h" 33 #include "scheduler.h"
296 HAL_Delay(50); 298 HAL_Delay(50);
297 #endif 299 #endif
298 } 300 }
299 301
300 void SPI_Start_single_TxRx_with_Master(void) { 302 void SPI_Start_single_TxRx_with_Master(void) {
303 static uint8_t DevicedataDelayCnt = 10;
304 static uint8_t DeviceDataPending = 0;
301 uint8_t * pOutput; 305 uint8_t * pOutput;
302 HAL_StatusTypeDef retval; 306 HAL_StatusTypeDef retval;
303 307
304 if (global.dataSendToSlave.getDeviceDataNow) { 308 if ((global.dataSendToSlave.getDeviceDataNow) || (DeviceDataPending))
305 global.dataSendToSlave.getDeviceDataNow = 0; 309 {
306 pOutput = (uint8_t*) &(global.deviceDataSendToMaster); 310 if(((DevicedataDelayCnt == 0) || (((get_voltage() != 6.0) && (get_temperature() != 0.0))))) /* devicedata complete? */
307 } else { 311 {
312 global.dataSendToSlave.getDeviceDataNow = 0;
313 DeviceDataPending = 0;
314 pOutput = (uint8_t*) &(global.deviceDataSendToMaster);
315 }
316 else
317 {
318 DeviceDataPending = 1;
319 DevicedataDelayCnt--;
320 pOutput = (uint8_t*) &(global.dataSendToMaster);
321 }
322
323 }
324 else
325 {
308 pOutput = (uint8_t*) &(global.dataSendToMaster); 326 pOutput = (uint8_t*) &(global.dataSendToMaster);
309 } 327 }
310 retval = HAL_SPI_TransmitReceive_DMA(&hspi1, pOutput,(uint8_t*) &(global.dataSendToSlave), EXCHANGE_BUFFERSIZE); 328 retval = HAL_SPI_TransmitReceive_DMA(&hspi1, pOutput,(uint8_t*) &(global.dataSendToSlave), EXCHANGE_BUFFERSIZE);
311 if ( retval!= HAL_OK) { 329 if ( retval!= HAL_OK) {
312 SPI_Error_Handler(); 330 SPI_Error_Handler();