comparison 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
comparison
equal deleted inserted replaced
262:f4c16ea0354a 267:cf6ad20380fb
315 315
316 void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi) { 316 void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi) {
317 /* restart SPI */ 317 /* restart SPI */
318 if (hspi == &hspi1) 318 if (hspi == &hspi1)
319 { 319 {
320 Scheduler_SyncToSPI(); 320 if(SPI_check_header_and_footer_ok()) /* process timestamp provided by main */
321 {
322 Scheduler_SyncToSPI(global.dataSendToSlave.header.checkCode[SPI_HEADER_INDEX_TX_TICK]);
323 }
324 else
325 {
326 Scheduler_SyncToSPI(0); /* => no async will be calculated */
327 }
328
321 SPIDataRX = 1; 329 SPIDataRX = 1;
322 330
323 /* stop data exchange? */ 331 /* stop data exchange? */
324 if (global.mode == MODE_SHUTDOWN) { 332 if (global.mode == MODE_SHUTDOWN) {
325 global.mode = MODE_SLEEP; 333 global.mode = MODE_SLEEP;
328 global.dataSendToSlaveIsNotValidCount = 0; 336 global.dataSendToSlaveIsNotValidCount = 0;
329 } 337 }
330 } 338 }
331 } 339 }
332 340
333 void SPI_Evaluate_RX_Data() 341 uint8_t SPI_Evaluate_RX_Data()
334 { 342 {
335 uint8_t resettimeout = 1; 343 uint8_t resettimeout = 1;
344 uint8_t ret = SPIDataRX;
336 345
337 if ((global.mode != MODE_SHUTDOWN) && ( global.mode != MODE_SLEEP) && (SPIDataRX)) 346 if ((global.mode != MODE_SHUTDOWN) && ( global.mode != MODE_SLEEP) && (SPIDataRX))
338 { 347 {
339 SPIDataRX = 0; 348 SPIDataRX = 0;
340 /* data consistent? */ 349 /* data consistent? */
383 global.deviceDataSendToMaster.power_on_reset = 0; 392 global.deviceDataSendToMaster.power_on_reset = 0;
384 393
385 scheduleSpecial_Evaluate_DataSendToSlave(); 394 scheduleSpecial_Evaluate_DataSendToSlave();
386 395
387 SPI_Start_single_TxRx_with_Master(); 396 SPI_Start_single_TxRx_with_Master();
388 } 397
389 398 if(resettimeout)
390 if(resettimeout) 399 {
391 { 400 global.check_sync_not_running = 0;
392 global.check_sync_not_running = 0; 401 }
393 } 402 }
403 return ret;
394 } 404 }
395 405
396 static uint8_t SPI_check_header_and_footer_ok(void) { 406 static uint8_t SPI_check_header_and_footer_ok(void) {
397 if (global.dataSendToSlave.header.checkCode[0] != 0xBB) 407 if (global.dataSendToSlave.header.checkCode[0] != 0xBB)
398 return 0; 408 return 0;