纯C的问题 ,结构体的 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 4960|回复: 4
打印 上一主题 下一主题

纯C的问题 ,结构体的

[复制链接]

28

主题

87

帖子

449

积分

中级会员

Rank: 3Rank: 3

积分
449
跳转到指定楼层
楼主
发表于 2016-6-7 09:13:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
EMIFANANDInit(NandInfo_t *nandInfo)
{
nandTimingInfo = (EMIFANANDTimingInfo_t *) nandInfo->hNandCtrlInfo->hNandTimingInfo;
}
这句话怎么理解呢?谁能给小弟详细解释一下,谢谢
下面是对应的结构体

: X* s- p; t  f1 p* }5 M! p

1 t) H- C& ~' _. G0 F' }

0 f, J( X4 P. n
typedef struct _EMIFA_NAND_TIMING_INFO_      
{unsigned int writeSetup;
    unsigned int writeStrobe;
    unsigned int writeHold;
    unsigned int readSetup;
    unsigned int readStrobe;
    unsigned int readHold;
    unsigned int turnAround;
}
EMIFANANDTimingInfo_t;
typedef struct _NAND_INFO_
{
    unsigned int dataRegAddr;
    /* ADDR Register address */
    unsigned int addrRegAddr;
    /* CMD Register address */
    unsigned int cmdRegAddr;
    /* Pointer to Memory Controller Structure */
    struct _NAND_CTRL_INFO_ *hNandCtrlInfo;
    /* Pointer to ECC Structure */
    struct _NAND_ECC_INFO_ *hNandEccInfo;
    /* Pointer to DMA Structure */
    struct _NAND_DMA_INFO_ *hNandDmaInfo;
}
NandInfo_t;

8 n  `5 q' ]! Q# d3 d# C
typedef struct _NAND_CTRL_INFO_
{
    unsigned int (*WaitPinStatusGet)(NandInfo_t *nandInfo);
    /* Timing info for the device and the controller */
    void *hNandTimingInfo;
    /* Base address of the controller */
    unsigned int baseAddr;
    /* ECC supported by the controller */
    unsigned int eccSupported;
    /* Wait pin where NAND dev R/B pin is connected  */  
    unsigned int chipSelectBaseAddr[NAND_MAX_CHIP_SELECTS];

* w. V( h8 l7 O; z5 _: l! o, ?# T
}
NandCtrlInfo_t;

/ `# z% u0 z! j/ z4 ?' {

) a/ J2 Z) d! @5 h& m1 j" ~- L
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

0

主题

113

帖子

2118

积分

创龙

Rank: 8Rank: 8

积分
2118
沙发
发表于 2016-6-8 16:31:45 | 只看该作者
提取结构体中的 hNandTimingInfo 到一个临时变量,结构体中的这个值结构体声明里有注释解释了。
, _& u3 r$ e1 e& W5 E5 `: y' `2 k$ y
其实不是很确定你的疑问是什么。
回复 支持 反对

使用道具 举报

28

主题

87

帖子

449

积分

中级会员

Rank: 3Rank: 3

积分
449
板凳
 楼主| 发表于 2016-6-8 16:37:37 | 只看该作者
Jackindata 发表于 2016-6-8 16:31
3 ?7 ?" U) L$ o8 p. N提取结构体中的 hNandTimingInfo 到一个临时变量,结构体中的这个值结构体声明里有注释解释了。& _- e3 i1 t* M& a. J

: s4 B3 b% o  w" G. _1 [4 V0 x. {9 u其实不是 ...
8 O' ~9 Y, @# ?# N# E& b3 G' S
您能给我解释一下 赋值运行的过程吗, 越详细越好 ,谢谢
回复 支持 反对

使用道具 举报

0

主题

113

帖子

2118

积分

创龙

Rank: 8Rank: 8

积分
2118
地板
发表于 2016-6-8 17:11:36 | 只看该作者
(EMIFANANDTimingInfo_t *) nandInfo->hNandCtrlInfo->hNandTimingInfo;
- a; r  b/ c6 l! Z1 g' H+ g' T& X) }
这里箭头符号
->
用于结构体指针访问结构体成员,而 hNandCtrlInfo 也是一个结构体指针,可以继续访问其结构体成员 hNandTimingInfo。5 `3 ~( |3 l' P3 g) q$ D- M
: s7 V# G$ J7 l5 x6 V
这个语句也可以这样写:9 l1 O- R8 o5 a, T6 c
  1. . p1 @  D/ u0 b, M( t, w3 A2 ?
  2. struct _NAND_CTRL_INFO_ *val1 = (EMIFANANDTimingInfo_t *) nandInfo->hNandCtrlInfo;
    # J% n6 N7 G$ y3 Z* l. L8 k+ z+ N
  3. void *val2 = val1->hNandTimingInfo;
复制代码
回复 支持 反对

使用道具 举报

15

主题

1357

帖子

4579

积分

创龙

Rank: 8Rank: 8

积分
4579
5#
发表于 2016-6-11 11:40:19 | 只看该作者
Jackindata 发表于 2016-6-8 17:11
7 E7 R8 r" A7 D这里箭头符号用于结构体指针访问结构体成员,而 hNandCtrlInfo 也是一个结构体指针,可以继续访问其结构体 ...
1 Z! Q( t5 z' B& g" E
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|手机版|小黑屋|嵌入式开发者社区 ( 粤ICP备15055271号

GMT+8, 2025-10-13 13:18 , Processed in 0.041367 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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