打印

结构体指针

[复制链接]
1593|7
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
jy02326166|  楼主 | 2013-1-20 13:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
pi, GPIO, IO, gp, ni
    GPIO_InitTypeDef      GPIO_InitStructure;                                                                           
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5;      
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;            
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;      
    GPIO_Init(GPIOC,    &GPIO_InitStructure);      

    GPIO_InitTypeDef     * GPIO_InitStructure;                                                                           
    GPIO_InitStructure->GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5;      
    GPIO_InitStructure-> GPIO_Mode = GPIO_Mode_Out_PP;            
    GPIO_InitStructure-> GPIO_Speed = GPIO_Speed_50MHz;      
    GPIO_Init(GPIOC,    GPIO_InitStructure);              


  我试了两种方法,上面的可以,下面的为什么不能工作?
沙发
reille| | 2013-1-20 15:26 | 只看该作者
本帖最后由 reille 于 2013-1-20 15:28 编辑

你的指针没有分配实体存储空间,所以是野指针,所以不能正常工作。

使用特权

评论回复
板凳
huangxz| | 2013-1-20 15:27 | 只看该作者
指针需要初始化

使用特权

评论回复
地板
jy02326166|  楼主 | 2013-1-20 16:00 | 只看该作者
huangxz 发表于 2013-1-20 15:27
指针需要初始化

* GPIO_InitStructure=0
这样初始化行吗?
或者
GPIO_InitTypeDef     GPIO_InitStructure;           
GPIO_InitTypeDef     *GPIO_InitStructure_p;   
GPIO_InitStructure_p=&GPIO_InitStructure;      

使用特权

评论回复
5
uet_cache| | 2013-1-20 16:05 | 只看该作者
楼主没事找事做吧。。。别人定义好好的 , 为什么要单独定义指针。。。还是顺着大家常用方法好。。

使用特权

评论回复
6
xiaox314| | 2013-1-20 17:02 | 只看该作者
:)多半是拿来主义!呵呵!楼主的想法很好~

使用特权

评论回复
7
dami| | 2013-1-20 21:53 | 只看该作者
GPIO_InitTypeDef      GPIO_InitStructure;              
GPIO_InitTypeDef * pGPIO_InitStructure;
pGPIO_InitStructure =&GPIO_InitStructure;                                                            
pGPIO_InitStructure->GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5;      
pGPIO_InitStructure->GPIO_Mode = GPIO_Mode_Out_PP;            
pGPIO_InitStructure->GPIO_Speed = GPIO_Speed_50MHz;      
GPIO_Init(GPIOC,    pGPIO_InitStructure);   

使用特权

评论回复
8
jy02326166|  楼主 | 2013-1-20 23:17 | 只看该作者
dami 发表于 2013-1-20 21:53
GPIO_InitTypeDef      GPIO_InitStructure;              
GPIO_InitTypeDef * pGPIO_InitStructure;
pGPI ...

嗯 谢谢
结果无误,C语言好久没用了,生疏了。。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

35

主题

105

帖子

0

粉丝