/\* Private includes ----------------------------------------------------------\*/ /\* USER CODE BEGIN Includes \*/ #include <stdio.h> /\* USER CODE END Includes \*/
/\* Private typedef -----------------------------------------------------------\*/ /\* USER CODE BEGIN PTD \*/
/\* USER CODE END PTD \*/
/\* Private define ------------------------------------------------------------\*/ /\* USER CODE BEGIN PD \*/ /\* USER CODE END PD \*/
/\* Private macro -------------------------------------------------------------\*/ /\* USER CODE BEGIN PM \*/
/\* Reset of all peripherals, Initializes the Flash interface and the Systick. \*/ HAL\_Init();
/\* USER CODE BEGIN Init \*/
/\* USER CODE END Init \*/
/\* Configure the system clock \*/ SystemClock\_Config();
/\* USER CODE BEGIN SysInit \*/
/\* USER CODE END SysInit \*/
/\* Initialize all configured peripherals \*/ MX\_GPIO\_Init(); MX\_IWDG\_Init(); MX\_USART1\_UART\_Init(); /\* USER CODE BEGIN 2 \*/ printf("\*\*\*\*IWDG Demo\*\*\*\*\r\n"); /\* USER CODE END 2 \*/
/\* Infinite loop \*/ /\* USER CODE BEGIN WHILE \*/ while (1) { /\* USER CODE END WHILE \*/
/\* USER CODE BEGIN 3 \*/ printf("\n\r Refreshes the IWDG !!!\n\r"); HAL\_IWDG\_Refresh(&hiwdg); HAL\_Delay(800); } /\* USER CODE END 3 \*/ }
/\*\* Initializes the RCC Oscillators according to the specified parameters \* in the RCC\_OscInitTypeDef structure. \*/ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.LSIState = RCC_LSI_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; if (HAL\_RCC\_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error\_Handler(); } /\*\* Initializes the CPU, AHB and APB buses clocks \*/ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL\_RCC\_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { Error\_Handler(); } }
/\* USER CODE BEGIN 4 \*/
/\* USER CODE END 4 \*/
/\*\* \* @brief This function is executed in case of error occurrence. \* @retval None \*/ void Error\_Handler(void) { /\* USER CODE BEGIN Error\_Handler\_Debug \*/ /\* User can add his own implementation to report the HAL error return state \*/ \_\_disable\_irq(); while (1) { } /\* USER CODE END Error\_Handler\_Debug \*/ }
#ifdef USE\_FULL\_ASSERT /\*\* \* @brief Reports the name of the source file and the source line number \* where the assert\_param error has occurred. \* @param file: pointer to the source file name \* @param line: assert\_param error line source number \* @retval None \*/ void assert\_failed(uint8_t \*file, uint32_t line) { /\* USER CODE BEGIN 6 \*/ /\* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) \*/ /\* USER CODE END 6 \*/ } #endif /\* USE\_FULL\_ASSERT \*/