Changeset 65 for trunk/fw_g473rct/Core/Src
- Timestamp:
- Apr 2, 2026, 3:56:21 PM (5 weeks ago)
- Location:
- trunk/fw_g473rct/Core/Src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/fw_g473rct/Core/Src/gpio.c
r55 r65 59 59 60 60 /*Configure GPIO pin Output Level */ 61 HAL_GPIO_WritePin(GPIOB, LED_ERROR_Pin|BUZZER_Pin , GPIO_PIN_RESET);61 HAL_GPIO_WritePin(GPIOB, LED_ERROR_Pin|BUZZER_Pin|UCPD1_VBUS_Pin, GPIO_PIN_RESET); 62 62 63 63 /*Configure GPIO pins : AUX_EN_Pin ADC_START_CONV_Pin ADC_RESET_Pin */ … … 75 75 HAL_GPIO_Init(LED_FUNCTION_GPIO_Port, &GPIO_InitStruct); 76 76 77 /*Configure GPIO pins : LED_ERROR_Pin BUZZER_Pin */78 GPIO_InitStruct.Pin = LED_ERROR_Pin|BUZZER_Pin ;77 /*Configure GPIO pins : LED_ERROR_Pin BUZZER_Pin UCPD1_VBUS_Pin */ 78 GPIO_InitStruct.Pin = LED_ERROR_Pin|BUZZER_Pin|UCPD1_VBUS_Pin; 79 79 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 80 80 GPIO_InitStruct.Pull = GPIO_NOPULL; -
trunk/fw_g473rct/Core/Src/main.c
r55 r65 56 56 #include "self_discharge.h" 57 57 #include "ltc_current.h" 58 #include "usbd_cdc_if.h" 58 59 59 60 /* USER CODE END Includes */ … … 71 72 #define MX_IWDG_Init DoNothing 72 73 #endif 74 //#define USBPD_DPM_Run DoNothing 73 75 74 76 /* USER CODE END PD */ … … 85 87 uint32_t bootLoaderMark __attribute__((section(".no_init"))); 86 88 87 modbus_t modbusData __attribute__((section(".RAM1")));88 89 90 __IO uint32_t adc1Data[SAMPLE_ARRAY_SIZE] __attribute__((section(".RAM1")));91 __IO uint32_t adc2Data[SAMPLE_ARRAY_SIZE] __attribute__((section(".RAM1")));92 __IO uint32_t adc3Data[3] __attribute__((section(".RAM1")));93 __IO uint32_t adc4Data[SAMPLE_ARRAY_SIZE] __attribute__((section(".RAM1")));94 __IO uint32_t adc5Data[4] __attribute__((section(".RAM1")));89 modbus_t modbusData; 90 91 92 __IO uint32_t adc1Data[SAMPLE_ARRAY_SIZE]; 93 __IO uint32_t adc2Data[SAMPLE_ARRAY_SIZE]; 94 __IO uint32_t adc3Data[3]; 95 __IO uint32_t adc4Data[SAMPLE_ARRAY_SIZE]; 96 __IO uint32_t adc5Data[4]; 95 97 int silentmode =0; 96 98 static volatile uint32_t newADC124Data = 0; … … 109 111 void SaveBackupRegister(void); 110 112 void JumpToBootloader(void); 113 void CheckRAMHWParity(void); 111 114 void DoNothing(void){}; 112 115 /* USER CODE END PFP */ … … 125 128 126 129 /* USER CODE BEGIN 1 */ 130 131 CheckRAMHWParity(); 127 132 128 133 if (bootLoaderMark == GOTO_SYSTEM_BOOTLOADER_MARK) … … 223 228 //HAL_DMA_Start(hadc2.DMA_Handle,(uint32_t)&hadc2.Instance->DR, (uint32_t)adc2Data,1); //Start ADC slave DMA 224 229 //SET_BIT(hadc1.Instance->CFGR, ADC_CFGR_DMAEN); //Enable DMA transfer for ADC master (ADC12_CCR.MDMA = 0b00 -> MDMA mode disabled) 225 if (HAL_ADC_Start_DMA(&hadc1,(uint32_t *)adc1Data,SAMPLE_ARRAY_SIZE)) //Start ADC interleaved mode 226 { 227 /* Start Error */ 228 Error_Handler(); 229 } 230 231 if (HAL_ADC_Start_DMA(&hadc2,(uint32_t *)adc2Data,SAMPLE_ARRAY_SIZE)) //Start ADC interleaved mode 232 { 233 /* Start Error */ 234 Error_Handler(); 235 } 236 237 if (HAL_ADC_Start_DMA(&hadc3, (uint32_t *) adc3Data , 3)) 238 { 239 /* Start Error */ 240 Error_Handler(); 241 } 242 243 if (HAL_ADC_Start_DMA(&hadc4, (uint32_t *) adc4Data , SAMPLE_ARRAY_SIZE)) 244 { 245 /* Start Error */ 246 Error_Handler(); 247 } 248 249 250 if (HAL_ADC_Start_DMA(&hadc5, (uint32_t *) adc5Data , 4)) 251 { 252 /* Start Error */ 253 Error_Handler(); 254 } 230 if (HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc1Data,SAMPLE_ARRAY_SIZE)) Error_Handler(); // Start ADC interleaved mode 231 if (HAL_ADC_Start_DMA(&hadc2, (uint32_t*)adc2Data,SAMPLE_ARRAY_SIZE)) Error_Handler(); // Start ADC interleaved mode 232 if (HAL_ADC_Start_DMA(&hadc3, (uint32_t*)adc3Data, 3)) Error_Handler(); 233 if (HAL_ADC_Start_DMA(&hadc4, (uint32_t*)adc4Data, SAMPLE_ARRAY_SIZE)) Error_Handler(); 234 if (HAL_ADC_Start_DMA(&hadc5, (uint32_t*)adc5Data, 4)) Error_Handler(); 255 235 256 236 // ADS1260 Initialierung … … 300 280 newADC124Data = 0; 301 281 302 303 304 305 if (HAL_ADC_Start_DMA(&hadc1,(uint32_t *)adc1Data,SAMPLE_ARRAY_SIZE)) //Start ADC interleaved mode 306 { 307 /* Start Error */ 308 Error_Handler(); 309 } 310 311 if (HAL_ADC_Start_DMA(&hadc2,(uint32_t *)adc2Data,SAMPLE_ARRAY_SIZE)) //Start ADC interleaved mode 312 { 313 /* Start Error */ 314 Error_Handler(); 315 } 316 317 // if (HAL_ADC_Start_DMA(&hadc4, (uint32_t *) adc4Data , SAMPLE_ARRAY_SIZE)) 318 // { 319 // /* Start Error */ 320 // Error_Handler(); 321 // } 322 323 324 325 282 if (HAL_ADC_Start_DMA(&hadc1,(uint32_t*)adc1Data,SAMPLE_ARRAY_SIZE)) Error_Handler(); //Start ADC interleaved mode 283 if (HAL_ADC_Start_DMA(&hadc2,(uint32_t*)adc2Data,SAMPLE_ARRAY_SIZE)) Error_Handler(); //Start ADC interleaved mode 326 284 } 327 285 … … 330 288 SHUNT_TEMPERATURE_Exec(adc3Data[0]); 331 289 LTC_CURRENT_Exec(adc3Data[1], adc3Data[2]); 332 333 } 334 335 336 337 338 339 340 290 } 341 291 342 292 if (newADC5Data == 1) … … 348 298 } 349 299 350 351 300 if (newCurrentValue == 1) 352 301 { … … 355 304 356 305 newCurrentValue = 0; 357 358 306 } 359 307 360 361 308 362 309 // Zeitbasis ms Systick; 363 310 newTime = HAL_GetTick(); 364 311 365 if (newTime != oldTime) {366 312 if (newTime != oldTime) 313 { 367 314 oldTime = newTime; 368 315 … … 406 353 } 407 354 408 409 355 // Amperestundenzhler 410 356 AH_COUNTER_Exec(); … … 426 372 427 373 sys_data.s.values.efficiency = EFFICIENCY_Exec(); 374 375 #ifdef DEBUG 376 if (sys_data.s.values.onTime % 5U == 0U) 377 { 378 static char* Buf = "Hello everybody!\r\n"; 379 const unsigned BufLen = strlen(Buf); 380 CDC_Transmit_FS((uint8_t*)Buf, BufLen - 1); 381 } 382 #endif 428 383 } 429 384 … … 610 565 } 611 566 567 //------------------------------------------------------------------------------ 612 568 613 569 void SaveBackupRegister(void) … … 668 624 } 669 625 670 626 //------------------------------------------------------------------------------ 671 627 672 628 /** … … 756 712 printf("Flash locked\n"); 757 713 printf("...Disable lock process finished\n"); 758 759 ;760 714 } 761 715 } 762 716 return true; 763 717 } 718 719 //------------------------------------------------------------------------------ 720 721 void CheckRAMHWParity(void) 722 { 723 if (FLASH->OPTR & FLASH_OPTR_SRAM_PE) 724 { // RAM HW Parity is not activated 725 if (HAL_OK != HAL_FLASH_Unlock()) 726 { 727 #ifdef DEBUG 728 printf("Cannot unlock FLASH!\n"); 729 #endif 730 return; 731 } 732 733 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR); // Clear OPTVERR bit set on virgin samples 734 735 if (HAL_OK != HAL_FLASH_OB_Unlock()) 736 { 737 #ifdef DEBUG 738 printf("Cannot unlock Option Bytes!\n"); 739 #endif 740 return; 741 } 742 743 // Activating SRAM1(first 32Kb) and CCM SRAM parity check (see RM0440, page 139) 744 FLASH->OPTR &= ~FLASH_OPTR_SRAM_PE; 745 while (FLASH->SR & FLASH_SR_BSY) {}; 746 FLASH->CR |= FLASH_CR_OPTSTRT; 747 while (FLASH->SR & FLASH_SR_BSY) {}; 748 // Updating option bytes by resetting of the device 749 FLASH->CR |= FLASH_CR_OBL_LAUNCH; 750 while (1) 751 #ifdef DEBUG 752 printf("Option Bytes write ERROR!\n") 753 #endif 754 ; 755 } 756 } 757 758 //------------------------------------------------------------------------------ 764 759 765 760 bool SetBootFromFlashAndReadOutProtection(void) … … 769 764 HAL_FLASHEx_OBGetConfig(&OptionsBytesStruct); 770 765 771 // Konfiguriere RDP fr Readoutprotection and USER OPTION BYTE FR Boot from Flash766 //Set Readout Protection Level 1 772 767 OptionsBytesStruct.OptionType = OPTIONBYTE_USER | OPTIONBYTE_RDP; 773 774 //Set Readout Protection Level 1775 OptionsBytesStruct.OptionType = OPTIONBYTE_USER|OPTIONBYTE_RDP;776 768 OptionsBytesStruct.RDPLevel = OB_RDP_LEVEL_1; 777 769 … … 780 772 OptionsBytesStruct.USERConfig = OB_USER_nBOOT0 | OB_USER_nSWBOOT0; 781 773 782 if (HAL_FLASH_Unlock() != HAL_OK) 783 { 784 printf("Flash unlock error\n"); 785 } 786 if (HAL_FLASH_OB_Unlock() != HAL_OK) 787 { 788 printf("Flash ob unlock error\n"); 789 } 774 if (HAL_FLASH_Unlock() != HAL_OK) printf("Flash unlock error\n"); 775 if (HAL_FLASH_OB_Unlock() != HAL_OK) printf("Flash ob unlock error\n"); 790 776 791 777 printf("...Flash unlock\n"); … … 804 790 return true; 805 791 } 792 793 //------------------------------------------------------------------------------ 794 806 795 uint8_t printprotectionstate(void) 807 796 {
Note:
See TracChangeset
for help on using the changeset viewer.
