comparison Discovery/Src/tComm.c @ 870:bc6c90e20d9e Evo_2_23

Instrument code for Bootloader: the Bootloader was reactivated. Because some functions have changed in the past years an instrumentation had to be done to avoid compile issues (e.g. no multilanguage in Bootloader, no special fonts)
author Ideenmodellierer
date Mon, 12 Aug 2024 22:25:46 +0200
parents 667093daa937
children 5e027b0f7475
comparison
equal deleted inserted replaced
869:4e10a3e087a1 870:bc6c90e20d9e
77 # include "logbook.h" 77 # include "logbook.h"
78 # include "tMenu.h" 78 # include "tMenu.h"
79 #else 79 #else
80 # include "base_bootloader.h" 80 # include "base_bootloader.h"
81 # include "firmwareEraseProgram.h" 81 # include "firmwareEraseProgram.h"
82 # include "text_multilanguage.h"
82 #endif 83 #endif
83 84
84 #ifdef SPECIALPROGRAMM 85 #ifdef SPECIALPROGRAMM
85 # include "firmwareEraseProgram.h" 86 # include "firmwareEraseProgram.h"
86 #endif 87 #endif
117 const uint8_t id_FONT = 0x10; 118 const uint8_t id_FONT = 0x10;
118 const uint8_t id_FONT_OLD = 0x00; 119 const uint8_t id_FONT_OLD = 0x00;
119 120
120 static BlueModTmpConfig_t BmTmpConfig = BM_CONFIG_OFF; /* Config BlueMod without storing the changes */ 121 static BlueModTmpConfig_t BmTmpConfig = BM_CONFIG_OFF; /* Config BlueMod without storing the changes */
121 static uint8_t EvaluateBluetoothSignalStrength = 0; 122 static uint8_t EvaluateBluetoothSignalStrength = 0;
123 #ifndef BOOTLOADER_STANDALONE
122 static uint8_t RequestDisconnection = 0; /* Disconnection from remote device requested */ 124 static uint8_t RequestDisconnection = 0; /* Disconnection from remote device requested */
125 static void tComm_Disconnect(void);
126 #endif
123 /* Private function prototypes -----------------------------------------------*/ 127 /* Private function prototypes -----------------------------------------------*/
124 static void tComm_Disconnect(void);
125 static void tComm_Error_Handler(void); 128 static void tComm_Error_Handler(void);
126 static uint8_t select_mode(uint8_t aRxByte); 129 static uint8_t select_mode(uint8_t aRxByte);
127 static uint8_t tComm_CheckAnswerOK(void); 130 static uint8_t tComm_CheckAnswerOK(void);
128 static uint8_t tComm_HandleBlueModConfig(void); 131 static uint8_t tComm_HandleBlueModConfig(void);
129 static void tComm_EvaluateBluetoothStrength(void); 132 static void tComm_EvaluateBluetoothStrength(void);
434 answer = HAL_ERROR; 437 answer = HAL_ERROR;
435 438
436 answer = HAL_OK; 439 answer = HAL_OK;
437 return answer; 440 return answer;
438 } 441 }
439 442 #ifndef BOOTLOADER_STANDALONE
440 void tComm_Disconnect() 443 void tComm_Disconnect()
441 { 444 {
442 uint8_t answer; 445 uint8_t answer;
443 uint8_t retrycnt = 3; 446 uint8_t retrycnt = 3;
444 char aTxDisconnect[] ="ATH\r"; 447 char aTxDisconnect[] ="ATH\r";
480 { 483 {
481 settingsGetPointer()->bluetoothActive = 0; 484 settingsGetPointer()->bluetoothActive = 0;
482 MX_Bluetooth_PowerOff(); 485 MX_Bluetooth_PowerOff();
483 } 486 }
484 } 487 }
485 488 #endif
486 489
487 uint8_t openComm(uint8_t aRxByte) 490 uint8_t openComm(uint8_t aRxByte)
488 { 491 {
489 SStateList status; 492 SStateList status;
490 uint8_t localRx; 493 uint8_t localRx;
584 SLogbookHeaderOSTC3compact * plogbookHeaderOSTC3compact; 587 SLogbookHeaderOSTC3compact * plogbookHeaderOSTC3compact;
585 uint32_t sampleTotalLength; 588 uint32_t sampleTotalLength;
586 SSettings* pSettings = settingsGetPointer(); 589 SSettings* pSettings = settingsGetPointer();
587 RTC_DateTypeDef sdatestructure; 590 RTC_DateTypeDef sdatestructure;
588 RTC_TimeTypeDef stimestructure; 591 RTC_TimeTypeDef stimestructure;
592 uint16_t index;
593 uint32_t header_profileLength, OSTC3_profileLength;
589 #else 594 #else
590 uint8_t dummyForBootloader[256] = {0}; 595 uint8_t dummyForBootloader[256] = {0};
591 #endif 596 #endif
592 uint8_t count; 597 uint8_t count;
593 uint8_t aTxBuffer[128]; 598 uint8_t aTxBuffer[128];
594 uint8_t aRxBuffer[68]; 599 uint8_t aRxBuffer[68];
595 uint8_t answer; 600 uint8_t answer;
596 uint16_t index;
597 uint32_t header_profileLength, OSTC3_profileLength;
598 aTxBuffer[0] = type; 601 aTxBuffer[0] = type;
599 aTxBuffer[1] = prompt4D4C(receiveStartByteUart); 602 aTxBuffer[1] = prompt4D4C(receiveStartByteUart);
600 uint8_t tempHigh, tempLow; 603 uint8_t tempHigh, tempLow;
601 count = 0; 604 count = 0;
602 605
1449 //get Checksum 1452 //get Checksum
1450 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 580000 1453 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 580000
1451 { 1454 {
1452 return 0; 1455 return 0;
1453 } 1456 }
1454 uint32_t checksum = 256 * 256 * 256 *(uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; 1457 checksum = 256 * 256 * 256 *(uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3];
1455 // uint32_t checksumCalc = crc32c_checksum(pBuffer, length,0,0); 1458 // uint32_t checksumCalc = crc32c_checksum(pBuffer, length,0,0);
1456 uint32_t checksumCalc = CRC_CalcBlockCRC((uint32_t*)pBuffer, length/4); 1459 checksumCalc = CRC_CalcBlockCRC((uint32_t*)pBuffer, length/4);
1457 1460
1458 if(checksum != checksumCalc) 1461 if(checksum != checksumCalc)
1459 { 1462 {
1460 return 0; 1463 return 0;
1461 } 1464 }