Mercurial > public > ostc4
comparison BootLoader/Src/base_bootlader.c @ 1048:493a5903ec20 GasConsumption
Merge with 9d9d506a82d3162b6b2323819cc08652887d7dd4 (Bootloader)
| author | Ideenmodellierer |
|---|---|
| date | Sat, 15 Nov 2025 19:29:44 +0100 |
| parents | 9d9d506a82d3 |
| children |
comparison
equal
deleted
inserted
replaced
| 1047:6fb16ca39125 | 1048:493a5903ec20 |
|---|---|
| 221 #include "stm32f4xx_hal.h" | 221 #include "stm32f4xx_hal.h" |
| 222 #include "stm32f4xx_hal_rcc.h" | 222 #include "stm32f4xx_hal_rcc.h" |
| 223 #include "stm32f4xx_hal_flash_ex.h" | 223 #include "stm32f4xx_hal_flash_ex.h" |
| 224 #include "stm32f4xx_hal_wwdg.h" | 224 #include "stm32f4xx_hal_wwdg.h" |
| 225 | 225 |
| 226 #ifdef BOOTLOADER_STANDALONE | 226 #include "font_T48_min.h" |
| 227 #include "Fonts/Font_T144_plus.h" | 227 #include "font_T24_min.h" |
| 228 #include "Fonts/Font_T84.h" | |
| 229 #include "Fonts/Font_T105.h" | |
| 230 #include "Fonts/Font_T54.h" | |
| 231 #include "Fonts/Font_T48_plus.h" | |
| 232 #include "Fonts/Font_T24.h" | |
| 233 #include "Fonts/Font_T42.h" | |
| 234 #include "Fonts/image_battery.h" | |
| 235 #include "Fonts/image_heinrichs_weikamp.h" | 228 #include "Fonts/image_heinrichs_weikamp.h" |
| 236 #include "Fonts/image_ostc.h" | |
| 237 #endif | |
| 238 | 229 |
| 239 // From Discovery/Inc (shall be shared...) | 230 // From Discovery/Inc (shall be shared...) |
| 240 #include "data_exchange_main.h" | 231 #include "data_exchange_main.h" |
| 241 #include "display.h" | 232 #include "display.h" |
| 242 #include "gfx_engine.h" | 233 #include "gfx_engine.h" |
| 246 | 237 |
| 247 // From AC6 support: | 238 // From AC6 support: |
| 248 #include <stdio.h> | 239 #include <stdio.h> |
| 249 #include <string.h> // for memcopy | 240 #include <string.h> // for memcopy |
| 250 | 241 |
| 242 | |
| 243 extern void decompressFont(const tFont* pFont, tImageComp** pFontComp); | |
| 244 | |
| 251 /* Private define ------------------------------------------------------------*/ | 245 /* Private define ------------------------------------------------------------*/ |
| 252 #define BUFFER_SIZE ((uint32_t)0x00177000) | 246 #define BUFFER_SIZE ((uint32_t)0x00177000) |
| 253 #define WRITE_READ_ADDR ((uint32_t)0x0000) | 247 #define WRITE_READ_ADDR ((uint32_t)0x0000) |
| 254 #define REFRESH_COUNT ((uint32_t)0x0569) /* SDRAM refresh counter (90Mhz SD clock) */ | 248 #define REFRESH_COUNT ((uint32_t)0x0569) /* SDRAM refresh counter (90Mhz SD clock) */ |
| 255 | 249 |
| 266 | 260 |
| 267 /* 4 bytes with trailing 0 */ | 261 /* 4 bytes with trailing 0 */ |
| 268 .signature = "mh", | 262 .signature = "mh", |
| 269 | 263 |
| 270 .release_year = 25, | 264 .release_year = 25, |
| 271 .release_month = 1, | 265 .release_month = 11, |
| 272 .release_day = 13, | 266 .release_day = 15, |
| 273 .release_sub = 0, | 267 .release_sub = 0, |
| 274 | 268 |
| 275 /* max 48 with trailing 0 */ | 269 /* max 48 with trailing 0 */ |
| 276 .release_info ="tComm with all", | 270 .release_info ="tComm with all", |
| 277 | 271 |
| 284 | 278 |
| 285 const SHardwareData HardwareData __attribute__((section(".bootloader_hardware_data"))) = | 279 const SHardwareData HardwareData __attribute__((section(".bootloader_hardware_data"))) = |
| 286 { | 280 { |
| 287 | 281 |
| 288 // first 52 bytes | 282 // first 52 bytes |
| 289 .primarySerial = 0xFFFF, | 283 .primarySerial = 0x06a4, |
| 290 .primaryLicence = 0x00, | 284 .primaryLicence = 0x00, |
| 291 .revision8bit = 0x02, | 285 .revision8bit = 0x02, |
| 292 .production_year = 0x19, | 286 .production_year = 0x19, |
| 293 .production_month = 0x01, | 287 .production_month = 0x01, |
| 294 .production_day = 0x10, | 288 .production_day = 0x10, |
| 416 HAL_GPIO_WritePin(GPIOA,GPIO_PIN_3,GPIO_PIN_SET); | 410 HAL_GPIO_WritePin(GPIOA,GPIO_PIN_3,GPIO_PIN_SET); |
| 417 HAL_Delay(10); | 411 HAL_Delay(10); |
| 418 } | 412 } |
| 419 } | 413 } |
| 420 | 414 |
| 421 | 415 int __attribute__((optimize("O0"))) main(void) |
| 422 int main(void) | |
| 423 { | 416 { |
| 424 | 417 |
| 425 /* | 418 /* |
| 426 HAL_Init(); | 419 HAL_Init(); |
| 427 SystemClock_Config(); | 420 SystemClock_Config(); |
| 447 MX_GPIO_Init(); | 440 MX_GPIO_Init(); |
| 448 | 441 |
| 449 /* button press is only 40 to 50 us low */ | 442 /* button press is only 40 to 50 us low */ |
| 450 MX_GPIO_One_Button_only_Init(); | 443 MX_GPIO_One_Button_only_Init(); |
| 451 | 444 |
| 452 uint32_t i = 500000; | 445 uint32_t i = 4000000; |
| 453 | 446 |
| 454 callForUpdate = __HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST); | 447 callForUpdate = __HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST); |
| 455 | 448 |
| 456 if(callForUpdate) | 449 if(callForUpdate) |
| 457 { | 450 { |
| 471 i--; | 464 i--; |
| 472 __NOP(); | 465 __NOP(); |
| 473 } | 466 } |
| 474 if(i) | 467 if(i) |
| 475 { | 468 { |
| 476 i = 200000; | 469 i = 4000000; |
| 477 while(!MX_GPIO_Read_The_One_Button() && i) | 470 while(!MX_GPIO_Read_The_One_Button() && i) |
| 478 { | 471 { |
| 479 i--; | 472 i--; |
| 480 __NOP(); | 473 __NOP(); |
| 481 } | 474 } |
| 482 if(i) | 475 if(i) |
| 483 { | 476 { |
| 484 i = 200000; | 477 i = 4000000; |
| 485 while(MX_GPIO_Read_The_One_Button() && i) | 478 while(MX_GPIO_Read_The_One_Button() && i) |
| 486 { | 479 { |
| 487 i--; | 480 i--; |
| 488 __NOP(); | 481 __NOP(); |
| 489 } | 482 } |
| 490 if(i) | |
| 491 { | |
| 492 i = 200000; | |
| 493 while(!MX_GPIO_Read_The_One_Button() && i) | |
| 494 { | |
| 495 i--; | |
| 496 __NOP(); | |
| 497 } | |
| 498 if(i) | |
| 499 { | |
| 500 i = 200000; | |
| 501 while(MX_GPIO_Read_The_One_Button() && i) | |
| 502 { | |
| 503 i--; | |
| 504 __NOP(); | |
| 505 } | |
| 506 } | |
| 507 } | |
| 508 } | 483 } |
| 509 } | 484 } |
| 510 } | 485 } |
| 511 | 486 |
| 512 if((i == 0) && (callForUpdate == 0)) | 487 if((i == 0) && (callForUpdate == 0)) |
| 513 firmware_JumpTo_Application(); | 488 firmware_JumpTo_Application(); |
| 514 | 489 |
| 515 MX_SPI_Init(); | 490 MX_SPI_Init(); |
| 516 SDRAM_Config(); | 491 SDRAM_Config(); |
| 492 | |
| 493 decompressFont(&FontT24min, (tImageComp**)&FontT24_Comp); | |
| 494 decompressFont(&FontT48min, (tImageComp**)&FontT48_Comp); | |
| 495 | |
| 517 HAL_Delay(100); | 496 HAL_Delay(100); |
| 518 | 497 |
| 519 GFX_init1_no_DMA(&pLayerInvisible, 2); | 498 GFX_init1_no_DMA(&pLayerInvisible, 2); |
| 520 | 499 |
| 521 TIM_BACKLIGHT_init(); | 500 TIM_BACKLIGHT_init(); |
| 707 MX_UART_Init(); | 686 MX_UART_Init(); |
| 708 MX_Bluetooth_PowerOn(); | 687 MX_Bluetooth_PowerOn(); |
| 709 tComm_init(); | 688 tComm_init(); |
| 710 | 689 |
| 711 tInfo_button_text("exit","","sleep"); | 690 tInfo_button_text("exit","","sleep"); |
| 712 tInfo_newpage("bootloader 250113"); | 691 tInfo_newpage("bootloader 251115"); |
| 713 tInfo_write("start bluetooth"); | 692 tInfo_write("start bluetooth"); |
| 714 tInfo_write(""); | |
| 715 tInfo_write(textVersion); | 693 tInfo_write(textVersion); |
| 694 #if 0 | |
| 716 if(tComm_Set_Bluetooth_Name(0) == 0xFF) | 695 if(tComm_Set_Bluetooth_Name(0) == 0xFF) |
| 696 #else | |
| 697 if(hardwareDataGetPointer()->production_bluetooth_name_set == 0xFF) | |
| 698 #endif | |
| 717 { | 699 { |
| 718 tInfo_write("init bluetooth"); | 700 tInfo_write("init bluetooth"); |
| 719 if(isNewDisplay()) | 701 tComm_StartBlueModBaseInit(); |
| 720 { | |
| 721 tComm_StartBlueModBaseInit(); | |
| 722 } | |
| 723 else | |
| 724 { | |
| 725 tComm_StartBlueModConfig(); | |
| 726 } | |
| 727 } | 702 } |
| 728 else | 703 else |
| 729 { | 704 { |
| 730 tInfo_write("bluetooth set"); | 705 tInfo_write("bluetooth set"); |
| 731 tComm_StartBlueModConfig(); | 706 tComm_StartBlueModConfig(); |
