Mercurial > public > ostc4
changeset 265:a91d99265884 IPC_Sync_Improvment_2
Increase SPI com timeout for cold start and wake up
There are use cases which cause the startup at Main to be longer than 300ms. In that case error reaction on RTE side would take place even if not needed.
On the other hand having an longer timeout delays timeout detection and therefor the time till connection is reestablished
=> Added function to separate startup from common operation use case
author | ideenmodellierer |
---|---|
date | Sun, 14 Apr 2019 14:22:41 +0200 |
parents | b3685fbada3b |
children | fd47e5631b9d |
files | Small_CPU/Inc/scheduler.h Small_CPU/Src/scheduler.c |
diffstat | 2 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/Small_CPU/Inc/scheduler.h Sun Apr 14 11:43:29 2019 +0200 +++ b/Small_CPU/Inc/scheduler.h Sun Apr 14 14:22:41 2019 +0200 @@ -40,6 +40,9 @@ #define SCHEDULER_TICK_EXE1SEC (980u) /* tick count based on cycle start which is used to trigger functions which */ /* shall be executed once in a second (20ms before cycle restarts) */ +#define SPI_COM_TIMEOUT_START (5) /* *100 ms timeout to avoid tiemout e.g. after Main wakeup */ +#define SPI_COM_TIMEOUT_COMMON (3) /* *100ms shorter timeout during normal operation to have a faster error reaction */ + typedef struct { uint8_t mode; @@ -84,6 +87,7 @@ uint8_t counterPressure100msec; uint8_t counterCompass100msec; uint8_t counterAmbientLight100msec; + uint8_t communicationTimeout; uint32_t tick_execute1second; uint32_t tickstart; } SScheduleCtrl;
--- a/Small_CPU/Src/scheduler.c Sun Apr 14 11:43:29 2019 +0200 +++ b/Small_CPU/Src/scheduler.c Sun Apr 14 14:22:41 2019 +0200 @@ -172,6 +172,7 @@ global.deviceData.temperatureMinimum.value_int32 = INT32_MAX; global.deviceData.voltageMinimum.value_int32 = INT32_MAX; + Scheduler.communicationTimeout = SPI_COM_TIMEOUT_START; Scheduler_Request_sync_with_SPI(SPI_SYNC_METHOD_HARD); } @@ -182,6 +183,7 @@ global.dataSendToSlaveIsNotValidCount = 0; global.sync_error_count = 0; global.check_sync_not_running = 0; + Scheduler.communicationTimeout = SPI_COM_TIMEOUT_START; } void scheduleSpecial_Evaluate_DataSendToSlave(void) @@ -410,7 +412,7 @@ void schedule_check_resync(void) { /* counter is incremented in cyclic 100ms loop and reset to 0 if the transmission complete callback is called */ - if((global.check_sync_not_running >= 5)) + if((global.check_sync_not_running >= Scheduler.communicationTimeout)) { // global.dataSendToSlaveIsNotValidCount = 0; global.check_sync_not_running = 0; @@ -420,6 +422,7 @@ * function error handler */ SPI_Start_single_TxRx_with_Master(); + Scheduler.communicationTimeout = SPI_COM_TIMEOUT_COMMON; /* Reduce error detection time */ Scheduler_Request_sync_with_SPI(SPI_SYNC_METHOD_HARD); } }