Mercurial > public > ostc4
diff Small_CPU/Src/spi.c @ 264:b3685fbada3b IPC_Sync_Improvment_2
Sync to Main 100ms time stamp & added Reinitialization of globals after startup
Added function to synchronize RTE to the timestamp provided by Main 100ms callback. This was introduced to compensated small shifts in execution and program flow shifts (for example during long operation times)
author | ideenmodellierer |
---|---|
date | Sun, 14 Apr 2019 11:43:29 +0200 |
parents | e4207f0aaa4b |
children | 580822b5d3d1 |
line wrap: on
line diff
--- a/Small_CPU/Src/spi.c Sun Apr 14 11:38:14 2019 +0200 +++ b/Small_CPU/Src/spi.c Sun Apr 14 11:43:29 2019 +0200 @@ -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) {