Mercurial > public > ostc4
comparison 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 |
comparison
equal
deleted
inserted
replaced
276:8e9c502c0b06 | 277:580822b5d3d1 |
---|---|
356 if(global.dataSendToSlave.header.checkCode[SPI_HEADER_INDEX_RX_STATE] == SPI_RX_STATE_SHIFTED) | 356 if(global.dataSendToSlave.header.checkCode[SPI_HEADER_INDEX_RX_STATE] == SPI_RX_STATE_SHIFTED) |
357 { | 357 { |
358 HAL_SPI_Abort_IT(&hspi1); | 358 HAL_SPI_Abort_IT(&hspi1); |
359 Scheduler_Request_sync_with_SPI(SPI_SYNC_METHOD_HARD); | 359 Scheduler_Request_sync_with_SPI(SPI_SYNC_METHOD_HARD); |
360 } | 360 } |
361 else | 361 else |
362 { | 362 { |
363 } | 363 } |
364 SPI_Start_single_TxRx_with_Master(); | |
364 } | 365 } |
365 else | 366 else |
366 { | 367 { |
367 // GPIO_new_DEBUG_LOW(); //For debug. | 368 // GPIO_new_DEBUG_LOW(); //For debug. |
368 global.dataSendToSlaveIsValid = 0; | 369 global.dataSendToSlaveIsValid = 0; |
384 else /* handle received data as if no data would have been received */ | 385 else /* handle received data as if no data would have been received */ |
385 { | 386 { |
386 global.dataSendToMaster.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_OFFLINE; | 387 global.dataSendToMaster.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_OFFLINE; |
387 resettimeout = 0; | 388 resettimeout = 0; |
388 } | 389 } |
390 HAL_SPI_TransmitReceive_DMA(&hspi1,(uint8_t*) &(global.dataSendToMaster),(uint8_t*) &(global.dataSendToSlave), EXCHANGE_BUFFERSIZE); | |
389 } | 391 } |
390 | 392 |
391 global.dataSendToMaster.power_on_reset = 0; | 393 global.dataSendToMaster.power_on_reset = 0; |
392 global.deviceDataSendToMaster.power_on_reset = 0; | 394 global.deviceDataSendToMaster.power_on_reset = 0; |
393 | 395 |
394 scheduleSpecial_Evaluate_DataSendToSlave(); | 396 scheduleSpecial_Evaluate_DataSendToSlave(); |
395 | |
396 SPI_Start_single_TxRx_with_Master(); | |
397 | 397 |
398 if(resettimeout) | 398 if(resettimeout) |
399 { | 399 { |
400 global.check_sync_not_running = 0; | 400 global.check_sync_not_running = 0; |
401 } | 401 } |