/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "tim.h" #include "usart.h" #include "gpio.h"
/* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */
/* 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 */
/* USER CODE BEGIN PV */ int flag; /* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); /* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { if(GPIO_Pin==GPIO_PIN_13)flag=1; } /* USER CODE END 0 */
/** * @brief The application entry point. * @retval int */ int main(void) { /* USER CODE BEGIN 1 */
/* 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_USART2_UART_Init(); MX_USART1_UART_Init(); MX_USART3_UART_Init(); MX_TIM1_Init(); MX_TIM2_Init(); /* USER CODE BEGIN 2 */ HAL_GPIO_WritePin(GPIOD,GPIO_PIN_12,GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOD,GPIO_PIN_10,GPIO_PIN_RESET); /* USER CODE END 2 */
/* Infinite loop */ /* USER CODE BEGIN WHILE */ while(1) { if(flag) { flag=0; int i=3; while(i--) { HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_13); HAL_Delay(250); } } /* USER CODE END WHILE */
/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "usart.h" #include "gpio.h"
/* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include <string.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_UART4_Init(); MX_UART5_Init(); MX_UART7_Init(); /* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { HAL_UART_Transmit(&huart7,(uint8_t *)s,strlen(s),HAL_MAX_DELAY); HAL_Delay(500); /* USER CODE END WHILE */
/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "usart.h" #include "gpio.h"
/* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include <stdlib.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_UART4_Init(); MX_UART5_Init(); MX_UART7_Init(); /* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */ /* USER CODE BEGIN WHILE */ HAL_UART_Receive_IT(&huart7,&data,1); while (1) { HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_13); HAL_Delay(t); /* USER CODE END WHILE */
/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include"main.h" #include"usart.h" #include"gpio.h"
/* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include <string.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_UART4_Init(); MX_UART5_Init(); MX_UART7_Init(); /* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */ /* USER CODE BEGIN WHILE */
HAL_UART_Receive_IT(&huart4,(uint8_t*)&data,1); while (1) { if(flag) { HAL_UART_Transmit(&huart7,(uint8_t*)m,strlen(m),HAL_MAX_DELAY); flag=0; } /* USER CODE END WHILE */
/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "tim.h" #include "usart.h" #include "gpio.h"
/* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */
/* 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_USART2_UART_Init(); MX_USART1_UART_Init(); MX_USART3_UART_Init(); MX_TIM1_Init(); MX_TIM2_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */
/* Infinite loop */ /* USER CODE BEGIN WHILE */ HAL_TIM_Base_Start_IT(&htim1); HAL_TIM_Base_Start_IT(&htim2); HAL_UART_Receive_IT(&huart1,&f,1); while(1) { if(t2-cnt>=500) { HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_13); cnt=t2; } /* USER CODE END WHILE */