Mercurial > public > ostc4
comparison Discovery/Src/tComm.c @ 316:4da2bffb07ca Bugfix_Flip_FirmwareUpdate
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
The text shown during firmware update was not shown in the correct position => updated screen orientation
In case of an interrupt of a firmware update the sw was froozen for about 60 seconds (former timeout for receiption of data block). To reduce the timeout to 6 seconds the receiption of date will now be split into blocks of 16k byte instead of 64k byte.
author | ideenmodellierer |
---|---|
date | Mon, 17 Jun 2019 21:47:33 +0200 |
parents | ad6ddc4aabcd |
children | effa6fb9eb89 |
comparison
equal
deleted
inserted
replaced
315:7420ed6c3508 | 316:4da2bffb07ca |
---|---|
101 uint8_t setForcedBluetoothName = 0; | 101 uint8_t setForcedBluetoothName = 0; |
102 | 102 |
103 uint8_t updateSettingsAndMenuOnExit = 0; | 103 uint8_t updateSettingsAndMenuOnExit = 0; |
104 | 104 |
105 /* Private types -------------------------------------------------------------*/ | 105 /* Private types -------------------------------------------------------------*/ |
106 #define BYTE_DOWNLOAD_MODE (0xBB) | 106 #define BYTE_DOWNLOAD_MODE (0xBB) |
107 #define BYTE_SERVICE_MODE (0xAA) | 107 #define BYTE_SERVICE_MODE (0xAA) |
108 | 108 |
109 #define UART_TIMEOUT_SECONDS (120u) /* Timeout for keeping connection open and waiting for data */ | 109 #define UART_TIMEOUT_SECONDS (120u) /* Timeout for keeping connection open and waiting for data */ |
110 #define UART_TIMEOUT_LARGE_BLOCK (6000u) /* Timeout (ms) for receiption of an 16K data block (typical RX time ~4,5seconds) */ | |
110 | 111 |
111 const uint8_t id_Region1_firmware = 0xFF; | 112 const uint8_t id_Region1_firmware = 0xFF; |
112 const uint8_t id_RTE = 0xFE; | 113 const uint8_t id_RTE = 0xFE; |
113 const uint8_t id_FONT = 0x10; | 114 const uint8_t id_FONT = 0x10; |
114 const uint8_t id_FONT_OLD = 0x00; | 115 const uint8_t id_FONT_OLD = 0x00; |
145 tCwindow.WindowNumberOfTextLines = 6; | 146 tCwindow.WindowNumberOfTextLines = 6; |
146 tCwindow.WindowLineSpacing = 65; | 147 tCwindow.WindowLineSpacing = 65; |
147 tCwindow.WindowTab = 400; | 148 tCwindow.WindowTab = 400; |
148 tCwindow.WindowX0 = 20; | 149 tCwindow.WindowX0 = 20; |
149 tCwindow.WindowX1 = 779; | 150 tCwindow.WindowX1 = 779; |
150 tCwindow.WindowY0 = 0; | 151 |
151 tCwindow.WindowY1 = 799; | 152 |
153 if(!settingsGetPointer()->FlipDisplay) | |
154 { | |
155 tCwindow.WindowY0 = 0; | |
156 tCwindow.WindowY1 = 479; | |
157 } | |
158 else | |
159 { | |
160 tCwindow.WindowY0 = 479 - 390; | |
161 tCwindow.WindowY1 = 479 - 25; | |
162 } | |
152 | 163 |
153 StartListeningToUART = 1; | 164 StartListeningToUART = 1; |
154 | 165 |
155 /* WHY? | 166 /* WHY? |
156 #ifdef BLE_NENABLE_PIN | 167 #ifdef BLE_NENABLE_PIN |
223 display_text[0] = 0; | 234 display_text[0] = 0; |
224 display_text[255] = 0; | 235 display_text[255] = 0; |
225 } | 236 } |
226 else if(display_text[255]) | 237 else if(display_text[255]) |
227 { | 238 { |
228 display_text[display_text[255]] = 0; | 239 display_text[(uint8_t)display_text[255]] = 0; |
229 releaseFrame(18,tCscreen.FBStartAdress); | 240 releaseFrame(18,tCscreen.FBStartAdress); |
230 tCscreen.FBStartAdress = getFrame(18); | 241 tCscreen.FBStartAdress = getFrame(18); |
231 write_content_simple(&tCscreen, 0, 800, 480-24, &FontT24,"Exit",CLUT_ButtonSurfaceScreen); | 242 write_content_simple(&tCscreen, 0, 800, 480-24, &FontT24,"Exit",CLUT_ButtonSurfaceScreen); |
232 GFX_write_string(&FontT48, &tCwindow, display_text,2); | 243 GFX_write_string(&FontT48, &tCwindow, display_text,2); |
233 GFX_SetFrameTop(tCscreen.FBStartAdress); | 244 GFX_SetFrameTop(tCscreen.FBStartAdress); |
1192 } | 1203 } |
1193 | 1204 |
1194 | 1205 |
1195 HAL_StatusTypeDef receive_uart_large_size(UART_HandleTypeDef *huart, uint8_t *pData, uint32_t Size) | 1206 HAL_StatusTypeDef receive_uart_large_size(UART_HandleTypeDef *huart, uint8_t *pData, uint32_t Size) |
1196 { | 1207 { |
1197 uint16_t length_16_blocks; | 1208 uint16_t length_16k_blocks; |
1198 uint16_t length_16_remainder; | 1209 uint16_t length_16k_remainder; |
1199 uint32_t temp; | 1210 uint32_t temp; |
1200 HAL_StatusTypeDef result = HAL_OK; | 1211 HAL_StatusTypeDef result = HAL_OK; |
1201 uint32_t pDataLocal; | 1212 uint32_t pDataLocal; |
1202 | 1213 |
1203 length_16_blocks = (uint16_t) (Size / 0xFFFF); | 1214 length_16k_blocks = (uint16_t) (Size / 0x3FFF); |
1204 temp = length_16_blocks; | 1215 temp = length_16k_blocks; |
1205 temp *= 0xFFFF; | 1216 temp *= 0x3FFF; |
1206 length_16_remainder = (uint16_t) ( Size - temp); | 1217 length_16k_remainder = (uint16_t) ( Size - temp); |
1207 | 1218 |
1208 pDataLocal = (uint32_t)pData; | 1219 pDataLocal = (uint32_t)pData; |
1209 | 1220 |
1210 while((result == HAL_OK) && length_16_blocks) | 1221 |
1211 { | 1222 while((result == HAL_OK) && length_16k_blocks) |
1212 result = HAL_UART_Receive(&UartHandle, (uint8_t *)pDataLocal, 0xFFFF , 60000); | 1223 { |
1213 pDataLocal += 0xFFFF; | 1224 result = HAL_UART_Receive(&UartHandle, (uint8_t *)pDataLocal, 0x3FFF , UART_TIMEOUT_LARGE_BLOCK); |
1214 length_16_blocks--; | 1225 pDataLocal += 0x3FFF; |
1215 } | 1226 length_16k_blocks--; |
1216 if((result == HAL_OK) && length_16_remainder) | 1227 } |
1217 { | 1228 if((result == HAL_OK) && length_16k_remainder) |
1218 result = HAL_UART_Receive(&UartHandle, (uint8_t *)pDataLocal, length_16_remainder , 60000); | 1229 { |
1230 result = HAL_UART_Receive(&UartHandle, (uint8_t *)pDataLocal, length_16k_remainder , UART_TIMEOUT_LARGE_BLOCK); | |
1219 } | 1231 } |
1220 return result; | 1232 return result; |
1221 } | 1233 } |
1222 | 1234 |
1223 | 1235 |