Mercurial > public > ostc4
annotate Discovery/Src/tComm.c @ 388:a848e22bc527 maintain-1
Added tag v1.5.1 release for changeset afa55a50cc72
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Sun, 01 Dec 2019 17:12:27 +0100 |
parents | 4da2bffb07ca |
children | effa6fb9eb89 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tComm.c | |
5 /// \brief Main file for communication with PC | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 08-Aug-2014 | |
8 /// | |
9 /// \details | |
10 /// | |
11 /// $Id$ | |
12 /////////////////////////////////////////////////////////////////////////////// | |
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
14 /// | |
15 /// This program is free software: you can redistribute it and/or modify | |
16 /// it under the terms of the GNU General Public License as published by | |
17 /// the Free Software Foundation, either version 3 of the License, or | |
18 /// (at your option) any later version. | |
19 /// | |
20 /// This program is distributed in the hope that it will be useful, | |
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 /// GNU General Public License for more details. | |
24 /// | |
25 /// You should have received a copy of the GNU General Public License | |
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
27 ////////////////////////////////////////////////////////////////////////////// | |
28 | |
29 /** | |
30 ============================================================================== | |
31 ##### How to use ##### | |
32 ============================================================================== | |
33 ============================================================================== | |
34 ##### History ##### | |
35 ============================================================================== | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
36 160211 added 4 bytes Serial in update Files after checksum prior to binary |
38 | 37 160211 0x6B changed to version only |
38 160623 fixed 0x72 (in V1.0.9) | |
39 160623 fixed rebuild menu (before update) for V1.0.10 | |
40 | |
41 ============================================================================== | |
42 ##### CTS / RTS ##### | |
43 ============================================================================== | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
44 RTS is Output, CTS is Input |
38 | 45 |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
46 BlueMod Pin D7 UART-RTS# is Output |
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
47 connected to STM32F429 PA11 CTS (Input) |
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
48 also STM32 PA12 RTS is connected to BlueMod UART-CTS# F3 |
38 | 49 |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
50 see BlueMod_SR_HWreference_r06.pdf, page 156 |
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
51 and MAIN_CPU STM32F4 Reference manual DM00031020.pdf, page 990 |
38 | 52 |
53 | |
54 ============================================================================== | |
55 ##### Codes ##### | |
56 ============================================================================== | |
57 [0x73] upload CPU2 firmware in SDRAM and update CPU2 | |
58 | |
59 [0x74] upload MainCPU firmware in EEPROM and start bootloader | |
60 | |
61 */ | |
62 | |
63 /* Includes ------------------------------------------------------------------*/ | |
64 | |
65 #include "tComm.h" | |
66 | |
67 #include "externCPU2bootloader.h" | |
68 #include "externLogbookFlash.h" | |
69 #include "gfx_colors.h" | |
70 #include "gfx_engine.h" | |
71 #include "gfx_fonts.h" | |
72 #include "ostc.h" | |
73 | |
74 #ifndef BOOTLOADER_STANDALONE | |
75 # include "base.h" | |
76 # include "tHome.h" | |
77 # include "logbook.h" | |
78 # include "tMenu.h" | |
79 #else | |
80 # include "base_bootloader.h" | |
81 # include "firmwareEraseProgram.h" | |
82 #endif | |
83 | |
84 #ifdef SPECIALPROGRAMM | |
85 # include "firmwareEraseProgram.h" | |
86 #endif | |
87 | |
88 #include <string.h> | |
89 | |
90 | |
91 /* Private variables ---------------------------------------------------------*/ | |
92 GFX_DrawCfgScreen tCscreen; | |
93 GFX_DrawCfgWindow tCwindow; | |
94 | |
95 uint8_t receiveStartByteUart = 0; | |
96 uint8_t bluetoothActiveLastTime = 0; | |
97 | |
98 uint8_t StartListeningToUART = 0; | |
229
2c0b502b0a72
cleanup: fix recent extra compiler warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
218
diff
changeset
|
99 char display_text[256] = { 0 }; |
38 | 100 |
101 uint8_t setForcedBluetoothName = 0; | |
102 | |
103 uint8_t updateSettingsAndMenuOnExit = 0; | |
104 | |
105 /* Private types -------------------------------------------------------------*/ | |
316
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
106 #define BYTE_DOWNLOAD_MODE (0xBB) |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
107 #define BYTE_SERVICE_MODE (0xAA) |
38 | 108 |
316
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
109 #define UART_TIMEOUT_SECONDS (120u) /* Timeout for keeping connection open and waiting for data */ |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
110 #define UART_TIMEOUT_LARGE_BLOCK (6000u) /* Timeout (ms) for receiption of an 16K data block (typical RX time ~4,5seconds) */ |
218
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
111 |
38 | 112 const uint8_t id_Region1_firmware = 0xFF; |
113 const uint8_t id_RTE = 0xFE; | |
114 const uint8_t id_FONT = 0x10; | |
115 const uint8_t id_FONT_OLD = 0x00; | |
116 | |
117 /* Private function prototypes -----------------------------------------------*/ | |
118 | |
119 static void tComm_Error_Handler(void); | |
120 static uint8_t select_mode(uint8_t aRxByte); | |
121 uint8_t receive_update_flex(uint8_t isRTEupdateALLOWED); | |
122 uint8_t receive_update_data_flex(uint8_t* pBuffer1, uint8_t* pBuffer2, uint8_t RTEupdateALLOWED); | |
123 uint8_t receive_update_data_mainCPU_firmware(void); | |
124 uint8_t receive_update_data_mainCPU_variable_firmware(void); | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
125 uint8_t receive_update_data_mainCPU_firmware_subroutine(uint8_t region, uint8_t* pBuffer1, uint8_t* pBuffer2); |
38 | 126 HAL_StatusTypeDef receive_uart_large_size(UART_HandleTypeDef *huart, uint8_t *pData, uint32_t Size); |
127 static uint8_t openComm(uint8_t aRxByte); | |
128 uint8_t HW_Set_Bluetooth_Name(uint16_t serial, uint8_t withEscapeSequence); | |
129 uint8_t prompt4D4C(uint8_t mode); | |
130 | |
131 #ifdef BOOTLOADER_STANDALONE | |
132 static uint8_t receive_update_data_cpu2(void); | |
133 uint8_t receive_update_data_cpu2_sub(uint8_t* pBuffer); | |
134 #endif | |
135 | |
136 /* Exported functions --------------------------------------------------------*/ | |
137 | |
138 void tComm_init(void) | |
139 { | |
140 tCscreen.FBStartAdress = 0; | |
141 tCscreen.ImageHeight = 480; | |
142 tCscreen.ImageWidth = 800; | |
143 tCscreen.LayerIndex = 1; | |
144 | |
145 tCwindow.Image = &tCscreen; | |
146 tCwindow.WindowNumberOfTextLines = 6; | |
147 tCwindow.WindowLineSpacing = 65; | |
148 tCwindow.WindowTab = 400; | |
149 tCwindow.WindowX0 = 20; | |
150 tCwindow.WindowX1 = 779; | |
316
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
151 |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
152 |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
153 if(!settingsGetPointer()->FlipDisplay) |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
154 { |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
155 tCwindow.WindowY0 = 0; |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
156 tCwindow.WindowY1 = 479; |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
157 } |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
158 else |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
159 { |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
160 tCwindow.WindowY0 = 479 - 390; |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
161 tCwindow.WindowY1 = 479 - 25; |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
162 } |
38 | 163 |
164 StartListeningToUART = 1; | |
165 | |
166 /* WHY? | |
167 #ifdef BLE_NENABLE_PIN | |
168 HAL_GPIO_WritePin(BLE_NENABLE_GPIO_PORT,BLE_NENABLE_PIN,GPIO_PIN_RESET); | |
169 #endif | |
170 */ | |
171 } | |
172 | |
173 uint8_t tComm_control(void) | |
174 { | |
175 uint8_t answer = 0; | |
176 #ifndef BOOTLOADER_STANDALONE | |
177 | |
178 /* should do something like reset UART ... */ | |
179 if( settingsGetPointer()->bluetoothActive == 0) | |
180 { | |
181 if(bluetoothActiveLastTime) | |
182 { | |
183 HAL_UART_DeInit(&UartHandle); | |
184 HAL_Delay(1); | |
185 HAL_UART_Init(&UartHandle); | |
186 HAL_Delay(1); | |
187 UartReady = RESET; | |
188 StartListeningToUART = 1; | |
189 bluetoothActiveLastTime = 0; | |
190 receiveStartByteUart = 0; | |
191 } | |
192 return 0; | |
193 } | |
194 else | |
195 { | |
196 bluetoothActiveLastTime = 1; | |
197 } | |
198 | |
199 #endif | |
200 | |
201 /*##-2- Put UART peripheral in reception process ###########################*/ | |
202 | |
203 if((UartReady == RESET) && StartListeningToUART) | |
204 { | |
205 StartListeningToUART = 0; | |
206 if(HAL_UART_Receive_IT(&UartHandle, &receiveStartByteUart, 1) != HAL_OK) | |
207 tComm_Error_Handler(); | |
208 } | |
209 /* Reset transmission flag */ | |
210 if(UartReady == SET) | |
211 { | |
212 UartReady = RESET; | |
213 if((receiveStartByteUart == BYTE_DOWNLOAD_MODE) || (receiveStartByteUart == BYTE_SERVICE_MODE)) | |
214 answer = openComm(receiveStartByteUart); | |
215 StartListeningToUART = 1; | |
216 return answer; | |
217 } | |
218 return 0; | |
219 } | |
220 | |
221 | |
222 void tComm_refresh(void) | |
223 { | |
224 if(tCscreen.FBStartAdress == 0) | |
225 { | |
226 GFX_hwBackgroundOn(); | |
227 tCscreen.FBStartAdress = getFrame(18); | |
228 write_content_simple(&tCscreen, 0, 800, 480-24, &FontT24,"Exit",CLUT_ButtonSurfaceScreen); | |
229 if(receiveStartByteUart == BYTE_SERVICE_MODE) | |
230 GFX_write_string(&FontT48, &tCwindow, "Service mode enabled",2); | |
231 else | |
232 GFX_write_string(&FontT48, &tCwindow, "Download mode enabled",2); | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
233 GFX_SetFramesTopBottom(tCscreen.FBStartAdress, 0,480); |
38 | 234 display_text[0] = 0; |
235 display_text[255] = 0; | |
236 } | |
237 else if(display_text[255]) | |
238 { | |
316
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
239 display_text[(uint8_t)display_text[255]] = 0; |
38 | 240 releaseFrame(18,tCscreen.FBStartAdress); |
241 tCscreen.FBStartAdress = getFrame(18); | |
242 write_content_simple(&tCscreen, 0, 800, 480-24, &FontT24,"Exit",CLUT_ButtonSurfaceScreen); | |
243 GFX_write_string(&FontT48, &tCwindow, display_text,2); | |
244 GFX_SetFrameTop(tCscreen.FBStartAdress); | |
245 display_text[0] = 0; | |
246 display_text[255] = 0; | |
247 } | |
248 } | |
249 | |
250 | |
251 void tComm_verlauf(uint8_t percentage_complete) | |
252 { | |
253 uint32_t pDestination; | |
254 | |
255 pDestination = (uint32_t)tCscreen.FBStartAdress; | |
256 pDestination += 150 * tCscreen.ImageHeight * 2; | |
257 pDestination += 100 * 2; | |
258 | |
259 if(percentage_complete > 100) | |
260 percentage_complete = 100; | |
261 | |
262 int i = 1; | |
263 while(i<=percentage_complete) | |
264 { | |
265 i += 1; | |
266 for(int y=0;y<4;y++) | |
267 { | |
268 for(int x=0;x<40;x++) | |
269 { | |
270 *(__IO uint16_t*)pDestination = 0xFF00 + 00; | |
271 pDestination += 2; | |
272 } | |
273 pDestination += (tCscreen.ImageHeight - 40 )* 2; | |
274 } | |
275 pDestination += tCscreen.ImageHeight * 2; // one spare line | |
276 } | |
277 } | |
278 | |
279 | |
280 void tComm_exit(void) | |
281 { | |
282 SStateList status; | |
283 get_globalStateList(&status); | |
284 | |
285 releaseFrame(18,tCscreen.FBStartAdress); | |
286 tCscreen.FBStartAdress = 0; | |
287 GFX_hwBackgroundOff(); | |
288 | |
289 if(setForcedBluetoothName) | |
290 { | |
291 setForcedBluetoothName = 0; | |
292 MX_Bluetooth_PowerOff(); | |
293 HAL_Delay(1000); | |
294 MX_Bluetooth_PowerOn(); | |
295 tComm_Set_Bluetooth_Name(1); | |
296 } | |
297 #ifndef BOOTLOADER_STANDALONE | |
298 if(updateSettingsAndMenuOnExit) | |
299 { | |
300 check_and_correct_settings(); | |
301 createDiveSettings(); | |
302 tM_rebuild_menu_after_tComm(); | |
303 } | |
304 #endif | |
305 updateSettingsAndMenuOnExit = 0; | |
306 | |
307 if(status.base == BaseComm) | |
308 { | |
309 #ifndef BOOTLOADER_STANDALONE | |
310 set_globalState_tHome(); | |
311 #else | |
312 set_globalState_Base(); | |
313 #endif | |
314 } | |
315 } | |
316 | |
317 | |
318 uint8_t tComm_Set_Bluetooth_Name(uint8_t force) | |
319 { | |
320 uint8_t answer = 0; | |
321 | |
322 if(hardwareDataGetPointer()->secondarySerial != 0xFFFF) | |
323 { | |
324 if(force || (hardwareDataGetPointer()->secondary_bluetooth_name_set == 0xFF)) | |
325 answer = HW_Set_Bluetooth_Name(hardwareDataGetPointer()->secondarySerial, 0); | |
326 #ifdef BOOTLOADER_STANDALONE | |
327 if(answer == HAL_OK) | |
328 hardware_programmSecondaryBluetoothNameSet(); | |
329 #endif | |
330 } | |
331 else | |
332 if(hardwareDataGetPointer()->primarySerial != 0xFFFF) | |
333 { | |
334 if(force || (hardwareDataGetPointer()->production_bluetooth_name_set == 0xFF)) | |
335 answer = HW_Set_Bluetooth_Name(hardwareDataGetPointer()->primarySerial, 0); | |
336 #ifdef BOOTLOADER_STANDALONE | |
337 if(answer == HAL_OK) | |
338 hardware_programmPrimaryBluetoothNameSet(); | |
339 #endif | |
340 } | |
341 return answer; | |
342 } | |
343 | |
344 | |
345 uint8_t HW_Set_Bluetooth_Name(uint16_t serial, uint8_t withEscapeSequence) | |
346 { | |
347 uint8_t answer = HAL_OK; | |
348 uint8_t aRxBuffer[50]; | |
349 | |
350 // char aTxFactoryDefaults[50] = "AT&F1\r"; | |
351 | |
352 char aTxBufferEscapeSequence[50] = "+++"; | |
353 // limit is 19 chars, with 7 chars shown in BLE advertising mode | |
354 //________________________123456789012345678901 | |
355 char aTxBufferName[50] = "AT+BNAME=OSTC4-12345\r"; | |
356 char answerOkay[6] = "\r\nOKr\n"; | |
357 | |
358 gfx_number_to_string(5,1,&aTxBufferName[15],serial); | |
359 | |
360 // store active configuration in non-volatile memory | |
361 char aTxBufferWrite[50] = "AT&W\r"; | |
362 | |
363 // char aTxBufferReset[50] = "AT+RESET\r"; | |
364 | |
365 | |
366 HAL_Delay(1010); | |
367 if(withEscapeSequence) | |
368 { | |
369 aRxBuffer[0] = 0; | |
370 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBufferEscapeSequence, 3, 2000)!= HAL_OK) | |
371 answer = HAL_ERROR; | |
372 HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 3, 2000); | |
373 HAL_Delay(1010); | |
374 | |
375 for(int i=0;i<3;i++) | |
376 if(aRxBuffer[i] != '+') | |
377 answer = HAL_ERROR; | |
378 } | |
379 | |
380 aRxBuffer[0] = 0; | |
381 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBufferName, 21, 2000)!= HAL_OK) | |
382 answer = HAL_ERROR; | |
383 HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 21+6, 2000); | |
384 | |
385 for(int i=0;i<21;i++) | |
386 if(aRxBuffer[i] != aTxBufferName[i]) | |
387 answer = HAL_ERROR; | |
388 | |
389 for(int i=0;i<6;i++) | |
390 if(aRxBuffer[21+i] != answerOkay[i]) | |
391 answer = HAL_ERROR; | |
392 | |
393 HAL_Delay(200); | |
394 | |
395 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBufferWrite, 5, 2000)!= HAL_OK) | |
396 answer = HAL_ERROR; | |
397 HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 5+6, 2000); | |
398 | |
399 for(int i=0;i<5;i++) | |
400 if(aRxBuffer[i] != aTxBufferWrite[i]) | |
401 answer = HAL_ERROR; | |
402 | |
403 for(int i=0;i<6;i++) | |
404 if(aRxBuffer[5+i] != answerOkay[i]) | |
405 answer = HAL_ERROR; | |
406 | |
407 answer = HAL_OK; | |
408 return answer; | |
409 } | |
410 | |
411 | |
412 uint8_t openComm(uint8_t aRxByte) | |
413 { | |
218
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
414 SStateList status; |
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
415 uint8_t timeoutCounter = 0; |
38 | 416 uint8_t answer = 0; |
417 uint8_t service_mode_last_three_bytes[3]; | |
418 uint8_t service_mode_response[5] = | |
419 { | |
420 0x4B, | |
421 0xAB, | |
422 0xCD, | |
423 0xEF, | |
424 0x4C | |
425 }; | |
426 uint8_t download_mode_response[2] = | |
427 { | |
428 0xBB, | |
429 0x4D | |
430 }; | |
431 | |
432 if((aRxByte != BYTE_DOWNLOAD_MODE) && (aRxByte != BYTE_SERVICE_MODE)) | |
433 return 0; | |
434 | |
435 set_globalState(StUART_STANDARD); | |
436 | |
437 /* service mode is four bytes | |
438 0xAA 0xAB 0xCD 0xEF | |
439 answer is | |
440 */ | |
441 | |
442 if(aRxByte == BYTE_SERVICE_MODE) | |
443 { | |
444 if((HAL_UART_Receive(&UartHandle, (uint8_t*)service_mode_last_three_bytes, 3, 2000)!= HAL_OK)) | |
445 answer = 0x00; | |
446 else | |
447 { | |
448 if((service_mode_last_three_bytes[0] != 0xAB) || (service_mode_last_three_bytes[1] != 0xCD) || (service_mode_last_three_bytes[2] != 0xEF)) | |
449 answer = 0x00; | |
450 else | |
451 { | |
452 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)service_mode_response, 5, 2000)!= HAL_OK) | |
453 answer = 0x00; | |
454 else | |
455 answer = prompt4D4C(receiveStartByteUart); | |
456 } | |
457 } | |
458 } | |
459 else //if(aRxByte == BYTE_SERVICE_MODE) | |
460 { | |
461 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)download_mode_response, 2, 2000)!= HAL_OK) | |
462 answer = 0x00; | |
463 else | |
464 answer = prompt4D4C(receiveStartByteUart); | |
465 } | |
466 /* | |
467 uint8_t debug[256] = {0}; | |
468 uint8_t dbgptr = 0; | |
469 debug[dbgptr++] = aRxByte; | |
470 */ | |
218
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
471 while((answer == prompt4D4C(receiveStartByteUart)) && (timeoutCounter < UART_TIMEOUT_SECONDS * 2)) /* Split 120 seconds timeout into 240 iterations a 500ms */ |
38 | 472 { |
218
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
473 if(HAL_UART_Receive(&UartHandle, (uint8_t*)&aRxByte, 1, 500)!= HAL_OK) /* Timeout half a second */ |
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
474 { |
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
475 timeoutCounter++; |
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
476 get_globalStateList(&status); |
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
477 if (status.base != BaseComm) |
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
478 { |
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
479 timeoutCounter = UART_TIMEOUT_SECONDS * 2; /* Abort action triggered outside main loop => exit */ |
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
480 } |
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
481 } |
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
482 else |
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
483 { |
38 | 484 // debug[dbgptr++] = aRxByte; |
218
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
485 answer = select_mode(aRxByte); |
ff59d1d07f9c
Splitted 120 seconds UART timeout into chunks of 500ms
ideenmodellierer
parents:
166
diff
changeset
|
486 } |
38 | 487 } |
488 set_returnFromComm(); | |
489 return 1; | |
490 } | |
491 | |
492 | |
493 uint8_t prompt4D4C(uint8_t mode) | |
494 { | |
495 if(mode == BYTE_SERVICE_MODE) | |
496 return 0x4C; | |
497 else | |
498 return 0x4D; | |
499 } | |
500 | |
501 | |
502 uint8_t select_mode(uint8_t type) | |
503 { | |
504 #ifndef BOOTLOADER_STANDALONE | |
505 SLogbookHeader logbookHeader; | |
506 SLogbookHeaderOSTC3 * plogbookHeaderOSTC3; | |
507 SLogbookHeaderOSTC3compact * plogbookHeaderOSTC3compact; | |
508 uint32_t sampleTotalLength; | |
509 SSettings* pSettings = settingsGetPointer(); | |
510 RTC_DateTypeDef sdatestructure; | |
511 RTC_TimeTypeDef stimestructure; | |
512 #else | |
513 uint8_t dummyForBootloader[256] = {0}; | |
514 #endif | |
515 | |
516 uint8_t count; | |
517 uint8_t aTxBuffer[128]; | |
518 uint8_t aRxBuffer[68]; | |
519 uint8_t answer; | |
520 aTxBuffer[0] = type; | |
521 aTxBuffer[1] = prompt4D4C(receiveStartByteUart); | |
522 uint8_t tempHigh, tempLow; | |
523 count = 0; | |
524 | |
525 // service mode only commands | |
526 if(receiveStartByteUart == BYTE_SERVICE_MODE) | |
527 { | |
528 // first part | |
529 switch(type) | |
530 { | |
531 // start communication (again) | |
532 case 0xAA: | |
533 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 2, 1000)!= HAL_OK) | |
534 return 0; | |
535 else | |
536 return prompt4D4C(receiveStartByteUart); | |
537 | |
538 /* | |
539 // update firmware main preparation | |
540 case 0x74: | |
541 ext_flash_erase_firmware_if_not_empty(); | |
542 break; | |
543 | |
544 // update firmware main with variable full access memory location preparation | |
545 case 0x76: | |
546 ext_flash_erase_firmware2_if_not_empty(); | |
547 break; | |
548 */ | |
549 default: | |
550 break; | |
551 } | |
552 | |
553 #ifndef BOOTLOADER_STANDALONE | |
554 uint32_t logCopyDataPtr = 0; | |
555 convert_Type logCopyDataLength; | |
556 uint32_t logCopyDataPtrTemp = 0; | |
557 uint32_t logCopyDataLengthTemp = 0; | |
558 uint8_t logDummyByte = 0; | |
559 uint8_t logStepBackwards = 0; | |
560 convert16_Type totalDiveCount; | |
561 logCopyDataLength.u32bit = 0; | |
562 totalDiveCount.u16bit = 0; | |
563 #endif | |
564 | |
565 // Exit communication on Text like RING, CONNECT, ... or 0xFF command | |
566 if((type < 0x60) || (type == 0xFF)) | |
567 return 0; | |
568 | |
569 // return of command for (almost) all commands | |
570 switch(type) | |
571 { | |
572 // not supported yet case 0x20: // send hi:lo:temp1 bytes starting from ext_flash_address:3 | |
573 // not supported yet case 0x22: // Resets all logbook pointers and the logbook (!) | |
574 // not supported yet case 0x23: // Resets battery gauge registers | |
575 // not supported yet case 0x30: // write bytes starting from ext_flash_address:3 (Stop when timeout) | |
576 // not supported yet case 0x40: // erases 4kB block from ext_flash_address:3 (Warning: No confirmation or built-in security here...) | |
577 // not supported yet case 0x42: // erases range in 4kB steps (Get 3 bytes address and 1byte amount of 4kB blocks) | |
578 // not supported yet case 0x50: // sends firmware from external flash from 0x3E0000 to 0x3FD000 (118784bytes) via comm | |
579 case 0xFE: // hw unit_tests | |
580 case 0x71: // hw read manufacturing data | |
581 case 0x73: // hw update FLEX | |
582 case 0x79: // hw read device data | |
583 #ifdef BOOTLOADER_STANDALONE | |
584 case 0x74: // hw update Firmware | |
585 case 0x75: // hw update RTE | |
586 case 0x76: // hw update Fonts | |
587 case 0x80: // hw write manufacturing data | |
588 case 0x81: // hw write second serial | |
589 case 0x82: // hw set bluetooth name | |
590 #else | |
591 case 0x83: // hw copy logbook entry - read | |
592 case 0x84: // hw copy logbook entry - write | |
593 case 0x85: // hw read entire logbook memory | |
594 case 0x86: // hw overwrite entire logbook memory | |
595 case 0x87: // hw ext_flash_repair_SPECIAL_dive_numbers_starting_count_with memory(x) | |
596 | |
597 #endif | |
598 case 0xC1: // Start low-level bootloader | |
599 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 1, 1000)!= HAL_OK) | |
600 return 0; | |
601 break; | |
602 default: | |
603 break; | |
604 } | |
605 | |
606 // now send content or update firmware | |
607 switch(type) | |
608 { | |
609 case 0xFE: | |
610 // work to do :-) 12. Oct. 2015 | |
611 // 256 bytes output | |
612 memset(aTxBuffer,0,128); | |
613 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 128,5000)!= HAL_OK) | |
614 return 0; | |
615 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 128,5000)!= HAL_OK) | |
616 return 0; | |
617 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
618 break; | |
619 | |
620 case 0x71: | |
621 memcpy(aTxBuffer,hardwareDataGetPointer(),64); | |
622 count += 64; | |
623 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
624 break; | |
625 | |
626 case 0x73: | |
627 #ifndef BOOTLOADER_STANDALONE | |
628 answer = receive_update_flex(1); | |
629 #else | |
630 answer = receive_update_flex(0); | |
631 #endif | |
632 if(answer == 0) | |
633 return 0; | |
634 else if(answer == 2) // 2 = RTE without bootToBootloader | |
635 { | |
636 aTxBuffer[0] = 0xFF; | |
637 HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 1,10000); | |
638 return 0; | |
639 } | |
640 else | |
641 { | |
642 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
643 if(answer == 1) /* 0xFF is checksum error, 2 = RTE without bootToBootloader */ | |
644 { | |
645 extern uint8_t bootToBootloader; | |
646 bootToBootloader = 1; | |
647 } | |
648 } | |
649 break; | |
650 | |
651 case 0x79: | |
652 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 1,10000)!= HAL_OK) | |
653 return 0; | |
654 ext_flash_read_fixed_16_devicedata_blocks_formated_128byte_total(aTxBuffer); | |
655 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 128,5000)!= HAL_OK) | |
656 return 0; | |
657 aTxBuffer[0] = prompt4D4C(receiveStartByteUart); | |
658 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 1,10000)!= HAL_OK) | |
659 return 0; | |
660 else | |
661 return prompt4D4C(receiveStartByteUart); | |
662 | |
663 case 0x82: | |
664 #ifdef BOOTLOADER_STANDALONE | |
665 setForcedBluetoothName = 1; | |
666 return 0; | |
667 #else | |
668 settingsGetPointer()->debugModeOnStart = 1; | |
669 extern uint8_t bootToBootloader; | |
670 bootToBootloader = 1; | |
671 return prompt4D4C(receiveStartByteUart); | |
672 #endif | |
673 | |
674 #ifdef BOOTLOADER_STANDALONE | |
675 case 0x74: | |
676 answer = receive_update_data_mainCPU_firmware(); | |
677 if(answer != 0) | |
678 { | |
679 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
680 if(answer == 1) // 0xFF is checksum error | |
681 { | |
682 extern uint8_t bootToBootloader; | |
683 bootToBootloader = 1; | |
684 } | |
685 } | |
686 else | |
687 return 0; | |
688 break; | |
689 | |
690 case 0x75: | |
691 receive_update_data_cpu2(); | |
692 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
693 break; | |
694 | |
695 case 0x76: | |
696 answer = receive_update_data_mainCPU_variable_firmware(); | |
697 if(answer != 0) | |
698 { | |
699 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
700 if(answer == 1) // 0xFF is checksum error | |
701 { | |
702 extern uint8_t bootToBootloader; | |
703 bootToBootloader = 1; | |
704 } | |
705 } | |
706 else | |
707 return 0; | |
708 break; | |
709 | |
710 case 0x80: | |
711 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 52, 5000)!= HAL_OK) | |
712 return 0; | |
713 if(hardware_programmProductionData(aRxBuffer) == HAL_OK) | |
714 { | |
715 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
716 } | |
717 else | |
718 return 0; | |
719 break; | |
720 | |
721 case 0x81: | |
722 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 12, 1000)!= HAL_OK) | |
723 return 0; | |
724 if(hardware_programmSecondarySerial(aRxBuffer) == HAL_OK) | |
725 { | |
726 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
727 } | |
728 else | |
729 return 0; | |
730 break; | |
731 | |
732 #else | |
733 | |
734 #ifdef SPECIALPROGRAMM | |
735 case 0x80: | |
736 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 52, 5000)!= HAL_OK) | |
737 return 0; | |
738 if(hardware_programmProductionData(aRxBuffer) == HAL_OK) | |
739 { | |
740 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
741 } | |
742 else | |
743 return 0; | |
744 break; | |
745 #endif | |
746 case 0x83: | |
747 if(HAL_UART_Receive(&UartHandle, &logStepBackwards, 1, 1000)!= HAL_OK) | |
748 return 0; | |
749 logCopyDataPtr = getFrame(98); | |
750 logCopyDataPtrTemp = logCopyDataPtr; | |
751 logCopyDataLength.u32bit = ext_flash_read_dive_raw_with_double_header_1K((uint8_t *)logCopyDataPtr, 1000000,logStepBackwards); | |
752 answer = HAL_OK; | |
753 if(answer == HAL_OK) | |
754 answer = HAL_UART_Transmit(&UartHandle, &(logCopyDataLength.u8bit.byteLow), 1,2000); | |
755 if(answer == HAL_OK) | |
756 answer = HAL_UART_Transmit(&UartHandle, &(logCopyDataLength.u8bit.byteMidLow), 1,2000); | |
757 if(answer == HAL_OK) | |
758 answer = HAL_UART_Transmit(&UartHandle, &(logCopyDataLength.u8bit.byteMidHigh), 1,2000); | |
759 if(answer == HAL_OK) | |
760 answer = HAL_UART_Transmit(&UartHandle, &(logCopyDataLength.u8bit.byteHigh), 1,2000); | |
761 logCopyDataLengthTemp = logCopyDataLength.u32bit; | |
762 while((logCopyDataLengthTemp >= 0xFFFF) && (answer == HAL_OK)) | |
763 { | |
764 answer = HAL_UART_Transmit(&UartHandle, (uint8_t *)logCopyDataPtrTemp, 0xFFFF,30000); | |
765 logCopyDataLengthTemp -= 0xFFFF; | |
766 logCopyDataPtrTemp += 0xFFFF; | |
767 } | |
768 if((logCopyDataLengthTemp > 0) && (answer == HAL_OK)) | |
769 answer = HAL_UART_Transmit(&UartHandle, (uint8_t *)logCopyDataPtrTemp, (uint16_t)logCopyDataLengthTemp,30000); | |
770 releaseFrame(98,logCopyDataPtr); | |
771 if(answer == HAL_OK) | |
772 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
773 else | |
774 return 0; | |
775 break; | |
776 | |
777 case 0x84: | |
778 logCopyDataPtr = getFrame(98); | |
779 logCopyDataPtrTemp = logCopyDataPtr; | |
780 answer = HAL_OK; | |
781 if(answer == HAL_OK) | |
782 answer = HAL_UART_Receive(&UartHandle, &logDummyByte, 1,2000); | |
783 if(answer == HAL_OK) | |
784 answer = HAL_UART_Receive(&UartHandle, &(logCopyDataLength.u8bit.byteLow), 1,2000); | |
785 if(answer == HAL_OK) | |
786 answer = HAL_UART_Receive(&UartHandle, &(logCopyDataLength.u8bit.byteMidLow), 1,2000); | |
787 if(answer == HAL_OK) | |
788 answer = HAL_UART_Receive(&UartHandle, &(logCopyDataLength.u8bit.byteMidHigh), 1,2000); | |
789 if(answer == HAL_OK) | |
790 answer = HAL_UART_Receive(&UartHandle, &(logCopyDataLength.u8bit.byteHigh), 1,2000); | |
791 logCopyDataLengthTemp = logCopyDataLength.u32bit; | |
792 while((logCopyDataLengthTemp >= 0xFFFF) && (answer == HAL_OK)) | |
793 { | |
794 answer = HAL_UART_Receive(&UartHandle, (uint8_t *)logCopyDataPtrTemp, 0xFFFF,30000); | |
795 logCopyDataLengthTemp -= 0xFFFF; | |
796 logCopyDataPtrTemp += 0xFFFF; | |
797 } | |
798 if((logCopyDataLengthTemp > 0) && (answer == HAL_OK)) | |
799 answer = HAL_UART_Receive(&UartHandle, (uint8_t *)logCopyDataPtrTemp, (uint16_t)logCopyDataLengthTemp,30000); | |
800 if(answer == HAL_OK) | |
801 ext_flash_write_dive_raw_with_double_header_1K((uint8_t *)logCopyDataPtr, logCopyDataLength.u32bit); | |
802 releaseFrame(98,logCopyDataPtr); | |
803 if(answer == HAL_OK) | |
804 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
805 else | |
806 return 0; | |
807 break; | |
808 | |
809 case 0x85: | |
810 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
811 logCopyDataPtr = getFrame(98); | |
812 ext_flash_read_header_memory((uint8_t *)logCopyDataPtr); | |
813 for(int i=0;i<8;i++) | |
814 HAL_UART_Transmit(&UartHandle, (uint8_t *)(logCopyDataPtr + (0x8000 * i)), (uint16_t)0x8000,60000); | |
815 releaseFrame(98,logCopyDataPtr); | |
816 break; | |
817 | |
818 case 0x86: | |
819 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
820 logCopyDataPtr = getFrame(98); | |
821 for(int i=0;i<8;i++) | |
822 HAL_UART_Receive(&UartHandle, (uint8_t *)(logCopyDataPtr + (0x8000 * i)), (uint16_t)0x8000,60000); | |
823 ext_flash_write_header_memory((uint8_t *)logCopyDataPtr); | |
824 releaseFrame(98,logCopyDataPtr); | |
825 break; | |
826 | |
827 case 0x87: | |
828 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 4, 1000)!= HAL_OK) | |
829 return 0; | |
830 if(((aRxBuffer[0] ^ aRxBuffer[2]) != 0xFF) || ((aRxBuffer[1] ^ aRxBuffer[3]) != 0xFF)) | |
831 return 0; | |
832 totalDiveCount.u8bit.byteLow = aRxBuffer[1]; | |
833 totalDiveCount.u8bit.byteHigh = aRxBuffer[0]; | |
834 ext_flash_repair_SPECIAL_dive_numbers_starting_count_with(totalDiveCount.u16bit); | |
835 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
836 break; | |
837 #endif | |
838 } | |
839 | |
840 // was service command? Yes, finish and exit | |
841 if(count) | |
842 { | |
843 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, count,10000)!= HAL_OK) | |
844 return 0; | |
845 else | |
846 return prompt4D4C(receiveStartByteUart); | |
847 } | |
848 } | |
849 | |
850 | |
851 // download mode commands | |
852 switch(type) | |
853 { | |
854 // return of command for almost all commands | |
855 case 0x60: // get model + features | |
856 case 0x61: // get all headers full (256 bytes) | |
857 case 0x62: // set clock | |
858 case 0x63: // set custom text | |
859 case 0x66: // get dive profile | |
860 case 0x69: // get serial, old version numbering, custom text | |
861 case 0x6A: // get model | |
862 case 0x6B: // get specific firmware version | |
863 case 0x6D: // get all compact headers (16 byte) | |
864 case 0x6E: // display text | |
865 case 0x70: // read min, default, max setting | |
866 case 0x72: // read setting | |
867 case 0x77: // write setting | |
868 case 0x78: // reset all settings | |
869 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 1, 1000)!= HAL_OK) | |
870 return 0; | |
871 break; | |
872 | |
873 // start communication (again) | |
874 case 0xBB: | |
875 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 2, 1000)!= HAL_OK) | |
876 return 0; | |
877 else | |
878 return prompt4D4C(receiveStartByteUart); | |
879 | |
880 // stop communication | |
881 case 0xFF: | |
882 HAL_UART_Transmit(&UartHandle, (uint8_t*)&aTxBuffer, 1, 1000); | |
883 return 0; | |
884 | |
885 default: | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
886 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); |
38 | 887 break; |
888 } | |
889 | |
890 switch(type) | |
891 { | |
892 case 0x62: | |
893 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 6, 2000)!= HAL_OK) | |
894 return 0; | |
895 break; | |
896 case 0x63: | |
897 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 60, 5000)!= HAL_OK) | |
898 return 0; | |
899 break; | |
900 case 0x66: | |
901 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 1, 1000)!= HAL_OK) | |
902 return 0; | |
903 break; | |
904 case 0x6B: | |
905 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 1, 1000)!= HAL_OK) | |
906 return 0; | |
907 break; | |
908 case 0x6E: | |
909 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 16, 5000)!= HAL_OK) | |
910 return 0; | |
911 break; | |
912 case 0x77: | |
913 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 5, 5000)!= HAL_OK) | |
914 return 0; | |
915 break; | |
916 case 0x72: | |
917 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 1, 5000)!= HAL_OK) | |
918 return 0; | |
919 break; | |
920 case 0x70: | |
921 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 1, 5000)!= HAL_OK) | |
922 return 0; | |
923 break; | |
924 } | |
925 | |
926 switch(type) | |
927 { | |
928 /* common to standard and bootloader */ | |
929 | |
930 // get model + features | |
931 case 0x60: | |
932 aTxBuffer[count++] = 0x00; // hardware descriptor HIGH byte | |
933 aTxBuffer[count++] = 0x3B; // hardware descriptor LOW byte // 0x3B is OSTC4 // 0x1A is OTSC3 | |
934 aTxBuffer[count++] = 0x00; // feature descriptor HIGH byte | |
138 | 935 aTxBuffer[count++] = 0x00; // feature descriptor LOW byte |
38 | 936 aTxBuffer[count++] = 0x43; // model id |
937 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
938 break; | |
939 | |
940 // get model | |
941 case 0x6A: | |
942 aTxBuffer[count++] = 0x3B; // 0x3B is OSTC4 // 0x1A is OTSC3 | |
943 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
944 break; | |
945 | |
946 // get all firmware version and status (OSTC4 only) | |
947 case 0x6B: | |
948 switch(*aRxBuffer) | |
949 { | |
950 case 0xFF: | |
951 // firmware | |
952 aTxBuffer[count++] = firmwareDataGetPointer()->versionFirst; | |
953 aTxBuffer[count++] = firmwareDataGetPointer()->versionSecond; | |
954 aTxBuffer[count++] = firmwareDataGetPointer()->versionThird; | |
955 aTxBuffer[count++] = firmwareDataGetPointer()->versionBeta; | |
956 break; | |
957 case 0xFE: | |
958 // RTE | |
959 getActualRTEandFONTversion(&tempHigh, &tempLow, 0, 0); // RTE | |
960 aTxBuffer[count++] = tempHigh; | |
961 aTxBuffer[count++] = tempLow; | |
962 aTxBuffer[count++] = 0; | |
963 aTxBuffer[count++] = 0; | |
964 break; | |
965 case 0x10: | |
966 getActualRTEandFONTversion( 0, 0, &tempHigh, &tempLow); // font | |
967 aTxBuffer[count++] = tempHigh; | |
968 aTxBuffer[count++] = tempLow; | |
969 aTxBuffer[count++] = 0; | |
970 aTxBuffer[count++] = 0; | |
971 break; | |
972 default: | |
973 // not supported | |
974 aTxBuffer[count++] = 0xFF; | |
975 aTxBuffer[count++] = 0xFF; | |
976 aTxBuffer[count++] = 0xFF; | |
977 aTxBuffer[count++] = 0xFF; | |
978 break; | |
979 /* Jef Driesen Test | |
980 default: | |
981 // not supported | |
982 aTxBuffer[count++] = 0x1; | |
983 aTxBuffer[count++] = 0x1; | |
984 aTxBuffer[count++] = 0x1; | |
985 aTxBuffer[count++] = 0x1; | |
986 break; | |
987 */ | |
988 } | |
989 /* | |
990 // serial | |
991 aTxBuffer[count++] = pSettings->serialLow; | |
992 aTxBuffer[count++] = pSettings->serialHigh; | |
993 // batch code (date) | |
994 hardwareBatchCode(&tempHigh, &tempLow); | |
995 aTxBuffer[count++] = tempLow; | |
996 aTxBuffer[count++] = tempHigh; | |
997 // status and status detail (future feature) | |
998 aTxBuffer[count++] = 0; | |
999 aTxBuffer[count++] = 0; | |
1000 aTxBuffer[count++] = 0; | |
1001 aTxBuffer[count++] = 0; | |
1002 */ | |
1003 // prompt | |
1004 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1005 break; | |
1006 | |
1007 // display text | |
1008 case 0x6E: | |
1009 for(int i=0;i<16;i++) | |
1010 display_text[i] = aRxBuffer[i]; | |
1011 display_text[15] = 0; | |
1012 display_text[255] = 16; | |
1013 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1014 break; | |
1015 | |
1016 // version / identify | |
1017 case 0x69: | |
1018 #ifndef BOOTLOADER_STANDALONE | |
1019 aTxBuffer[count++] = pSettings->serialLow; | |
1020 aTxBuffer[count++] = pSettings->serialHigh; | |
1021 aTxBuffer[count++] = firmwareVersion_16bit_low(); | |
1022 aTxBuffer[count++] = firmwareVersion_16bit_high(); | |
1023 memcpy(&aTxBuffer[count], pSettings->customtext, 60); | |
1024 #else | |
1025 aTxBuffer[count++] = 0;//pSettings->serialLow; | |
1026 aTxBuffer[count++] = 0;//pSettings->serialHigh; | |
1027 aTxBuffer[count++] = 0;//firmwareVersion_16bit_low(); | |
1028 aTxBuffer[count++] = 0;//firmwareVersion_16bit_high(); | |
1029 memset(&aTxBuffer[count], 0, 60); | |
1030 #endif | |
1031 count += 60; | |
1032 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1033 break; | |
1034 | |
1035 #ifndef BOOTLOADER_STANDALONE | |
1036 //Reset all setting | |
1037 case 0x78: | |
1038 set_settings_to_Standard(); | |
1039 updateSettingsAndMenuOnExit = 1; | |
1040 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1041 break; | |
1042 #endif | |
1043 | |
1044 #ifndef BOOTLOADER_STANDALONE | |
1045 // full headers (256 byte) | |
1046 case 0x61: | |
1047 for(int StepBackwards = 255; StepBackwards > -1; StepBackwards--) | |
1048 { | |
1049 logbook_getHeader(StepBackwards, &logbookHeader); | |
1050 plogbookHeaderOSTC3 = logbook_build_ostc3header(&logbookHeader); | |
1051 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)plogbookHeaderOSTC3, 256,5000)!= HAL_OK) | |
1052 return 0; | |
1053 } | |
1054 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1055 break; | |
1056 | |
1057 // compact headers (16 byte) | |
1058 case 0x6D: | |
1059 for(int StepBackwards = 255; StepBackwards > -1; StepBackwards--) | |
1060 { | |
1061 logbook_getHeader(StepBackwards, &logbookHeader); | |
1062 plogbookHeaderOSTC3compact = logbook_build_ostc3header_compact(&logbookHeader); | |
1063 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)plogbookHeaderOSTC3compact, 16,5000)!= HAL_OK) | |
1064 return 0; | |
1065 } | |
1066 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1067 break; | |
1068 | |
1069 // set clock & date | |
1070 case 0x62: | |
1071 // ToDo | |
1072 stimestructure.Hours = aRxBuffer[0]; | |
1073 stimestructure.Minutes = aRxBuffer[1]; | |
1074 stimestructure.Seconds = aRxBuffer[2]; | |
1075 sdatestructure.Month = aRxBuffer[3]; | |
1076 sdatestructure.Date = aRxBuffer[4]; | |
1077 sdatestructure.Year = aRxBuffer[5]; // This parameter must be a number between Min_Data = 0 and Max_Data = 99 | |
1078 setWeekday(&sdatestructure); | |
1079 | |
1080 if( ( stimestructure.Hours < 24 ) | |
1081 &&( stimestructure.Minutes < 60 ) | |
1082 &&( stimestructure.Seconds < 60 ) | |
1083 &&( sdatestructure.Month < 13 ) | |
1084 &&( sdatestructure.Date < 32 ) | |
1085 &&( sdatestructure.Year < 100 )) | |
1086 { | |
1087 setTime(stimestructure); | |
1088 setDate(sdatestructure); | |
1089 set_globalState(StUART_RTECONNECT); | |
1090 HAL_Delay(1); | |
1091 set_globalState(StUART_STANDARD); | |
1092 } | |
1093 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1094 break; | |
1095 | |
1096 case 0x63: | |
1097 for(int i=0;i<60;i++) | |
1098 pSettings->customtext[i] = aRxBuffer[i]; | |
1099 pSettings->customtext[59] = 0; | |
1100 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1101 break; | |
1102 | |
1103 // get dive profile | |
1104 case 0x66: | |
1105 logbook_getHeader(255 - aRxBuffer[0], &logbookHeader); | |
1106 plogbookHeaderOSTC3 = logbook_build_ostc3header(&logbookHeader); | |
1107 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)plogbookHeaderOSTC3, 256,5000)!= HAL_OK) | |
1108 return 0; | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1109 ext_flash_open_read_sample(255 - aRxBuffer[0], &sampleTotalLength); |
38 | 1110 while(sampleTotalLength >= 128) |
1111 { | |
1112 ext_flash_read_next_sample_part(aTxBuffer,128); | |
1113 sampleTotalLength -= 128; | |
1114 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 128,5000)!= HAL_OK) | |
1115 return 0; | |
1116 } | |
1117 if(sampleTotalLength) | |
1118 { | |
1119 ext_flash_read_next_sample_part(aTxBuffer,sampleTotalLength); | |
1120 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, sampleTotalLength,5000)!= HAL_OK) | |
1121 return 0; | |
1122 } | |
1123 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1124 break; | |
1125 | |
1126 // read min,default,max setting | |
1127 case 0x70: | |
1128 count += readDataLimits__8and16BitValues_4and7BytesOutput(aRxBuffer[0],&aTxBuffer[count]); | |
1129 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1130 break; | |
1131 | |
1132 // read setting | |
1133 case 0x72: | |
1134 readData(aRxBuffer[0],&aTxBuffer[count]); | |
1135 count += 4; | |
1136 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1137 break; | |
1138 | |
1139 // write setting | |
1140 case 0x77: | |
1141 writeData(aRxBuffer); | |
1142 updateSettingsAndMenuOnExit = 1; | |
1143 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1144 break; | |
1145 #else | |
1146 /* bootloader dummies */ | |
1147 // full headers (256 byte) | |
1148 case 0x61: | |
1149 for(int StepBackwards = 0;StepBackwards<256;StepBackwards++) | |
1150 { | |
1151 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)dummyForBootloader, 256,5000)!= HAL_OK) | |
1152 return 0; | |
1153 } | |
1154 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1155 break; | |
1156 // compact headers (16 byte) | |
1157 case 0x6D: | |
1158 for(int StepBackwards = 0;StepBackwards<256;StepBackwards++) | |
1159 { | |
1160 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)dummyForBootloader, 16,5000)!= HAL_OK) | |
1161 return 0; | |
1162 } | |
1163 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1164 break; | |
1165 // set clock & date | |
1166 case 0x62: | |
1167 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1168 break; | |
1169 // set custom text | |
1170 case 0x63: | |
1171 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1172 break; | |
1173 // get dive profile | |
1174 case 0x66: | |
1175 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)dummyForBootloader, 256,5000)!= HAL_OK) | |
1176 return 0; | |
1177 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1178 break; | |
1179 // read min,default,max setting | |
1180 // read settings | |
1181 | |
1182 | |
1183 case 0x72: | |
1184 memcpy(&aTxBuffer[count], dummyForBootloader, 4); | |
1185 count += 4; | |
1186 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1187 break; | |
1188 // write settings | |
1189 case 0x77: | |
1190 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | |
1191 break; | |
1192 #endif | |
1193 } | |
1194 | |
1195 if(count) | |
1196 { | |
1197 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, count,10000)!= HAL_OK) | |
1198 return 0; | |
1199 else | |
1200 return prompt4D4C(receiveStartByteUart); | |
1201 } | |
1202 return 0; | |
1203 } | |
1204 | |
1205 | |
1206 HAL_StatusTypeDef receive_uart_large_size(UART_HandleTypeDef *huart, uint8_t *pData, uint32_t Size) | |
1207 { | |
316
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
1208 uint16_t length_16k_blocks; |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
1209 uint16_t length_16k_remainder; |
38 | 1210 uint32_t temp; |
1211 HAL_StatusTypeDef result = HAL_OK; | |
1212 uint32_t pDataLocal; | |
1213 | |
316
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
1214 length_16k_blocks = (uint16_t) (Size / 0x3FFF); |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
1215 temp = length_16k_blocks; |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
1216 temp *= 0x3FFF; |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
1217 length_16k_remainder = (uint16_t) ( Size - temp); |
38 | 1218 |
1219 pDataLocal = (uint32_t)pData; | |
1220 | |
316
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
1221 |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
1222 while((result == HAL_OK) && length_16k_blocks) |
38 | 1223 { |
316
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
1224 result = HAL_UART_Receive(&UartHandle, (uint8_t *)pDataLocal, 0x3FFF , UART_TIMEOUT_LARGE_BLOCK); |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
1225 pDataLocal += 0x3FFF; |
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
1226 length_16k_blocks--; |
38 | 1227 } |
316
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
1228 if((result == HAL_OK) && length_16k_remainder) |
38 | 1229 { |
316
4da2bffb07ca
Bugfix text display in update mode (flipped display) and reduction of timeout in case of a failed firmware update
ideenmodellierer
parents:
236
diff
changeset
|
1230 result = HAL_UART_Receive(&UartHandle, (uint8_t *)pDataLocal, length_16k_remainder , UART_TIMEOUT_LARGE_BLOCK); |
38 | 1231 } |
1232 return result; | |
1233 } | |
1234 | |
1235 | |
1236 /* for safety reason (memory blocking this code is main and sub */ | |
1237 | |
1238 #ifdef BOOTLOADER_STANDALONE | |
1239 | |
1240 uint8_t receive_update_data_cpu2(void) | |
1241 { | |
1242 uint8_t answer; | |
1243 | |
1244 uint8_t* pBuffer = (uint8_t*)getFrame(20); | |
1245 answer = receive_update_data_cpu2_sub(pBuffer); | |
1246 releaseFrame(20,(uint32_t)pBuffer); | |
1247 return answer; | |
1248 } | |
1249 | |
1250 | |
1251 uint8_t receive_update_data_cpu2_sub(uint8_t* pBuffer) | |
1252 { | |
1253 uint8_t sBuffer[10]; | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1254 uint32_t length, offsetTotal, checksum, checksumCalc; |
38 | 1255 uint8_t id; |
1256 const uint8_t id_RTE = 0xFE; | |
1257 | |
1258 //Get length | |
1259 if(HAL_UART_Receive(&UartHandle, pBuffer, 4,5000)!= HAL_OK) // 58000 | |
1260 { | |
1261 return 0; | |
1262 } | |
1263 length = 256 * 256 * 256 * (uint32_t)pBuffer[0] + 256 * 256 * (uint32_t)pBuffer[1] + 256 * (uint32_t)pBuffer[2] + pBuffer[3]; | |
1264 | |
1265 //Get id | |
1266 if(HAL_UART_Receive(&UartHandle, pBuffer, 4,5000)!= HAL_OK) // 58000 | |
1267 { | |
1268 return 0; | |
1269 } | |
1270 id = pBuffer[0]; | |
1271 offsetTotal = 256 * 256 * 256 * (uint32_t)pBuffer[0] + 256 * 256 * (uint32_t)pBuffer[1] + 256 * (uint32_t)pBuffer[2] + pBuffer[3]; | |
1272 | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1273 // get checksum, bytes are in different order on Dev C++ code!!! |
38 | 1274 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 |
1275 { | |
1276 return 0; | |
1277 } | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1278 checksum = 256 * 256 * 256 * (uint32_t)sBuffer[3] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[1] + sBuffer[0]; |
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1279 checksumCalc = length + offsetTotal; |
38 | 1280 |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1281 // no need to get code if checksum == length is wrong |
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1282 if(checksumCalc != checksum) |
38 | 1283 { |
1284 return 0; | |
1285 } | |
1286 | |
1287 //get Code | |
1288 if(receive_uart_large_size(&UartHandle, pBuffer, length)!= HAL_OK) | |
1289 { | |
1290 return 0; | |
1291 } | |
1292 | |
1293 //get Checksum | |
1294 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 580000 | |
1295 { | |
1296 return 0; | |
1297 } | |
1298 uint32_t checksum = 256 * 256 * 256 *(uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; | |
1299 // uint32_t checksumCalc = crc32c_checksum(pBuffer, length,0,0); | |
1300 uint32_t checksumCalc = CRC_CalcBlockCRC((uint32_t*)pBuffer, length/4); | |
1301 | |
1302 if(checksum != checksumCalc) | |
1303 { | |
1304 return 0; | |
1305 } | |
1306 | |
1307 if(id != id_RTE) | |
1308 { | |
1309 strcpy(display_text,"wrong data."); | |
1310 display_text[255] = 32; | |
1311 return 0; | |
1312 } | |
1313 | |
1314 strcpy(display_text," RTE update."); | |
1315 display_text[255] = 32; | |
1316 | |
1317 return extCPU2bootloader(pBuffer,length,display_text); | |
1318 } | |
1319 #endif // BOOTLOADER_STANDALONE | |
1320 | |
1321 | |
1322 | |
1323 uint8_t receive_update_flex(uint8_t isRTEupdateALLOWED) | |
1324 { | |
1325 uint8_t answer; | |
1326 | |
1327 uint8_t* pBuffer1 = (uint8_t*)getFrame(20); | |
1328 uint8_t* pBuffer2 = (uint8_t*)getFrame(20); | |
1329 | |
1330 answer = receive_update_data_flex(pBuffer1, pBuffer2, isRTEupdateALLOWED); | |
1331 | |
1332 releaseFrame(20,(uint32_t)pBuffer1); | |
1333 releaseFrame(20,(uint32_t)pBuffer2); | |
1334 | |
1335 return answer; | |
1336 } | |
1337 | |
1338 uint8_t receive_update_data_mainCPU_firmware(void) | |
1339 { | |
1340 uint8_t answer; | |
1341 | |
1342 uint8_t* pBuffer1 = (uint8_t*)getFrame(20); | |
1343 | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1344 answer = receive_update_data_mainCPU_firmware_subroutine(1, pBuffer1, 0); |
38 | 1345 |
1346 releaseFrame(20,(uint32_t)pBuffer1); | |
1347 | |
1348 return answer; | |
1349 } | |
1350 | |
1351 /* multi buffer (long data) not tested yet */ | |
1352 uint8_t receive_update_data_mainCPU_variable_firmware(void) | |
1353 { | |
1354 uint8_t answer; | |
1355 | |
1356 uint8_t* pBuffer1 = (uint8_t*)getFrame(20); | |
1357 uint8_t* pBuffer2 = (uint8_t*)getFrame(20); | |
1358 | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1359 answer = receive_update_data_mainCPU_firmware_subroutine(2, pBuffer1, pBuffer2); |
38 | 1360 |
1361 releaseFrame(20,(uint32_t)pBuffer1); | |
1362 releaseFrame(20,(uint32_t)pBuffer2); | |
1363 | |
1364 return answer; | |
1365 } | |
1366 | |
1367 uint8_t receive_update_data_flex(uint8_t* pBuffer1, uint8_t* pBuffer2, uint8_t RTEupdateALLOWED) | |
1368 { | |
1369 uint8_t sBuffer[10]; | |
1370 uint8_t serialBuffer[10]; | |
1371 uint32_t length1, length2, lengthCompare, offsetCompare, ByteCompareStatus; | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1372 uint32_t lengthTotal, offsetTotal; |
51
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
1373 uint32_t checksum, checksumCalc = 0; |
38 | 1374 uint8_t id; |
1375 const uint8_t id_Region1_firmware = 0xFF; | |
1376 const uint8_t id_RTE = 0xFE; | |
1377 uint8_t textpointer = 0; | |
1378 | |
1379 //Get length | |
1380 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 | |
1381 { | |
1382 return 0; | |
1383 } | |
1384 lengthTotal = 256 * 256 * 256 * (uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; | |
1385 | |
1386 //Get offset and/or id (id is 0xFF for RTE, 0xFE for firmware and offset if var) | |
1387 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 | |
1388 { | |
1389 return 0; | |
1390 } | |
1391 id = sBuffer[0]; | |
1392 | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1393 checksumCalc = 256 * 256 * 256 * (uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; |
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1394 checksumCalc += lengthTotal; |
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1395 //old, does no longer work because of the fonts: checksumCalc = lengthTotal + offsetTotal; |
38 | 1396 |
1397 if((id != id_Region1_firmware) && (id != id_RTE) && (id != id_FONT) && (id != id_FONT_OLD)) | |
1398 { | |
1399 return 0; | |
1400 } | |
1401 | |
1402 // neu 110212 | |
1403 if(id == id_FONT) | |
1404 offsetTotal = 256 * 256 * 256 * (uint32_t)sBuffer[1] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[3]; | |
1405 else | |
1406 offsetTotal = 256 * 256 * 256 * (uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; | |
1407 | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1408 // get checksum, bytes are in different order on Dev C++ code!!! |
38 | 1409 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 |
1410 { | |
1411 return 0; | |
1412 } | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1413 checksum = 256 * 256 * 256 * (uint32_t)sBuffer[3] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[1] + sBuffer[0]; |
38 | 1414 |
1415 | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1416 if(checksumCalc != checksum) |
38 | 1417 { |
1418 uint8_t ptr = 0; | |
1419 strcpy(&display_text[ptr]," checksum error"); | |
1420 ptr += 15; | |
1421 strcpy(&display_text[ptr],"\n\r"); | |
1422 ptr += 2; | |
1423 ptr += gfx_number_to_string(10,0,&display_text[ptr],checksumCalc); | |
1424 display_text[ptr] = 0; | |
1425 display_text[255] = ptr + 1; | |
1426 return 0xFF; | |
1427 } | |
1428 | |
1429 //Get serial (new since 160211) | |
1430 if(HAL_UART_Receive(&UartHandle, serialBuffer, 4,5000)!= HAL_OK) | |
1431 { | |
1432 return 0; | |
1433 } | |
1434 | |
1435 if(lengthTotal > 768000) | |
1436 { | |
1437 length1 = 768000; | |
1438 length2 = lengthTotal - length1; | |
1439 } | |
1440 else | |
1441 { | |
1442 length1 = lengthTotal; | |
1443 length2 = 0; | |
1444 } | |
1445 | |
1446 if((pBuffer2 == 0) && (length2 != 0)) | |
1447 return 0; | |
1448 | |
1449 //get Code | |
1450 if(receive_uart_large_size(&UartHandle, pBuffer1, length1)!= HAL_OK) | |
1451 return 0; | |
1452 | |
1453 if(length2) | |
1454 if(receive_uart_large_size(&UartHandle, pBuffer2, length2)!= HAL_OK) | |
1455 return 0; | |
1456 | |
1457 //get Checksum | |
1458 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 | |
1459 return 0; | |
1460 | |
1461 checksum = 256 * 256 * 256 *(uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; | |
1462 // uint32_t checksumCalc = crc32c_checksum(pBuffer1, length1, pBuffer2, length2); | |
1463 if(length2) | |
1464 checksumCalc = CRC_CalcBlockCRC_moreThan768000((uint32_t*)pBuffer1, (uint32_t*)pBuffer2, lengthTotal/4); | |
1465 else | |
1466 checksumCalc = CRC_CalcBlockCRC((uint32_t*)pBuffer1, length1/4); | |
1467 | |
1468 /* check id now */ | |
1469 /* | |
1470 if(region == 2) | |
1471 { | |
1472 if((id == id_Region1_firmware) || (id == id_RTE)) | |
1473 { | |
1474 strcpy(display_text,"wrong data."); | |
1475 display_text[255] = 32; | |
1476 return 0; | |
1477 } | |
1478 } | |
1479 else | |
1480 { | |
1481 if(id != id_Region1_firmware) | |
1482 { | |
1483 strcpy(display_text,"wrong data."); | |
1484 display_text[255] = 32; | |
1485 return 0; | |
1486 } | |
1487 } | |
1488 */ | |
1489 /* test checksum */ | |
1490 if(checksum != checksumCalc) | |
1491 { | |
1492 uint8_t ptr = 0; | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1493 strcpy(&display_text[ptr]," checksum error"); |
38 | 1494 ptr += 15; |
1495 strcpy(&display_text[ptr],"\n\r"); | |
1496 display_text[ptr] = 0; | |
1497 display_text[255] = ptr + 1; | |
1498 return 0xFF; | |
1499 } | |
1500 | |
1501 if(id == id_Region1_firmware) | |
1502 { | |
1503 uint8_t ptr = 0; | |
1504 display_text[ptr++] = 'V'; | |
1505 ptr += gfx_number_to_string(2,0,&display_text[ptr],pBuffer1[0x10000] & 0x1F); | |
1506 display_text[ptr++] = '.'; | |
1507 ptr += gfx_number_to_string(2,0,&display_text[ptr],pBuffer1[0x10001] & 0x1F); | |
1508 display_text[ptr++] = '.'; | |
1509 ptr += gfx_number_to_string(2,0,&display_text[ptr],pBuffer1[0x10002] & 0x1F); | |
1510 display_text[ptr++] = ' '; | |
1511 if(pBuffer1[0x10003]) | |
1512 { | |
1513 strcpy(&display_text[ptr],"beta "); | |
1514 ptr +=5; | |
1515 } | |
1516 strcpy(&display_text[ptr],"\n\rpreparing for install."); | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1517 ptr += 25; |
38 | 1518 display_text[255] = ptr + 1; |
1519 } | |
1520 else if(id == id_RTE) | |
1521 { | |
1522 if(RTEupdateALLOWED) | |
1523 { | |
1524 strcpy(display_text," RTE update.\n\r"); | |
1525 textpointer = 0; | |
1526 while((display_text[textpointer] != 0) && (textpointer < 50)) | |
1527 textpointer++; | |
1528 #ifndef BOOTLOADER_STANDALONE | |
1529 if(textpointer < 50) | |
1530 { | |
1531 // display_text[textpointer++] = | |
1532 display_text[textpointer++] = '\025'; | |
1533 display_text[textpointer++] = TXT_2BYTE; | |
1534 display_text[textpointer++] = TXT2BYTE_DecoDataLost; | |
1535 display_text[textpointer] = 0; | |
1536 } | |
1537 #endif | |
1538 display_text[255] = textpointer+1; | |
1539 return extCPU2bootloader(pBuffer1,length1,display_text); | |
1540 } | |
1541 else | |
1542 return 0xFF; | |
1543 } | |
1544 else | |
1545 //if(region == 2) | |
1546 { | |
1547 uint8_t ptr = 0; | |
1548 ptr += gfx_number_to_string(7,0,&display_text[ptr],lengthTotal); | |
1549 strcpy(&display_text[ptr]," bytes with "); | |
1550 ptr += 12; | |
1551 ptr += gfx_number_to_string(7,0,&display_text[ptr],offsetTotal); | |
1552 strcpy(&display_text[ptr]," offset"); | |
1553 ptr += 7; | |
1554 strcpy(&display_text[ptr],"\n\rpreparing for install."); | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1555 ptr += 25; |
38 | 1556 display_text[255] = ptr + 1; |
1557 } | |
1558 | |
1559 | |
1560 // only non RTE !! | |
1561 uint8_t* pBufferCompare = (uint8_t*)getFrame(20); | |
1562 ByteCompareStatus = 0; | |
1563 | |
1564 if(id == id_Region1_firmware) | |
1565 { | |
1566 /* standard firmware limited to 768000 */ | |
1567 if(ext_flash_read_firmware(pBufferCompare,4,0) != 0xFFFFFFFF) | |
1568 ext_flash_erase_firmware(); | |
1569 ext_flash_write_firmware(pBuffer1, length1); | |
1570 lengthCompare = ext_flash_read_firmware(pBufferCompare,768000,0); | |
1571 | |
1572 if(lengthCompare != length1) | |
1573 ByteCompareStatus = 10000; | |
1574 for(int i = 0; i < length1; i++) | |
1575 { | |
1576 if(pBuffer1[0] != pBufferCompare[0]) | |
1577 ByteCompareStatus++; | |
1578 } | |
1579 } | |
1580 else | |
1581 //if(region == 2) | |
1582 { | |
1583 /* upper region firmware can be larger (1MB) */ | |
1584 if(ext_flash_read_firmware2(0, pBufferCompare,4, 0,0) != 0xFFFFFFFF) | |
1585 ext_flash_erase_firmware2(); | |
1586 ext_flash_write_firmware2(offsetTotal, pBuffer1, length1, pBuffer2, length2); | |
1587 lengthCompare = ext_flash_read_firmware2(&offsetCompare, pBufferCompare,768000, 0,768000); | |
1588 | |
1589 if(lengthCompare != length1 + length2) | |
1590 ByteCompareStatus = 10000; | |
1591 if(offsetTotal != offsetCompare) | |
1592 ByteCompareStatus += 20000; | |
1593 for(int i = 0; i < length1; i++) | |
1594 { | |
1595 if(pBuffer1[0] != pBufferCompare[0]) | |
1596 ByteCompareStatus++; | |
1597 } | |
1598 | |
1599 lengthCompare = ext_flash_read_firmware2(0, 0,768000, pBufferCompare,768000); | |
1600 for(int i = 0; i < length2; i++) | |
1601 { | |
1602 if(pBuffer2[0] != pBufferCompare[0]) | |
1603 ByteCompareStatus++; | |
1604 } | |
1605 } | |
1606 | |
1607 releaseFrame(20,(uint32_t)pBufferCompare); | |
1608 | |
1609 if(ByteCompareStatus != 0) | |
1610 { | |
1611 strcpy(&display_text[0],"\n\rcopy error."); | |
1612 display_text[255] = 21; | |
1613 return 0; | |
1614 } | |
1615 else | |
1616 { | |
1617 strcpy(&display_text[0],"\n\rready to install."); | |
1618 display_text[255] = 21; | |
1619 return 1; | |
1620 } | |
1621 } | |
1622 | |
1623 | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1624 uint8_t receive_update_data_mainCPU_firmware_subroutine(uint8_t region, uint8_t* pBuffer1, uint8_t* pBuffer2) |
38 | 1625 { |
1626 uint8_t sBuffer[10]; | |
1627 uint32_t length1, length2, lengthCompare, offsetCompare, ByteCompareStatus; | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1628 uint32_t lengthTotal, offsetTotal, checksum, checksumCalc = 0; |
38 | 1629 uint8_t id; |
1630 | |
1631 //Get length | |
1632 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 | |
1633 return 0; | |
1634 | |
1635 lengthTotal = 256 * 256 * 256 * (uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; | |
1636 | |
1637 //Get offset and/or id (id is 0xFF for RTE, 0xFE for firmware and offset if var) | |
1638 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 | |
1639 return 0; | |
1640 | |
1641 id = sBuffer[0]; | |
1642 | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1643 checksumCalc = 256 * 256 * 256 * (uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; |
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1644 checksumCalc += lengthTotal; |
38 | 1645 |
1646 if((id != id_Region1_firmware) && (id != id_RTE) && (id != id_FONT) && (id != id_FONT_OLD)) | |
1647 return 0; | |
1648 | |
1649 if(id == id_FONT) | |
1650 offsetTotal = 256 * 256 * 256 * (uint32_t)sBuffer[1] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[3]; | |
1651 // alt, prior to id for font | |
1652 else | |
1653 offsetTotal = 256 * 256 * 256 * (uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; | |
1654 | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1655 // get checksum, bytes are in different order on Dev C++ code!!! |
38 | 1656 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 |
1657 return 0; | |
1658 | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1659 checksum = 256 * 256 * 256 * (uint32_t)sBuffer[3] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[1] + sBuffer[0]; |
38 | 1660 |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1661 //old: checksumCalc = lengthTotal + offsetTotal; |
38 | 1662 |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1663 if(checksumCalc != checksum) |
38 | 1664 { |
1665 uint8_t ptr = 0; | |
1666 strcpy(&display_text[ptr]," checksum error"); | |
1667 ptr += 15; | |
1668 strcpy(&display_text[ptr],"\n\r"); | |
1669 ptr += 2; | |
1670 ptr += gfx_number_to_string(10,0,&display_text[ptr],checksumCalc); | |
1671 display_text[ptr] = 0; | |
1672 display_text[255] = ptr + 1; | |
1673 return 0xFF; | |
1674 } | |
1675 | |
1676 if(lengthTotal > 768000) | |
1677 { | |
1678 length1 = 768000; | |
1679 length2 = lengthTotal - length1; | |
1680 } | |
1681 else | |
1682 { | |
1683 length1 = lengthTotal; | |
1684 length2 = 0; | |
1685 } | |
1686 | |
1687 if((pBuffer2 == 0) && (length2 != 0)) | |
1688 return 0; | |
1689 | |
1690 //get Code | |
1691 if(receive_uart_large_size(&UartHandle, pBuffer1, length1)!= HAL_OK) | |
1692 return 0; | |
1693 | |
1694 if(length2) | |
1695 if(receive_uart_large_size(&UartHandle, pBuffer2, length2)!= HAL_OK) | |
1696 return 0; | |
1697 | |
1698 //get Checksum | |
1699 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 | |
1700 return 0; | |
1701 | |
1702 checksum = 256 * 256 * 256 *(uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; | |
1703 // uint32_t checksumCalc = crc32c_checksum(pBuffer1, length1, pBuffer2, length2); | |
1704 if(length2) | |
1705 checksumCalc = CRC_CalcBlockCRC_moreThan768000((uint32_t*)pBuffer1, (uint32_t*)pBuffer2, lengthTotal/4); | |
1706 else | |
1707 checksumCalc = CRC_CalcBlockCRC((uint32_t*)pBuffer1, length1/4); | |
1708 | |
1709 /* check id now */ | |
1710 if(region == 2) | |
1711 { | |
1712 if((id == id_Region1_firmware) || (id == id_RTE)) | |
1713 { | |
1714 strcpy(display_text,"wrong data."); | |
1715 display_text[255] = 32; | |
1716 return 0; | |
1717 } | |
1718 } | |
1719 else | |
1720 { | |
1721 if(id != id_Region1_firmware) | |
1722 { | |
1723 strcpy(display_text,"wrong data."); | |
1724 display_text[255] = 32; | |
1725 return 0; | |
1726 } | |
1727 } | |
1728 | |
1729 /* test checksum */ | |
1730 if(checksum != checksumCalc) | |
1731 { | |
1732 uint8_t ptr = 0; | |
1733 strcpy(&display_text[ptr]," pruefsummen error"); | |
1734 ptr += 15; | |
1735 strcpy(&display_text[ptr],"\n\r"); | |
1736 display_text[ptr] = 0; | |
1737 display_text[255] = ptr + 1; | |
1738 return 0xFF; | |
1739 } | |
1740 | |
1741 if(region == 2) | |
1742 { | |
1743 uint8_t ptr = 0; | |
1744 ptr += gfx_number_to_string(7,0,&display_text[ptr],lengthTotal); | |
1745 strcpy(&display_text[ptr]," bytes with "); | |
1746 ptr += 12; | |
1747 ptr += gfx_number_to_string(7,0,&display_text[ptr],offsetTotal); | |
1748 strcpy(&display_text[ptr]," offset"); | |
1749 ptr += 7; | |
1750 strcpy(&display_text[ptr],"\n\rpreparing for install."); | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1751 ptr += 25; |
38 | 1752 display_text[255] = ptr + 1; |
1753 | |
1754 } | |
1755 else | |
1756 { | |
1757 uint8_t ptr = 0; | |
1758 display_text[ptr++] = 'V'; | |
1759 ptr += gfx_number_to_string(2,0,&display_text[ptr],pBuffer1[0x10000] & 0x1F); | |
1760 display_text[ptr++] = '.'; | |
1761 ptr += gfx_number_to_string(2,0,&display_text[ptr],pBuffer1[0x10001] & 0x1F); | |
1762 display_text[ptr++] = '.'; | |
1763 ptr += gfx_number_to_string(2,0,&display_text[ptr],pBuffer1[0x10002] & 0x1F); | |
1764 display_text[ptr++] = ' '; | |
1765 if(pBuffer1[0x10003]) | |
1766 { | |
1767 strcpy(&display_text[ptr],"beta "); | |
1768 ptr +=5; | |
1769 } | |
1770 strcpy(&display_text[ptr],"\n\rpreparing for install."); | |
236
ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
heinrichsweikamp
parents:
229
diff
changeset
|
1771 ptr += 25; |
38 | 1772 display_text[255] = ptr + 1; |
1773 } | |
1774 | |
1775 uint8_t* pBufferCompare = (uint8_t*)getFrame(20); | |
1776 ByteCompareStatus = 0; | |
1777 | |
1778 if(region == 2) | |
1779 { | |
1780 /* upper region firmware can be larger (1MB) */ | |
1781 if(ext_flash_read_firmware2(0, pBufferCompare,4, 0,0) != 0xFFFFFFFF) | |
1782 ext_flash_erase_firmware2(); | |
1783 ext_flash_write_firmware2(offsetTotal, pBuffer1, length1, pBuffer2, length2); | |
1784 lengthCompare = ext_flash_read_firmware2(&offsetCompare, pBufferCompare,768000, 0,768000); | |
1785 | |
1786 if(lengthCompare != length1 + length2) | |
1787 ByteCompareStatus = 10000; | |
1788 if(offsetTotal != offsetCompare) | |
1789 ByteCompareStatus += 20000; | |
1790 for(int i = 0; i < length1; i++) | |
1791 { | |
1792 if(pBuffer1[0] != pBufferCompare[0]) | |
1793 ByteCompareStatus++; | |
1794 } | |
1795 | |
1796 lengthCompare = ext_flash_read_firmware2(0, 0,768000, pBufferCompare,768000); | |
1797 for(int i = 0; i < length2; i++) | |
1798 { | |
1799 if(pBuffer2[0] != pBufferCompare[0]) | |
1800 ByteCompareStatus++; | |
1801 } | |
1802 } | |
1803 else | |
1804 { | |
1805 /* standard firmware limited to 768000 */ | |
1806 if(ext_flash_read_firmware(pBufferCompare,4,0) != 0xFFFFFFFF) | |
1807 ext_flash_erase_firmware(); | |
1808 ext_flash_write_firmware(pBuffer1, length1); | |
1809 lengthCompare = ext_flash_read_firmware(pBufferCompare,768000,0); | |
1810 | |
1811 if(lengthCompare != length1) | |
1812 ByteCompareStatus = 10000; | |
1813 for(int i = 0; i < length1; i++) | |
1814 { | |
1815 if(pBuffer1[0] != pBufferCompare[0]) | |
1816 ByteCompareStatus++; | |
1817 } | |
1818 } | |
1819 | |
1820 releaseFrame(20,(uint32_t)pBufferCompare); | |
1821 | |
1822 if(ByteCompareStatus != 0) | |
1823 { | |
1824 strcpy(&display_text[0],"\n\rcopy error."); | |
1825 display_text[255] = 21; | |
1826 return 0; | |
1827 } | |
1828 else | |
1829 { | |
1830 strcpy(&display_text[0],"\n\rready to install."); | |
1831 display_text[255] = 21; | |
1832 return 1; | |
1833 } | |
1834 } | |
1835 | |
1836 static void tComm_Error_Handler(void) | |
1837 { | |
1838 while(1) | |
1839 {} | |
1840 } |