# HG changeset patch # User ideenmodellierer # Date 1555244561 -7200 # Node ID a91d9926588433393074ba7e220b384cbedbaf39 # Parent b3685fbada3bfc294867b95328dbfb3a979a212f 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 diff -r b3685fbada3b -r a91d99265884 Small_CPU/Inc/scheduler.h --- 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; diff -r b3685fbada3b -r a91d99265884 Small_CPU/Src/scheduler.c --- 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); } }