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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

! r) d, G+ z0 J) u, c- M

) T* P* I* w" c4 c' {% z5 H
* ^& q2 q. l& p5 j
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 V. K6 h& F% R+ I8 M- ?$ A
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];
1 g' K+ \2 @) s" S$ ?2 g( J* |
}
NandCtrlInfo_t;

) E' v2 G5 d4 O: @( Y& U; w

8 n. t1 s9 |1 \2 U3 \4 l
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

0

主题

113

帖子

2070

积分

创龙

Rank: 8Rank: 8

积分
2070
沙发
发表于 2016-6-8 16:31:45 | 只看该作者
提取结构体中的 hNandTimingInfo 到一个临时变量,结构体中的这个值结构体声明里有注释解释了。8 V% ^0 n8 V: `
% `1 n& v3 T( W8 n6 J7 H+ }1 U
其实不是很确定你的疑问是什么。
回复 支持 反对

使用道具 举报

28

主题

87

帖子

449

积分

中级会员

Rank: 3Rank: 3

积分
449
板凳
 楼主| 发表于 2016-6-8 16:37:37 | 只看该作者
Jackindata 发表于 2016-6-8 16:31: I- p) z9 P3 W5 m3 V2 ^
提取结构体中的 hNandTimingInfo 到一个临时变量,结构体中的这个值结构体声明里有注释解释了。
3 `- ?. T) G; H& e+ E+ L+ ~
3 s+ b1 S. E- u4 c% q6 d  Y7 ?# n其实不是 ...
* m. R1 I! ]# q* o# r" m* q+ m: T% w
您能给我解释一下 赋值运行的过程吗, 越详细越好 ,谢谢
回复 支持 反对

使用道具 举报

0

主题

113

帖子

2070

积分

创龙

Rank: 8Rank: 8

积分
2070
地板
发表于 2016-6-8 17:11:36 | 只看该作者
(EMIFANANDTimingInfo_t *) nandInfo->hNandCtrlInfo->hNandTimingInfo;
$ r8 c# z' @3 K8 B$ f2 F
这里箭头符号
->
用于结构体指针访问结构体成员,而 hNandCtrlInfo 也是一个结构体指针,可以继续访问其结构体成员 hNandTimingInfo。5 ]% _7 N; e5 L1 p2 v) H; ]
* g" J5 Y0 \5 ]+ Y1 }1 L
这个语句也可以这样写:
( L5 G. ^8 ^6 r3 l5 I
  1. 7 [; Q5 H( s2 g+ n9 e6 w+ F
  2. struct _NAND_CTRL_INFO_ *val1 = (EMIFANANDTimingInfo_t *) nandInfo->hNandCtrlInfo;
    . g' ~! |+ Z5 J- x5 [4 D8 x
  3. void *val2 = val1->hNandTimingInfo;
复制代码
回复 支持 反对

使用道具 举报

15

主题

1357

帖子

4579

积分

创龙

Rank: 8Rank: 8

积分
4579
5#
发表于 2016-6-11 11:40:19 | 只看该作者
Jackindata 发表于 2016-6-8 17:113 ?3 H3 a: |7 L( L3 h% [) ?( R
这里箭头符号用于结构体指针访问结构体成员,而 hNandCtrlInfo 也是一个结构体指针,可以继续访问其结构体 ...
9 j; k$ Y! w1 V
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-4-30 17:11 , Processed in 0.041216 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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