野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10017|回复: 2

请教一个例程中的结构体问题

[复制链接]
发表于 2019-6-10 15:26:45 | 显示全部楼层 |阅读模式
void LED_GPIO_Config(void)
{               
               
                GPIO_InitTypeDef *GPIO_InitStructure;//GPIO_InitTypeDef GPIO_InitStructure;

               
                RCC_AHB1PeriphClockCmd ( LED1_GPIO_CLK|
                                   LED2_GPIO_CLK|
                                   LED3_GPIO_CLK, ENABLE);

                                                                                                                                  
                GPIO_InitStructure->GPIO_Pin = LED1_PIN;        //GPIO_InitStructure.GPIO_Pin = LED1_PIN;       

               
                GPIO_InitStructure->GPIO_Mode = GPIO_Mode_OUT; //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   


    GPIO_InitStructure->GPIO_OType = GPIO_OType_PP;//GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;


    GPIO_InitStructure->GPIO_PuPd = GPIO_PuPd_UP;//GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;


                GPIO_InitStructure->GPIO_Speed = GPIO_Speed_2MHz; //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;

               
                GPIO_Init(LED1_GPIO_PORT, GPIO_InitStructure);        //GPIO_Init(LED1_GPIO_PORT, &GPIO_InitStructure);       

                                                                                                                  
                GPIO_InitStructure->GPIO_Pin = LED2_PIN;        //GPIO_InitStructure.GPIO_Pin = LED2_PIN;       
    GPIO_Init(LED2_GPIO_PORT, GPIO_InitStructure);        //GPIO_Init(LED2_GPIO_PORT, &GPIO_InitStructure);       

                                                                                                                          
                GPIO_InitStructure->GPIO_Pin = LED3_PIN;        //GPIO_InitStructure.GPIO_Pin = LED3_PIN;       
    GPIO_Init(LED3_GPIO_PORT, GPIO_InitStructure);        //GPIO_Init(LED3_GPIO_PORT, &GPIO_InitStructure);       
               
                LED_RGBOFF;               


请教各位大佬,为什么修改成左边的形式之后就不能实现功能了呢?

回复

使用道具 举报

发表于 2019-6-10 15:46:51 | 显示全部楼层

GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitTypeDef *GPIO_InitStructure_P=&GPIO_InitStructure;

你的指针没有初始化
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-6-10 16:40:55 | 显示全部楼层
WishWish 发表于 2019-6-10 15:46
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitTypeDef *GPIO_InitStructure_P=&GPIO_InitStructure;
...

非常感谢
回复 支持 反对

使用道具 举报

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

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-9-28 20:19 , Processed in 0.044585 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表