Mercurial > public > ostc4
diff Discovery/Src/tComm.c @ 437:6c824f902934
Merged in Ideenmodellierer/ostc4/Improve_BatteryGasGauge (pull request #40)
Improve BatteryGasGauge
author | heinrichsweikamp <bitbucket@heinrichsweikamp.com> |
---|---|
date | Mon, 24 Feb 2020 07:58:37 +0000 |
parents | f68f2c4d71c7 |
children | 5e38b09d2c45 |
line wrap: on
line diff
--- a/Discovery/Src/tComm.c Tue Feb 18 12:41:45 2020 +0100 +++ b/Discovery/Src/tComm.c Mon Feb 24 07:58:37 2020 +0000 @@ -106,6 +106,7 @@ #define BYTE_DOWNLOAD_MODE (0xBB) #define BYTE_SERVICE_MODE (0xAA) +#define UART_OPERATION_TIMEOUT (500u) /* Timeout for common read / write operations (ms) */ #define UART_TIMEOUT_SECONDS (120u) /* Timeout for keeping connection open and waiting for data */ #define UART_TIMEOUT_LARGE_BLOCK (6000u) /* Timeout (ms) for reception of an 16K data block (typical RX time ~4,5seconds) */ @@ -444,7 +445,7 @@ do { HAL_Delay(200); - if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBufferEscapeSequence, 3, 1000)== HAL_OK) + if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBufferEscapeSequence, 3, UART_OPERATION_TIMEOUT)== HAL_OK) { answer = tComm_CheckAnswerOK(); } @@ -455,13 +456,13 @@ if(answer == HAL_OK) { answer = HAL_ERROR; - if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxDisconnect,sizeDisconnect , 1000)== HAL_OK) + if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxDisconnect,sizeDisconnect , UART_OPERATION_TIMEOUT)== HAL_OK) { answer = HAL_ERROR; if(tComm_CheckAnswerOK() == HAL_OK) { answer = HAL_ERROR; - if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBufferEnd, 4, 1000) == HAL_OK) /* exit terminal mode */ + if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBufferEnd, 4, UART_OPERATION_TIMEOUT) == HAL_OK) /* exit terminal mode */ { answer = tComm_CheckAnswerOK(); } @@ -536,7 +537,7 @@ while((answer == prompt4D4C(receiveStartByteUart)) && (timeoutCounter < UART_TIMEOUT_SECONDS)) /* try receive once a second */ { - if(HAL_UART_Receive(&UartHandle, (uint8_t*)&localRx, 1, 1000)!= HAL_OK) + if(HAL_UART_Receive(&UartHandle, (uint8_t*)&localRx, 1, UART_OPERATION_TIMEOUT)!= HAL_OK) { timeoutCounter++; get_globalStateList(&status); @@ -666,7 +667,7 @@ #endif case 0xC1: // Start low-level bootloader - if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 1, 1000)!= HAL_OK) + if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 1, UART_OPERATION_TIMEOUT)!= HAL_OK) return 0; break; default: @@ -1926,7 +1927,7 @@ uint8_t answer; memset(aRxBuffer,0,UART_CMD_BUF_SIZE); - if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, sizeAnswer, 1000) == HAL_OK) + if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, sizeAnswer, UART_OPERATION_TIMEOUT) == HAL_OK) { do { @@ -2098,7 +2099,7 @@ { if(BmTmpConfig == BM_CONFIG_ECHO) /* echo is not yet turned off => read and discard echo */ { - HAL_UART_Receive(&UartHandle, (uint8_t*)TxBuffer, CmdSize, 1000); + HAL_UART_Receive(&UartHandle, (uint8_t*)TxBuffer, CmdSize, UART_OPERATION_TIMEOUT); } result = tComm_CheckAnswerOK();