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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 4972|回复: 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;
}
这句话怎么理解呢?谁能给小弟详细解释一下,谢谢
下面是对应的结构体
3 d8 L: \. ~3 V! Q, p1 N1 ~/ \
7 |$ y) N5 `7 D* T% Z
, b. U/ r, r1 _$ \
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;

; {/ D0 n5 a# i. T+ m6 E
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];
2 c( @3 V- C2 u- f
}
NandCtrlInfo_t;
  v, e; y2 |- K

% \: E$ x. J5 K, x8 Y) ?( N! {
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

0

主题

113

帖子

2122

积分

创龙

Rank: 8Rank: 8

积分
2122
沙发
发表于 2016-6-8 16:31:45 | 只看该作者
提取结构体中的 hNandTimingInfo 到一个临时变量,结构体中的这个值结构体声明里有注释解释了。9 P$ ~4 B6 o2 ~7 L( x8 v0 Z! J# Q
: P- Z- c$ v# z6 Z1 A1 f4 y
其实不是很确定你的疑问是什么。
回复 支持 反对

使用道具 举报

28

主题

87

帖子

449

积分

中级会员

Rank: 3Rank: 3

积分
449
板凳
 楼主| 发表于 2016-6-8 16:37:37 | 只看该作者
Jackindata 发表于 2016-6-8 16:31
: U0 _0 t+ {1 B4 f提取结构体中的 hNandTimingInfo 到一个临时变量,结构体中的这个值结构体声明里有注释解释了。
& x( O0 N$ t" N, O4 h, Q  S# q6 H2 K# Q& N) n$ Y$ p" J$ _( q
其实不是 ...

) \% g) x# w( K# C您能给我解释一下 赋值运行的过程吗, 越详细越好 ,谢谢
回复 支持 反对

使用道具 举报

0

主题

113

帖子

2122

积分

创龙

Rank: 8Rank: 8

积分
2122
地板
发表于 2016-6-8 17:11:36 | 只看该作者
(EMIFANANDTimingInfo_t *) nandInfo->hNandCtrlInfo->hNandTimingInfo;
  Y: k# P  C* L/ i# w+ _
这里箭头符号
->
用于结构体指针访问结构体成员,而 hNandCtrlInfo 也是一个结构体指针,可以继续访问其结构体成员 hNandTimingInfo。
+ w1 R' C* Q" O* t
1 j: i+ z" B0 ]$ N$ ?4 D# x3 G7 l8 d7 e这个语句也可以这样写:# l2 h1 x! T' J+ Y5 s2 [  L( E- n

  1. % v* y8 b: |( m, k+ y
  2. struct _NAND_CTRL_INFO_ *val1 = (EMIFANANDTimingInfo_t *) nandInfo->hNandCtrlInfo;- [3 h+ \: X5 t1 _! |  d' Q
  3. void *val2 = val1->hNandTimingInfo;
复制代码
回复 支持 反对

使用道具 举报

15

主题

1357

帖子

4579

积分

创龙

Rank: 8Rank: 8

积分
4579
5#
发表于 2016-6-11 11:40:19 | 只看该作者
Jackindata 发表于 2016-6-8 17:115 k! |! f$ ~- r+ O, d/ @" M, G* P
这里箭头符号用于结构体指针访问结构体成员,而 hNandCtrlInfo 也是一个结构体指针,可以继续访问其结构体 ...
7 G4 J. }. m' D" M; Q: t
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-10-17 14:23 , Processed in 0.040214 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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