Changeset 78 for trunk/fw_g473rct/Core


Ignore:
Timestamp:
Sep 9, 2026, 4:41:33 PM (11 days ago)
Author:
f.jahn
Message:

15s button press on device's power up initiates Factory Reset.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/fw_g473rct/Core/Src/main.c

    r77 r78  
    7171
    7272#define MAX_OVERCURRENT_RETRYS  3
    73 #ifdef DEBUG
     73
    7474#define MX_IWDG_Init DoNothing
    75 #endif
     75
    7676//#define USBPD_DPM_Run DoNothing
    7777
     
    192192  MX_CRC_Init();
    193193  MX_RTC_Init();
    194   //MX_IWDG_Init();
     194  MX_IWDG_Init();
    195195  MX_TIM3_Init();
    196196  #ifndef NO_USB_SUPPORT
     
    216216          case FIRST_START_ERROR:                                               EEPROM_fullRestore(&sys_data);            break;
    217217  }
    218  
    219   HAL_IWDG_Refresh(&hiwdg);
    220218
    221219  // Set Slave Address via user button
     
    236234    }
    237235  }*/
    238   HAL_IWDG_Refresh(&hiwdg);
     236
     237  #undef MX_IWDG_Init
     238  MX_IWDG_Init();
     239
    239240  LoadBackupRegister();
    240241 
     
    253254  if (HAL_ADCEx_Calibration_Start(&hadc4, ADC_DIFFERENTIAL_ENDED) != HAL_OK) Error_Handler();
    254255  if (HAL_ADCEx_Calibration_Start(&hadc5, ADC_SINGLE_ENDED) != HAL_OK) Error_Handler();
    255 
    256256
    257257
     
    630630#endif
    631631
    632         // Buzzer signalize that we are now in Slave Address Setting mode
     632        // Buzzer signalizes that we are now in Slave Address Setting mode
    633633        startTime = HAL_GetTick();
    634634        while (HAL_GetTick() - startTime < 300U)
     
    639639        HAL_GPIO_WritePin(BUZZER_GPIO_Port, BUZZER_Pin, BUZZER_OFF);
    640640
    641         // We need to wait till button release(10s)
     641        // We need to wait till button release(15s)
    642642        startTime = HAL_GetTick();
    643643        while (BTN_PRESSED == HAL_GPIO_ReadPin(GPIO_INPUT_BTN_MODE_GPIO_Port, GPIO_INPUT_BTN_MODE_Pin))
    644         {
    645                 if (HAL_GetTick() - startTime >= 60U * 1000U) return 0;
     644        {       // if we hold a user button pressed for a 15s, when we perform Factory Reset
     645                if (HAL_GetTick() - startTime >= 15U * 1000U)
     646                {
     647                        // Buzzer signalizes that we are now in Factory Reset mode
     648                        startTime = HAL_GetTick();
     649                        while (HAL_GetTick() - startTime < 1000U)
     650                        {
     651                                HAL_GPIO_TogglePin(BUZZER_GPIO_Port, BUZZER_Pin);
     652                                HAL_Delay(50U);
     653                        }
     654                        HAL_GPIO_WritePin(BUZZER_GPIO_Port, BUZZER_Pin, BUZZER_OFF);
     655                        EEPROM_factoryRestore(&sys_data, 1);
     656                        return 0;
     657                }
    646658                HAL_Delay(10U);
    647659        }
Note: See TracChangeset for help on using the changeset viewer.