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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 4862|回复: 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;
}
这句话怎么理解呢?谁能给小弟详细解释一下,谢谢
下面是对应的结构体
  j8 u! F# x" _( I

0 p  s. D5 w; r. ?1 O$ E

1 l$ }% Q1 E" n5 h1 a
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;
3 M  u1 K2 ~9 r; y
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];

! M9 F- x$ @' X$ ^6 p
}
NandCtrlInfo_t;

, x+ W7 P) y/ p" w1 D' k9 H

0 V& }8 d+ Q5 W. c; ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

0

主题

113

帖子

2110

积分

创龙

Rank: 8Rank: 8

积分
2110
沙发
发表于 2016-6-8 16:31:45 | 只看该作者
提取结构体中的 hNandTimingInfo 到一个临时变量,结构体中的这个值结构体声明里有注释解释了。
/ L8 [2 M; p3 d- Z6 ?- f4 T, ~( z5 @, F' O6 ^' P6 r
其实不是很确定你的疑问是什么。
回复 支持 反对

使用道具 举报

28

主题

87

帖子

449

积分

中级会员

Rank: 3Rank: 3

积分
449
板凳
 楼主| 发表于 2016-6-8 16:37:37 | 只看该作者
Jackindata 发表于 2016-6-8 16:31
8 W- s# O- T# _0 t' V- r提取结构体中的 hNandTimingInfo 到一个临时变量,结构体中的这个值结构体声明里有注释解释了。1 @+ ^3 Y5 X+ W. L

. }8 S  n4 T, k/ j) l- Y其实不是 ...

% m1 j# y; R% r您能给我解释一下 赋值运行的过程吗, 越详细越好 ,谢谢
回复 支持 反对

使用道具 举报

0

主题

113

帖子

2110

积分

创龙

Rank: 8Rank: 8

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

; E6 m1 \* S3 ^" P0 J2 l这里箭头符号
->
用于结构体指针访问结构体成员,而 hNandCtrlInfo 也是一个结构体指针,可以继续访问其结构体成员 hNandTimingInfo。. W( S* H9 ?/ \" n; q6 H

4 p  s: e1 ^: r" F0 D这个语句也可以这样写:
- o3 y0 y0 x7 x( n: A
  1. 9 ~2 s4 U: h( V) ?
  2. struct _NAND_CTRL_INFO_ *val1 = (EMIFANANDTimingInfo_t *) nandInfo->hNandCtrlInfo;
    ; @6 w# W( e, i. s" ]% B
  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
+ z7 g! x0 P/ ~' O* k. j, x这里箭头符号用于结构体指针访问结构体成员,而 hNandCtrlInfo 也是一个结构体指针,可以继续访问其结构体 ...
3 }  K5 y- o) c( @( c  }) B* g
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-9-16 07:51 , Processed in 0.039886 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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