项目目标

添加项目背景、目标等描述

参与人员

用 @ 添加项目参与人员

项目拆解

  1. 分拆项目一
  2. 分拆项目二
  3. 更多分拆项目

排期和程碑

[20200302~20200311] 分拆项目一
[20200310~20200319] 分拆项目二
[20200312~20200312] 里程碑 1
[20200318~20200325] 分拆项目三
[20200326~20200326] 里程碑 2

项目风险

等级 风险描述 影响描述 解决方案

测试代码

  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.c
  5. * @brief : Main program body
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "main.h"
  22. /* Private includes ----------------------------------------------------------*/
  23. /* USER CODE BEGIN Includes */
  24. /* USER CODE BEGIN Includes */
  25. #include "stdio.h"
  26. /* USER CODE END Includes */
  27. /* Private typedef -----------------------------------------------------------*/
  28. /* USER CODE BEGIN PTD */
  29. /* USER CODE END PTD */
  30. /* Private define ------------------------------------------------------------*/
  31. /* USER CODE BEGIN PD */
  32. /* USER CODE END PD */
  33. /* Private macro -------------------------------------------------------------*/
  34. /* USER CODE BEGIN PM */
  35. /* USER CODE END PM */
  36. /* Private variables ---------------------------------------------------------*/
  37. USART_HandleTypeDef husart1;
  38. UART_HandleTypeDef huart2;
  39. /* USER CODE BEGIN PV */
  40. /* USER CODE END PV */
  41. /* Private function prototypes -----------------------------------------------*/
  42. void SystemClock_Config(void);
  43. static void MX_GPIO_Init(void);
  44. static void MX_USART1_Init(void);
  45. static void MX_USART2_UART_Init(void);
  46. /* USER CODE BEGIN PFP */
  47. /* USER CODE END PFP */
  48. /* Private user code ---------------------------------------------------------*/
  49. /* USER CODE BEGIN 0 */
  50. /* USER CODE END 0 */
  51. /**
  52. * @brief The application entry point.
  53. * @retval int
  54. */
  55. int main(void)
  56. {
  57. /* USER CODE BEGIN 1 */
  58. /* USER CODE END 1 */
  59. /* MCU Configuration--------------------------------------------------------*/
  60. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  61. HAL_Init();
  62. /* USER CODE BEGIN Init */
  63. /* USER CODE END Init */
  64. /* Configure the system clock */
  65. SystemClock_Config();
  66. /* USER CODE BEGIN SysInit */
  67. /* USER CODE END SysInit */
  68. /* Initialize all configured peripherals */
  69. MX_GPIO_Init();
  70. MX_USART1_Init();
  71. MX_USART2_UART_Init();
  72. /* USER CODE BEGIN 2 */
  73. /* USER CODE END 2 */
  74. /* Infinite loop */
  75. /* USER CODE BEGIN WHILE */
  76. while (1)
  77. {
  78. /* USER CODE END WHILE */
  79. /* USER CODE BEGIN 3 */
  80. }
  81. /* USER CODE END 3 */
  82. }
  83. /**
  84. * @brief System Clock Configuration
  85. * @retval None
  86. */
  87. void SystemClock_Config(void)
  88. {
  89. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  90. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  91. /** Initializes the CPU, AHB and APB busses clocks
  92. */
  93. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  94. RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  95. RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  96. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  97. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
  98. RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16;
  99. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  100. {
  101. Error_Handler();
  102. }
  103. /** Initializes the CPU, AHB and APB busses clocks
  104. */
  105. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  106. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  107. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  108. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  109. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  110. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  111. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  112. {
  113. Error_Handler();
  114. }
  115. }
  116. /**
  117. * @brief USART1 Initialization Function
  118. * @param None
  119. * @retval None
  120. */
  121. static void MX_USART1_Init(void)
  122. {
  123. /* USER CODE BEGIN USART1_Init 0 */
  124. /* USER CODE END USART1_Init 0 */
  125. /* USER CODE BEGIN USART1_Init 1 */
  126. /* USER CODE END USART1_Init 1 */
  127. husart1.Instance = USART1;
  128. husart1.Init.BaudRate = 9600;
  129. husart1.Init.WordLength = USART_WORDLENGTH_8B;
  130. husart1.Init.StopBits = USART_STOPBITS_1;
  131. husart1.Init.Parity = USART_PARITY_ODD;
  132. husart1.Init.Mode = USART_MODE_TX_RX;
  133. husart1.Init.CLKPolarity = USART_POLARITY_LOW;
  134. husart1.Init.CLKPhase = USART_PHASE_1EDGE;
  135. husart1.Init.CLKLastBit = USART_LASTBIT_DISABLE;
  136. if (HAL_USART_Init(&husart1) != HAL_OK)
  137. {
  138. Error_Handler();
  139. }
  140. /* USER CODE BEGIN USART1_Init 2 */
  141. /* USER CODE END USART1_Init 2 */
  142. }
  143. /**
  144. * @brief USART2 Initialization Function
  145. * @param None
  146. * @retval None
  147. */
  148. static void MX_USART2_UART_Init(void)
  149. {
  150. /* USER CODE BEGIN USART2_Init 0 */
  151. /* USER CODE END USART2_Init 0 */
  152. /* USER CODE BEGIN USART2_Init 1 */
  153. /* USER CODE END USART2_Init 1 */
  154. huart2.Instance = USART2;
  155. huart2.Init.BaudRate = 115200;
  156. huart2.Init.WordLength = UART_WORDLENGTH_8B;
  157. huart2.Init.StopBits = UART_STOPBITS_1;
  158. huart2.Init.Parity = UART_PARITY_NONE;
  159. huart2.Init.Mode = UART_MODE_TX_RX;
  160. huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  161. huart2.Init.OverSampling = UART_OVERSAMPLING_16;
  162. if (HAL_UART_Init(&huart2) != HAL_OK)
  163. {
  164. Error_Handler();
  165. }
  166. /* USER CODE BEGIN USART2_Init 2 */
  167. /* USER CODE END USART2_Init 2 */
  168. }
  169. /**
  170. * @brief GPIO Initialization Function
  171. * @param None
  172. * @retval None
  173. */
  174. static void MX_GPIO_Init(void)
  175. {
  176. GPIO_InitTypeDef GPIO_InitStruct = {0};
  177. /* GPIO Ports Clock Enable */
  178. __HAL_RCC_GPIOC_CLK_ENABLE();
  179. __HAL_RCC_GPIOD_CLK_ENABLE();
  180. __HAL_RCC_GPIOA_CLK_ENABLE();
  181. __HAL_RCC_GPIOB_CLK_ENABLE();
  182. /*Configure GPIO pin Output Level */
  183. HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
  184. /*Configure GPIO pin : B1_Pin */
  185. GPIO_InitStruct.Pin = B1_Pin;
  186. GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  187. GPIO_InitStruct.Pull = GPIO_NOPULL;
  188. HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
  189. /*Configure GPIO pin : LD2_Pin */
  190. GPIO_InitStruct.Pin = LD2_Pin;
  191. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  192. GPIO_InitStruct.Pull = GPIO_NOPULL;
  193. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  194. HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);
  195. /* EXTI interrupt init*/
  196. HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
  197. HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
  198. }
  199. /* USER CODE BEGIN 4 */
  200. int fputc(int ch, FILE *f)
  201. {
  202. /* Place your implementation of fputc here */
  203. /* e.g. write a character to the USART1 and Loop until the end of transmission */
  204. HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);
  205. return ch;
  206. }
  207. /* USER CODE END 4 */
  208. /**
  209. * @brief This function is executed in case of error occurrence.
  210. * @retval None
  211. */
  212. void Error_Handler(void)
  213. {
  214. /* USER CODE BEGIN Error_Handler_Debug */
  215. /* User can add his own implementation to report the HAL error return state */
  216. /* USER CODE END Error_Handler_Debug */
  217. }
  218. #ifdef USE_FULL_ASSERT
  219. /**
  220. * @brief Reports the name of the source file and the source line number
  221. * where the assert_param error has occurred.
  222. * @param file: pointer to the source file name
  223. * @param line: assert_param error line source number
  224. * @retval None
  225. */
  226. void assert_failed(uint8_t *file, uint32_t line)
  227. {
  228. /* USER CODE BEGIN 6 */
  229. /* User can add his own implementation to report the file name and line number,
  230. tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  231. /* USER CODE END 6 */
  232. }
  233. #endif /* USE_FULL_ASSERT */
  234. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

项目资料

输入 Ctrl(Command)+/ 后,在菜单上选择「语雀文档」或「本地文档」,可嵌入文档直接预览内容。

语雀内容