[开发工具] static关键字在定义接口初始化结构体的用处是什么?

[复制链接]
562|0
 楼主| wanduzi 发表于 2022-6-23 10:18 | 显示全部楼层 |阅读模式
  1. /* USER CODE BEGIN PV */
  2. static GPIO_InitTypeDef  GPIO_InitStruct;

  3. /* USER CODE END PV */

  4. /* Private function prototypes -----------------------------------------------*/
  5. void SystemClock_Config(void);
  6. /* USER CODE BEGIN PFP */

  7. /* USER CODE END PFP */

  8. /* Private user code ---------------------------------------------------------*/
  9. /* USER CODE BEGIN 0 */

  10. /* USER CODE END 0 */

  11. /**
  12.   * [url=home.php?mod=space&uid=247401]@brief[/url]  The application entry point.
  13.   * @retval int
  14.   */
  15. int main(void)
  16. {
  17.   /* USER CODE BEGIN 1 */
  18.   /* STM32G4xx HAL library initialization:
  19.        - Configure the Flash prefetch
  20.        - Systick timer is configured by default as source of time base, but user
  21.          can eventually implement his proper time base source (a general purpose
  22.          timer for example or other time source), keeping in mind that Time base
  23.          duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
  24.          handled in milliseconds basis.
  25.        - Set NVIC Group Priority to 4
  26.        - Low Level Initialization
  27.      */
  28.   /* USER CODE END 1 */

  29.   /* MCU Configuration--------------------------------------------------------*/

  30.   /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  31.   HAL_Init();

  32.   /* USER CODE BEGIN Init */

  33.   /* USER CODE END Init */

  34.   /* Configure the system clock */
  35.   SystemClock_Config();

  36.   /* USER CODE BEGIN SysInit */

  37.   /* USER CODE END SysInit */

  38.   /* Initialize all configured peripherals */
  39.   /* USER CODE BEGIN 2 */

  40.    /* -1- Enable GPIO Clock (to be able to program the configuration registers) */
  41.   LED2_GPIO_CLK_ENABLE();

  42.   /* -2- Configure IO in output push-pull mode to drive external LEDs */
  43.   GPIO_InitStruct.Mode  = GPIO_MODE_OUTPUT_PP;
  44.   GPIO_InitStruct.Pull  = GPIO_PULLUP;
  45.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

  46.   GPIO_InitStruct.Pin = LED2_PIN;
  47.   HAL_GPIO_Init(LED2_GPIO_PORT, &GPIO_InitStruct);
一直不懂啊
static GPIO_InitTypeDef GPIO_InitStruct
这里为何要用 static 修饰。


您需要登录后才可以回帖 登录 | 注册

本版积分规则

156

主题

1882

帖子

3

粉丝
快速回复 在线客服 返回列表 返回顶部