Mercurial > public > ostc4
comparison BootLoader/Src/base_bootlader.c @ 981:c6c781a2e85b default
Merge into default
| author | heinrichsweikamp |
|---|---|
| date | Tue, 11 Feb 2025 18:12:00 +0100 |
| parents | d29e752660c5 |
| children | 5e7ad81e9ac2 |
comparison
equal
deleted
inserted
replaced
| 871:f7318457df4d | 981:c6c781a2e85b |
|---|---|
| 37 ============================================================================== | 37 ============================================================================== |
| 38 ##### bootloader specific ##### | 38 ##### bootloader specific ##### |
| 39 ============================================================================== | 39 ============================================================================== |
| 40 | 40 |
| 41 151130 hw sleep on button3 | 41 151130 hw sleep on button3 |
| 42 (MX_tell_reset_logik_alles_ok() + DataEX_call() in endlos loop) | 42 (MX_tell_reset_logik_alles_ok() + DataEX_call() in endless loop) |
| 43 | 43 |
| 44 ============================================================================== | 44 ============================================================================== |
| 45 ##### bootloader specific ##### | 45 ##### bootloader specific ##### |
| 46 ============================================================================== | 46 ============================================================================== |
| 47 | 47 |
| 87 with the NVIC_PRIORITYGROUP_2 setting. | 87 with the NVIC_PRIORITYGROUP_2 setting. |
| 88 | 88 |
| 89 ============================================================================== | 89 ============================================================================== |
| 90 ##### MainTask ##### | 90 ##### MainTask ##### |
| 91 ============================================================================== | 91 ============================================================================== |
| 92 [..] For everthing slow without importance to be 'in time'. | 92 [..] For everything slow without importance to be 'in time'. |
| 93 Like VPM and Buehlmann. | 93 Like VPM and Buehlmann. |
| 94 No sprintf and probably no GFX_SetFramesTopBottom() stuff neither. | 94 No sprintf and probably no GFX_SetFramesTopBottom() stuff neither. |
| 95 If sprintf is called while sprintf is executed it blows up everything. | 95 If sprintf is called while sprintf is executed it blows up everything. |
| 96 | 96 |
| 97 ============================================================================== | 97 ============================================================================== |
| 98 ##### Frames / the external SDRAM ##### | 98 ##### Frames / the external SDRAM ##### |
| 99 ============================================================================== | 99 ============================================================================== |
| 100 [..] The SDRAM is handled by getFrame() and releaseFrame(). | 100 [..] The SDRAM is handled by getFrame() and releaseFrame(). |
| 101 Each frame with 800*480*2 Bytes. | 101 Each frame with 800*480*2 Bytes. |
| 102 Be carefull to release every frame | 102 Be careful to release every frame |
| 103 otherwise there will be a memory leakage over time. | 103 otherwise there will be a memory leakage over time. |
| 104 housekeepingFrame() in the MainTask takes care of cleaning the frames. | 104 housekeepingFrame() in the MainTask takes care of cleaning the frames. |
| 105 All frames are filled with 0x00. This will be transparent with color of | 105 All frames are filled with 0x00. This will be transparent with color of |
| 106 CLUT_Font020 (is CLUT 0) if the alpha is set for a 16bit pair. | 106 CLUT_Font020 (is CLUT 0) if the alpha is set for a 16bit pair. |
| 107 housekeepingFrame() delays the cleaning of frames still used as screen | 107 housekeepingFrame() delays the cleaning of frames still used as screen |
| 125 | 125 |
| 126 (#) GFX_SetFramesTopBottom() and the subset | 126 (#) GFX_SetFramesTopBottom() and the subset |
| 127 GFX_SetFrameTop() + GFX_SetFrameBottom() | 127 GFX_SetFrameTop() + GFX_SetFrameBottom() |
| 128 Those do not change anything on the display but give commands to.. | 128 Those do not change anything on the display but give commands to.. |
| 129 (#) GFX_change_LTDC() The only place that changes the pointer. | 129 (#) GFX_change_LTDC() The only place that changes the pointer. |
| 130 This prevents erratic behaviour if several changes | 130 This prevents erratic behavior if several changes |
| 131 are made within one refresh rate of the screen. | 131 are made within one refresh rate of the screen. |
| 132 Is called in IRQ by PD4 and HAL_GPIO_EXTI_IRQHandler | 132 Is called in IRQ by PD4 and HAL_GPIO_EXTI_IRQHandler |
| 133 from VSYNC signal. | 133 from VSYNC signal. |
| 134 | 134 |
| 135 [..] Content | 135 [..] Content |
| 140 (#) Text by text_multilinguage.h/.c with one char | 140 (#) Text by text_multilinguage.h/.c with one char |
| 141 necessary only starting from '\x80' | 141 necessary only starting from '\x80' |
| 142 with automatic language switch by | 142 with automatic language switch by |
| 143 selected_language in SSettings | 143 selected_language in SSettings |
| 144 see openEdit_Language() in tMenuEditSystem.c | 144 see openEdit_Language() in tMenuEditSystem.c |
| 145 Therefore there are differnent functions | 145 Therefore there are different functions |
| 146 for example: | 146 for example: |
| 147 write_label_fix() for single char multilanguage | 147 write_label_fix() for single char multilanguage |
| 148 write_label_var() for strings that could include | 148 write_label_var() for strings that could include |
| 149 multilanguage as well | 149 multilanguage as well |
| 150 see GFX_write_string() to get an overview of the controls | 150 see GFX_write_string() to get an overview of the controls |
| 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 | |
| 227 #include "Fonts/Font_T144_plus.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" | |
| 236 #include "Fonts/image_ostc.h" | |
| 237 #endif | |
| 238 | |
| 226 // From Discovery/Inc (shall be shared...) | 239 // From Discovery/Inc (shall be shared...) |
| 227 #include "data_exchange_main.h" | 240 #include "data_exchange_main.h" |
| 228 #include "display.h" | 241 #include "display.h" |
| 229 #include "gfx_engine.h" | 242 #include "gfx_engine.h" |
| 230 #include "ostc.h" | 243 #include "ostc.h" |
| 250 .versionSecond = 0, | 263 .versionSecond = 0, |
| 251 .versionThird = 1, | 264 .versionThird = 1, |
| 252 .versionBeta = 1, | 265 .versionBeta = 1, |
| 253 | 266 |
| 254 /* 4 bytes with trailing 0 */ | 267 /* 4 bytes with trailing 0 */ |
| 255 .signature = "cw", | 268 .signature = "mh", |
| 256 | 269 |
| 257 .release_year = 16, | 270 .release_year = 25, |
| 258 .release_month = 4, | 271 .release_month = 1, |
| 259 .release_day = 8, | 272 .release_day = 13, |
| 260 .release_sub = 0, | 273 .release_sub = 0, |
| 261 | 274 |
| 262 /* max 48 with trailing 0 */ | 275 /* max 48 with trailing 0 */ |
| 263 .release_info ="tComm with all", | 276 .release_info ="tComm with all", |
| 264 | 277 |
| 267 .magic[1] = FIRMWARE_MAGIC_SECOND, | 280 .magic[1] = FIRMWARE_MAGIC_SECOND, |
| 268 .magic[2] = FIRMWARE_MAGIC_FIRMWARE, /* the magic byte */ | 281 .magic[2] = FIRMWARE_MAGIC_FIRMWARE, /* the magic byte */ |
| 269 .magic[3] = FIRMWARE_MAGIC_END | 282 .magic[3] = FIRMWARE_MAGIC_END |
| 270 }; | 283 }; |
| 271 | 284 |
| 272 | 285 const SHardwareData HardwareData __attribute__((section(".bootloader_hardware_data"))) = |
| 273 const SHardwareData HardwareData __attribute__((at(HARDWAREDATA_ADDRESS))) = { | 286 { |
| 274 | 287 |
| 275 // first 52 bytes | 288 // first 52 bytes |
| 276 .primarySerial = 0xFFFF, | 289 .primarySerial = 0xFFFF, |
| 277 .primaryLicence = 0xFF, | 290 .primaryLicence = 0x00, |
| 278 .revision8bit = 0xFF, | 291 .revision8bit = 0x02, |
| 279 .production_year = 0xFF, | 292 .production_year = 0x19, |
| 280 .production_month = 0xFF, | 293 .production_month = 0x01, |
| 281 .production_day = 0xFF, | 294 .production_day = 0x10, |
| 282 .production_bluetooth_name_set = 0xFF, | 295 .production_bluetooth_name_set = 0xFF, |
| 283 | 296 |
| 284 .production_info = { | 297 .production_info = { |
| 285 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | 298 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x4F,0x53,0x54,0x43, |
| 299 0x20,0x35,0x20,0x65,0x6E,0x64,0x2D,0x32,0x30,0x32,0x34, | |
| 300 0x20,0x68,0x61,0x72,0x64,0x77,0x61,0x72,0x65,0x20,0x20, | |
| 301 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20}, | |
| 302 | |
| 303 /* 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | |
| 286 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | 304 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 287 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | 305 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 288 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, | 306 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, |
| 289 | 307 */ |
| 290 // other 12 bytes (64 in total) | 308 // other 12 bytes (64 in total) |
| 291 .secondarySerial = 0xFFFF, | 309 .secondarySerial = 0xFFFF, |
| 292 .secondaryLicence = 0xFF, | 310 .secondaryLicence = 0xFF, |
| 293 .secondaryReason8bit = 0xFF, | 311 .secondaryReason8bit = 0xFF, |
| 294 .secondary_year = 0xFF, | 312 .secondary_year = 0xFF, |
| 416 uint8_t status = 0; | 434 uint8_t status = 0; |
| 417 char textVersion[32]; | 435 char textVersion[32]; |
| 418 uint8_t ptr; | 436 uint8_t ptr; |
| 419 uint32_t pOffset; | 437 uint32_t pOffset; |
| 420 | 438 |
| 439 const SHardwareData* HardwareData = hardwareDataGetPointer(); | |
| 440 | |
| 421 set_globalState(StBoot0); | 441 set_globalState(StBoot0); |
| 422 | 442 |
| 423 HAL_Init(); | 443 HAL_Init(); |
| 424 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_2); | 444 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_2); |
| 425 | 445 SystemClock_Config(); |
| 426 /* feedback for the user | 446 |
| 427 * aber sehr unsch�n beim Warmstart | 447 MX_GPIO_Init(); |
| 428 * da das letzte Bild noch lange nachleuchtet */ | |
| 429 // MX_GPIO_Backlight_max_static_only_Init(); | |
| 430 | |
| 431 | 448 |
| 432 /* button press is only 40 to 50 us low */ | 449 /* button press is only 40 to 50 us low */ |
| 433 MX_GPIO_One_Button_only_Init(); | 450 MX_GPIO_One_Button_only_Init(); |
| 434 | 451 |
| 435 uint32_t i = 500000; | 452 uint32_t i = 500000; |
| 440 { | 457 { |
| 441 i = 0; | 458 i = 0; |
| 442 } | 459 } |
| 443 else | 460 else |
| 444 if( (firmware_MainCodeIsProgammed() == 0) | 461 if( (firmware_MainCodeIsProgammed() == 0) |
| 445 || (hardwareDataGetPointer()->primarySerial == 0xFFFF) | 462 || (HardwareData->primarySerial == 0xFFFF) |
| 446 || (hardwareDataGetPointer()->production_bluetooth_name_set == 0xFF)) | 463 || (HardwareData->production_bluetooth_name_set == 0xFF)) |
| 447 { | 464 { |
| 448 i = 1; | 465 i = 1; |
| 449 } | 466 } |
| 450 else | 467 else |
| 451 { | 468 { |
| 493 } | 510 } |
| 494 | 511 |
| 495 if((i == 0) && (callForUpdate == 0)) | 512 if((i == 0) && (callForUpdate == 0)) |
| 496 firmware_JumpTo_Application(); | 513 firmware_JumpTo_Application(); |
| 497 | 514 |
| 498 SystemClock_Config(); | |
| 499 | |
| 500 MX_GPIO_Init(); | |
| 501 MX_Bluetooth_PowerOn(); | |
| 502 MX_SPI_Init(); | 515 MX_SPI_Init(); |
| 503 SDRAM_Config(); | 516 SDRAM_Config(); |
| 504 HAL_Delay(100); | 517 HAL_Delay(100); |
| 505 | 518 |
| 506 GFX_init1_no_DMA(&pLayerInvisible, 2); | 519 GFX_init1_no_DMA(&pLayerInvisible, 2); |
| 572 } | 585 } |
| 573 | 586 |
| 574 /* here comes the variable upper firmware loader */ | 587 /* here comes the variable upper firmware loader */ |
| 575 if((i == 0) && (status == HAL_OK)) | 588 if((i == 0) && (status == HAL_OK)) |
| 576 { | 589 { |
| 577 tInfo_newpage("load firmware2 data"); | 590 tInfo_newpage("load fontpack data"); |
| 578 uint8_t* pBuffer = (uint8_t*)((uint32_t)0xD0000000); /* blocked via GFX_init1_no_DMA */ | 591 uint8_t* pBuffer = (uint8_t*)((uint32_t)0xD0000000); /* blocked via GFX_init1_no_DMA */ |
| 579 firmware_load_result = ext_flash_read_firmware2(&pOffset, pBuffer,768000*2,0,0); | 592 firmware_load_result = ext_flash_read_firmware2(&pOffset, pBuffer,768000*2,0,0); |
| 580 | 593 |
| 581 if((firmware_load_result > 0) && (firmware_load_result + pOffset <= 1024000)) | 594 if((firmware_load_result > 0) && (firmware_load_result + pOffset <= 1024000)) |
| 582 { | 595 { |
| 644 } | 657 } |
| 645 } | 658 } |
| 646 | 659 |
| 647 if((i == 0) && (status == HAL_OK)) | 660 if((i == 0) && (status == HAL_OK)) |
| 648 { | 661 { |
| 649 tInfo_newpage("Done."); | 662 tInfo_newpage("done."); |
| 650 tInfo_write("Cleaning."); | 663 tInfo_write("cleaning."); |
| 651 ext_flash_erase_firmware_if_not_empty(); | 664 ext_flash_erase_firmware_if_not_empty(); |
| 652 ext_flash_erase_firmware2_if_not_empty(); | 665 ext_flash_erase_firmware2_if_not_empty(); |
| 653 tInfo_write("Reset device."); | 666 tInfo_write("reset device."); |
| 654 reset_to_firmware_using_Watchdog(); | 667 reset_to_firmware_using_Watchdog(); |
| 655 } | 668 } |
| 656 | 669 |
| 657 ptr = 0; | 670 ptr = 0; |
| 658 textVersion[ptr++] = '\021'; | 671 textVersion[ptr++] = '\020'; |
| 659 textVersion[ptr++] = 's'; | 672 textVersion[ptr++] = 's'; |
| 660 textVersion[ptr++] = 'e'; | 673 textVersion[ptr++] = 'e'; |
| 661 textVersion[ptr++] = 'r'; | 674 textVersion[ptr++] = 'r'; |
| 662 textVersion[ptr++] = 'i'; | 675 textVersion[ptr++] = 'i'; |
| 663 textVersion[ptr++] = 'a'; | 676 textVersion[ptr++] = 'a'; |
| 664 textVersion[ptr++] = 'l'; | 677 textVersion[ptr++] = 'l'; |
| 665 textVersion[ptr++] = ' '; | 678 textVersion[ptr++] = ' '; |
| 666 if(HardwareData.primarySerial == 0xFFFF) | 679 if(HardwareData->primarySerial == 0xFFFF) |
| 667 { | 680 { |
| 668 textVersion[ptr++] = 'n'; | 681 textVersion[ptr++] = 'n'; |
| 669 textVersion[ptr++] = 'o'; | 682 textVersion[ptr++] = 'o'; |
| 670 textVersion[ptr++] = 't'; | 683 textVersion[ptr++] = 't'; |
| 671 textVersion[ptr++] = ' '; | 684 textVersion[ptr++] = ' '; |
| 672 textVersion[ptr++] = 's'; | 685 textVersion[ptr++] = 's'; |
| 673 textVersion[ptr++] = 'e'; | 686 textVersion[ptr++] = 'e'; |
| 674 textVersion[ptr++] = 't'; | 687 textVersion[ptr++] = 't'; |
| 675 } | 688 } |
| 676 else if(HardwareData.secondarySerial == 0xFFFF) | 689 else if(HardwareData->secondarySerial == 0xFFFF) |
| 677 { | 690 { |
| 678 textVersion[ptr++] = '#'; | 691 textVersion[ptr++] = '#'; |
| 679 ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData.primarySerial); | 692 ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData->primarySerial); |
| 680 } | 693 } |
| 681 else | 694 else |
| 682 { | 695 { |
| 683 textVersion[ptr++] = '#'; | 696 textVersion[ptr++] = '#'; |
| 684 ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData.secondarySerial); | 697 ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData->secondarySerial); |
| 685 textVersion[ptr++] = ' '; | 698 textVersion[ptr++] = ' '; |
| 686 textVersion[ptr++] = '('; | 699 textVersion[ptr++] = '('; |
| 687 ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData.primarySerial); | 700 ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData->primarySerial); |
| 688 textVersion[ptr++] = ')'; | 701 textVersion[ptr++] = ')'; |
| 689 } | 702 } |
| 690 textVersion[ptr++] = '\020'; | 703 textVersion[ptr++] = '\020'; |
| 691 textVersion[ptr] = 0; | 704 textVersion[ptr] = 0; |
| 692 | 705 |
| 693 tInfo_button_text("Exit","","Sleep"); | 706 TIM_init(); |
| 694 tInfo_newpage("Bootloader 160602"); | 707 MX_UART_Init(); |
| 708 MX_Bluetooth_PowerOn(); | |
| 709 tComm_init(); | |
| 710 | |
| 711 tInfo_button_text("exit","","sleep"); | |
| 712 tInfo_newpage("bootloader 250113"); | |
| 695 tInfo_write("start bluetooth"); | 713 tInfo_write("start bluetooth"); |
| 696 tInfo_write(""); | 714 tInfo_write(""); |
| 697 tInfo_write(textVersion); | 715 tInfo_write(textVersion); |
| 698 tInfo_write(""); | 716 if(tComm_Set_Bluetooth_Name(0) == 0xFF) |
| 699 | 717 { |
| 700 TIM_init(); | 718 tInfo_write("init bluetooth"); |
| 701 MX_UART_Init(); | 719 if(isNewDisplay()) |
| 702 MX_Bluetooth_PowerOn(); | 720 { |
| 703 tComm_Set_Bluetooth_Name(0); | 721 tComm_StartBlueModBaseInit(); |
| 704 | 722 } |
| 705 tComm_init(); | 723 else |
| 724 { | |
| 725 tComm_StartBlueModConfig(); | |
| 726 } | |
| 727 } | |
| 728 else | |
| 729 { | |
| 730 tInfo_write("bluetooth set"); | |
| 731 tComm_StartBlueModConfig(); | |
| 732 } | |
| 733 | |
| 706 set_globalState_Base(); | 734 set_globalState_Base(); |
| 707 | 735 |
| 708 GFX_start_VSYNC_IRQ(); | 736 GFX_start_VSYNC_IRQ(); |
| 709 | 737 |
| 710 EXTILine_Buttons_Config(); | 738 EXTILine_Buttons_Config(); |
| 751 if(returnFromCommCleanUpRequest) | 779 if(returnFromCommCleanUpRequest) |
| 752 { | 780 { |
| 753 tComm_exit(); | 781 tComm_exit(); |
| 754 returnFromCommCleanUpRequest = 0; | 782 returnFromCommCleanUpRequest = 0; |
| 755 GFX_hwBackgroundOn(); | 783 GFX_hwBackgroundOn(); |
| 756 tInfo_button_text("Exit","","Sleep"); | 784 tInfo_button_text("exit","","sleep"); |
| 757 tInfo_newpage("bluetooth disonnected"); | 785 tInfo_newpage("bluetooth disonnected"); |
| 758 tInfo_write(""); | 786 tInfo_write(""); |
| 759 tInfo_write(""); | 787 tInfo_write(""); |
| 760 tInfo_write(""); | 788 tInfo_write(""); |
| 761 tInfo_write(""); | 789 tInfo_write(""); |
| 797 time_without_button_pressed_deciseconds = 0; | 825 time_without_button_pressed_deciseconds = 0; |
| 798 | 826 |
| 799 if(GFX_logoStatus() != 0) | 827 if(GFX_logoStatus() != 0) |
| 800 return; | 828 return; |
| 801 | 829 |
| 802 if(GPIO_Pin == BUTTON_BACK_PIN) // links | 830 if(GPIO_Pin == BUTTON_BACK_PIN) // left |
| 803 action = ACTION_BUTTON_BACK; | 831 action = ACTION_BUTTON_BACK; |
| 804 else | 832 else |
| 805 if(GPIO_Pin == BUTTON_ENTER_PIN) // mitte | 833 if(GPIO_Pin == BUTTON_ENTER_PIN) // center |
| 806 action = ACTION_BUTTON_ENTER; | 834 action = ACTION_BUTTON_ENTER; |
| 807 else | 835 else |
| 808 if(GPIO_Pin == BUTTON_NEXT_PIN) // rechts | 836 if(GPIO_Pin == BUTTON_NEXT_PIN) // right |
| 809 action = ACTION_BUTTON_NEXT; | 837 action = ACTION_BUTTON_NEXT; |
| 810 #ifdef BUTTON_CUSTOM_PIN | 838 #ifdef BUTTON_CUSTOM_PIN |
| 811 else | 839 else |
| 812 if(GPIO_Pin == BUTTON_CUSTOM_PIN) // extra | 840 if(GPIO_Pin == BUTTON_CUSTOM_PIN) // extra |
| 813 action = ACTION_BUTTON_CUSTOM; | 841 action = ACTION_BUTTON_CUSTOM; |
| 814 #endif | 842 #endif |
| 815 else | 843 else |
| 816 action = 0; | 844 action = 0; |
| 817 get_globalStateList(&status); | 845 get_globalStateList(&status); |
| 818 | 846 |
| 819 switch(status.base) | 847 if(status.base == BaseComm) |
| 820 { | 848 { |
| 821 case BaseComm: | |
| 822 if(action == ACTION_BUTTON_BACK) | 849 if(action == ACTION_BUTTON_BACK) |
| 823 { | 850 { |
| 824 reset_to_firmware_using_Watchdog(); | 851 reset_to_firmware_using_Watchdog(); |
| 825 } | 852 } |
| 826 break; | 853 } |
| 827 | 854 else |
| 828 default: | 855 { |
| 829 if((action == ACTION_BUTTON_NEXT) && (counterToPreventSleep == 255) && (get_globalState() == StS)) | 856 switch (action) |
| 830 { | 857 { |
| 831 while(1) | 858 case ACTION_BUTTON_NEXT: if((counterToPreventSleep == 255) && (get_globalState() == StS)) |
| 832 { | 859 { |
| 833 MX_tell_reset_logik_alles_ok(); | 860 while(1) |
| 834 DataEX_call(); | 861 { |
| 835 HAL_Delay(100); | 862 MX_tell_reset_logik_alles_ok(); |
| 836 } | 863 DataEX_call(); |
| 837 } | 864 HAL_Delay(100); |
| 838 else | 865 } |
| 839 if(action == ACTION_BUTTON_BACK) | 866 } |
| 840 { | 867 break; |
| 841 reset_to_firmware_using_Watchdog(); | 868 case ACTION_BUTTON_BACK: reset_to_firmware_using_Watchdog(); |
| 842 } | 869 break; |
| 843 else | 870 case ACTION_BUTTON_CUSTOM: if(get_globalState() == StS) |
| 844 if(action == ACTION_BUTTON_CUSTOM) | 871 { |
| 845 { | 872 gotoSleep(); |
| 846 if(get_globalState() == StS) | 873 } |
| 847 gotoSleep(); | 874 break; |
| 848 } | 875 case ACTION_BUTTON_ENTER: /* reset_to_update_using_system_reset(); old function */ |
| 849 else | 876 tComm_StartBlueModBaseInit(); /* new: factory reset bluetooth */ |
| 850 if(action == ACTION_BUTTON_ENTER) | 877 break; |
| 851 { | 878 default: |
| 852 reset_to_update_using_system_reset(); | 879 break; |
| 853 } | 880 } |
| 854 break; | |
| 855 } | 881 } |
| 856 } | 882 } |
| 857 | 883 |
| 858 | 884 |
| 859 void gotoSleep(void) | 885 void gotoSleep(void) |
| 1151 * @param None | 1177 * @param None |
| 1152 * @retval None | 1178 * @retval None |
| 1153 */ | 1179 */ |
| 1154 static void SystemClock_Config(void) | 1180 static void SystemClock_Config(void) |
| 1155 { | 1181 { |
| 1156 RCC_ClkInitTypeDef RCC_ClkInitStruct; | 1182 /* Enable Power Control clock */ |
| 1157 RCC_OscInitTypeDef RCC_OscInitStruct; | 1183 __PWR_CLK_ENABLE(); |
| 1158 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; | 1184 |
| 1159 | 1185 /* The voltage scaling allows optimizing the power consumption when the device is |
| 1160 /* Enable Power Control clock */ | 1186 clocked below the maximum system frequency, to update the voltage scaling value |
| 1161 __PWR_CLK_ENABLE(); | 1187 regarding system frequency refer to product datasheet. */ |
| 1162 | 1188 __HAL_PWR_VOLTAGESCALING_CONFIG( PWR_REGULATOR_VOLTAGE_SCALE1 ); |
| 1163 /* The voltage scaling allows optimizing the power consumption when the device is | 1189 |
| 1164 clocked below the maximum system frequency, to update the voltage scaling value | 1190 /*##-1- System Clock Configuration #########################################*/ |
| 1165 regarding system frequency refer to product datasheet. */ | 1191 /* Enable HighSpeed Oscillator and activate PLL with HSE/HSI as source */ |
| 1166 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); | 1192 RCC_OscInitTypeDef RCC_OscInitStruct = { 0 }; |
| 1167 | 1193 #ifdef DISC1_BOARD |
| 1168 /*##-1- System Clock Configuration #########################################*/ | 1194 // Use High Speed Internal (HSI) oscillator, running at 16MHz. |
| 1169 /* Enable HSE Oscillator and activate PLL with HSE as source */ | 1195 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; |
| 1170 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; | 1196 RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
| 1171 RCC_OscInitStruct.HSEState = RCC_HSE_ON; | 1197 RCC_OscInitStruct.HSICalibrationValue = 0x10; |
| 1172 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; | 1198 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; |
| 1173 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; | 1199 RCC_OscInitStruct.PLL.PLLM = 16; // HSI/16 is 1Mhz. |
| 1174 RCC_OscInitStruct.PLL.PLLM = 8; | 1200 #else |
| 1175 RCC_OscInitStruct.PLL.PLLN = 336;//360; | 1201 // Use High Speed External oscillator, running at 8MHz |
| 1176 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; | 1202 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; |
| 1177 RCC_OscInitStruct.PLL.PLLQ = 7; | 1203 RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
| 1178 HAL_RCC_OscConfig(&RCC_OscInitStruct); | 1204 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; |
| 1205 RCC_OscInitStruct.PLL.PLLM = 8; // HSE/8 is 1Mhz. | |
| 1206 #endif | |
| 1207 // System clock = PLL (1MHz) * N/p = 180 MHz. | |
| 1208 RCC_OscInitStruct.PLL.PLLN = 360; | |
| 1209 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; | |
| 1210 RCC_OscInitStruct.PLL.PLLQ = 7; | |
| 1211 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; | |
| 1212 HAL_RCC_OscConfig( &RCC_OscInitStruct ); | |
| 1179 | 1213 |
| 1180 // HAL_PWREx_ActivateOverDrive(); | 1214 // HAL_PWREx_ActivateOverDrive(); |
| 1181 HAL_PWREx_DeactivateOverDrive(); | 1215 HAL_PWREx_DeactivateOverDrive(); |
| 1182 /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 | 1216 |
| 1183 clocks dividers */ | 1217 /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ |
| 1184 RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); | 1218 RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 }; |
| 1185 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; | 1219 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK |
| 1186 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; | 1220 | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; |
| 1187 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; | 1221 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
| 1188 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; | 1222 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
| 1189 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_8);//FLASH_LATENCY_5); | 1223 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; |
| 1190 | 1224 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; |
| 1191 /*##-2- LTDC Clock Configuration ###########################################*/ | 1225 HAL_RCC_ClockConfig( &RCC_ClkInitStruct, FLASH_LATENCY_8 ); //FLASH_LATENCY_5); |
| 1192 /* LCD clock configuration */ | 1226 |
| 1193 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ | 1227 /*##-2- LTDC Clock Configuration ###########################################*/ |
| 1194 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ | 1228 /* LCD clock configuration */ |
| 1195 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */ | 1229 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ |
| 1196 /* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDIVR_8 = 48/8 = 6 Mhz */ | 1230 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ |
| 1197 | 1231 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */ |
| 1198 /* neu: 8MHz/8*300/5/8 = 7,5 MHz = 19,5 Hz bei 800 x 480 */ | 1232 /* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDIVR_8 = 48/8 = 6 Mhz */ |
| 1199 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; | 1233 |
| 1200 PeriphClkInitStruct.PLLSAI.PLLSAIN = 300;//192; | 1234 /* neu: 8MHz/8*300/5/8 = 7,5 MHz = 19,5 Hz bei 800 x 480 */ |
| 1201 PeriphClkInitStruct.PLLSAI.PLLSAIR = 5;//4; | 1235 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; |
| 1202 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8;//RCC_PLLSAIDIVR_4;// RCC_PLLSAIDIVR_2; // RCC_PLLSAIDIVR_8 | 1236 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; |
| 1203 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); | 1237 PeriphClkInitStruct.PLLSAI.PLLSAIN = 300; //192; |
| 1238 PeriphClkInitStruct.PLLSAI.PLLSAIR = 5; //4; | |
| 1239 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8;//RCC_PLLSAIDIVR_4;// RCC_PLLSAIDIVR_2; // RCC_PLLSAIDIVR_8 | |
| 1240 HAL_RCCEx_PeriphCLKConfig( &PeriphClkInitStruct ); | |
| 1204 } | 1241 } |
| 1205 | 1242 |
| 1206 | 1243 |
| 1207 /** | 1244 /** |
| 1208 * @brief This function is executed in case of error occurrence. | 1245 * @brief This function is executed in case of error occurrence. |
| 1217 { | 1254 { |
| 1218 } | 1255 } |
| 1219 } | 1256 } |
| 1220 | 1257 |
| 1221 /** | 1258 /** |
| 1222 * @brief Perform the SDRAM exernal memory inialization sequence | 1259 * @brief Perform the SDRAM external memory initialization sequence |
| 1223 * @param hsdram: SDRAM handle | 1260 * @param hsdram: SDRAM handle |
| 1224 * @param Command: Pointer to SDRAM command structure | 1261 * @param Command: Pointer to SDRAM command structure |
| 1225 * @retval None | 1262 * @retval None |
| 1226 */ | 1263 */ |
| 1227 static void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command) | 1264 static void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command) |
| 1281 | 1318 |
| 1282 /* | 1319 /* |
| 1283 static void DualBoot(void) | 1320 static void DualBoot(void) |
| 1284 { | 1321 { |
| 1285 // Set BFB2 bit to enable boot from Flash Bank2 | 1322 // Set BFB2 bit to enable boot from Flash Bank2 |
| 1286 // Allow Access to Flash control registers and user Falsh | 1323 // Allow Access to Flash control registers and user Flash |
| 1287 HAL_FLASH_Unlock(); | 1324 HAL_FLASH_Unlock(); |
| 1288 | 1325 |
| 1289 // Allow Access to option bytes sector | 1326 // Allow Access to option bytes sector |
| 1290 HAL_FLASH_OB_Unlock(); | 1327 HAL_FLASH_OB_Unlock(); |
| 1291 | 1328 |
| 1331 */ | 1368 */ |
| 1332 | 1369 |
| 1333 | 1370 |
| 1334 /** | 1371 /** |
| 1335 * @brief DMA2D configuration. | 1372 * @brief DMA2D configuration. |
| 1336 * @note This function Configure tha DMA2D peripheral : | 1373 * @note This function Configure the DMA2D peripheral : |
| 1337 * 1) Configure the transfer mode : memory to memory W/ pixel format conversion | 1374 * 1) Configure the transfer mode : memory to memory W/ pixel format conversion |
| 1338 * 2) Configure the output color mode as ARGB4444 | 1375 * 2) Configure the output color mode as ARGB4444 |
| 1339 * 3) Configure the output memory address at SRAM memory | 1376 * 3) Configure the output memory address at SRAM memory |
| 1340 * 4) Configure the data size : 320x120 (pixels) | 1377 * 4) Configure the data size : 320x120 (pixels) |
| 1341 * 5) Configure the input color mode as ARGB8888 | 1378 * 5) Configure the input color mode as ARGB8888 |
| 1501 WwdgHandle.Init.Prescaler = WWDG_PRESCALER_8; | 1538 WwdgHandle.Init.Prescaler = WWDG_PRESCALER_8; |
| 1502 WwdgHandle.Init.Window = 80; | 1539 WwdgHandle.Init.Window = 80; |
| 1503 WwdgHandle.Init.Counter = 127; | 1540 WwdgHandle.Init.Counter = 127; |
| 1504 | 1541 |
| 1505 HAL_WWDG_Init(&WwdgHandle); | 1542 HAL_WWDG_Init(&WwdgHandle); |
| 1506 HAL_WWDG_Start(&WwdgHandle); | 1543 /* HAL_WWDG_Start(&WwdgHandle); has been removed from HAL library starting_V120 */ |
| 1507 while(1); | 1544 while(1); |
| 1508 } | 1545 } |
| 1509 | 1546 |
| 1510 | 1547 |
| 1511 void set_returnFromComm(void) | 1548 void set_returnFromComm(void) |
