- #include "main.h"
- int main(void)
- {
- /* USER CODE BEGIN 1 */
- /* USER CODE END 1 */
- /* Enable the CPU Cache */
- /* Enable I-Cache---------------------------------------------------------*/
- SCB_EnableICache();
- /* Enable D-Cache---------------------------------------------------------*/
- SCB_EnableDCache();
- /* MCU Configuration--------------------------------------------------------*/
- /* Update SystemCoreClock variable according to RCC registers values. */
- SystemCoreClockUpdate();
- /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
- HAL_Init();
- /* USER CODE BEGIN Init */
- /* USER CODE END Init */
- /* USER CODE BEGIN SysInit */
- /* USER CODE END SysInit */
- /* Initialize all configured peripherals */
- MX_GPIO_Init();
- /* USER CODE BEGIN 2 */
- /* USER CODE END 2 */
- /* Infinite loop */
- /* USER CODE BEGIN WHILE */
- while (1)
- {
- /* USER CODE END WHILE */
- HAL_GPIO_TogglePin(GPIOM, LD4_Pin|LD3_Pin);
- HAL_GPIO_TogglePin(GPIOO, LD1_Pin|LD2_Pin);
- HAL_Delay(1000);
- /* USER CODE BEGIN 3 */
- }
- /* USER CODE END 3 */
- }
- /**
- * [url=home.php?mod=space&uid=247401]@brief[/url] GPIO Initialization Function
- * @param None
- * @retval None
- */
- static void MX_GPIO_Init(void)
- {
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- /* USER CODE BEGIN MX_GPIO_Init_1 */
- /* USER CODE END MX_GPIO_Init_1 */
- /* GPIO Ports Clock Enable */
- __HAL_RCC_GPIOM_CLK_ENABLE();
- __HAL_RCC_GPIOO_CLK_ENABLE();
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOM, LD4_Pin|LD3_Pin, GPIO_PIN_RESET);
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOO, LD1_Pin|LD2_Pin, GPIO_PIN_RESET);
- /*Configure GPIO pins : LD4_Pin LD3_Pin */
- GPIO_InitStruct.Pin = LD4_Pin|LD3_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOM, &GPIO_InitStruct);
- /*Configure GPIO pins : LD1_Pin LD2_Pin */
- GPIO_InitStruct.Pin = LD1_Pin|LD2_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOO, &GPIO_InitStruct);
- /* USER CODE BEGIN MX_GPIO_Init_2 */
- /* USER CODE END MX_GPIO_Init_2 */
- }
- /* USER CODE BEGIN 4 */
- /* USER CODE END 4 */
- /**
- * [url=home.php?mod=space&uid=247401]@brief[/url] 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
- /**
- * [url=home.php?mod=space&uid=247401]@brief[/url] 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 */
https://www.bilibili.com/video/BV1bNpJeDEiX/?buvid=XY75B537C416E17A953A00A33EDB883CA28EB&is_story_h5=false&mid=Pw2Hq3t6IhfKj%2FPD%2Bao96g%3D%3D&plat_id=147&share_from=ugc&share_medium=android&share_plat=android&share_session_id=8758dcb1-5e96-49bd-b2c9-ab99ce05f44c&share_source=WEIXIN&share_tag=s_i×tamp=1726671158&unique_k=6ODxL4z&up_id=526937168