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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 4683|回复: 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;
}
这句话怎么理解呢?谁能给小弟详细解释一下,谢谢
下面是对应的结构体

2 @7 j! ?" m% v" p: s

9 c- |7 F( ?. P5 X

! U' s1 r. B' }" K' l% G9 v/ M
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;
; P/ e, {, S7 e6 b  @0 o6 V
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];

, Z0 |/ Y2 y2 B; L( b
}
NandCtrlInfo_t;

" f* w. E% K+ j  E, Z4 K

7 x( n  o, i* {
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

0

主题

113

帖子

2089

积分

创龙

Rank: 8Rank: 8

积分
2089
沙发
发表于 2016-6-8 16:31:45 | 只看该作者
提取结构体中的 hNandTimingInfo 到一个临时变量,结构体中的这个值结构体声明里有注释解释了。
1 B' z' H. i* a" E5 k$ y8 v; _$ @2 ^% N# f
其实不是很确定你的疑问是什么。
回复 支持 反对

使用道具 举报

28

主题

87

帖子

449

积分

中级会员

Rank: 3Rank: 3

积分
449
板凳
 楼主| 发表于 2016-6-8 16:37:37 | 只看该作者
Jackindata 发表于 2016-6-8 16:31
  ^6 Y; J, F3 W- D1 Y9 x: w+ \/ E提取结构体中的 hNandTimingInfo 到一个临时变量,结构体中的这个值结构体声明里有注释解释了。! w( b  ~. k0 {) v& N

7 {# O% p# E, G0 o7 J其实不是 ...

& \) D# q2 \, G0 v2 }您能给我解释一下 赋值运行的过程吗, 越详细越好 ,谢谢
回复 支持 反对

使用道具 举报

0

主题

113

帖子

2089

积分

创龙

Rank: 8Rank: 8

积分
2089
地板
发表于 2016-6-8 17:11:36 | 只看该作者
(EMIFANANDTimingInfo_t *) nandInfo->hNandCtrlInfo->hNandTimingInfo;

; h' [% _- u) H' e0 M6 s  f这里箭头符号
->
用于结构体指针访问结构体成员,而 hNandCtrlInfo 也是一个结构体指针,可以继续访问其结构体成员 hNandTimingInfo。
* C( ~+ H; T$ w6 ?& x- z6 l( I8 G8 ]$ A, j- I' g# T% z
这个语句也可以这样写:
4 f5 W4 w# N5 ~) e1 Z
  1. 4 D# T* W: y" i: u
  2. struct _NAND_CTRL_INFO_ *val1 = (EMIFANANDTimingInfo_t *) nandInfo->hNandCtrlInfo;- P! ^1 l8 m$ T
  3. void *val2 = val1->hNandTimingInfo;
复制代码
回复 支持 反对

使用道具 举报

15

主题

1357

帖子

4579

积分

创龙

Rank: 8Rank: 8

积分
4579
5#
发表于 2016-6-11 11:40:19 | 只看该作者
Jackindata 发表于 2016-6-8 17:116 i' E7 H2 E6 D' l) s
这里箭头符号用于结构体指针访问结构体成员,而 hNandCtrlInfo 也是一个结构体指针,可以继续访问其结构体 ...
  }- X3 I) Z. G
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-17 02:07 , Processed in 0.074345 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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