嵌入式开发者社区

标题: 纯C的问题 ,结构体的 [打印本页]

作者: 新手上路    时间: 2016-6-7 09:13
标题: 纯C的问题 ,结构体的
EMIFANANDInit(NandInfo_t *nandInfo)
{
nandTimingInfo = (EMIFANANDTimingInfo_t *) nandInfo->hNandCtrlInfo->hNandTimingInfo;
}
这句话怎么理解呢?谁能给小弟详细解释一下,谢谢
下面是对应的结构体

& M$ [9 W! u0 \5 `
. ^1 ?% b& o& c0 F! T! U

3 h; L' G* _) A- Z& Z- E* `& @
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;

$ n* A" o* R9 q+ B0 r! W
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];

5 A3 s0 _0 M7 t/ L$ ~/ S
}
NandCtrlInfo_t;

. a9 v' a. R2 R) C$ c+ E+ R5 c

* G6 W9 s/ g3 H7 \) U- B4 Y9 |
作者: Jackindata    时间: 2016-6-8 16:31
提取结构体中的 hNandTimingInfo 到一个临时变量,结构体中的这个值结构体声明里有注释解释了。
' ?( l. X8 @. }- i/ `* O. [5 a+ O/ g$ ]8 c2 w/ Y& A
其实不是很确定你的疑问是什么。
作者: 新手上路    时间: 2016-6-8 16:37
Jackindata 发表于 2016-6-8 16:312 H9 h5 Z9 I& V# ~1 U  s9 H( z& v
提取结构体中的 hNandTimingInfo 到一个临时变量,结构体中的这个值结构体声明里有注释解释了。
* y2 V* H- s% o' u) |/ A' {1 D9 n1 V9 w. w$ B8 \  `2 B: b
其实不是 ...
, @, [5 {! v+ u: h2 b
您能给我解释一下 赋值运行的过程吗, 越详细越好 ,谢谢
作者: Jackindata    时间: 2016-6-8 17:11
(EMIFANANDTimingInfo_t *) nandInfo->hNandCtrlInfo->hNandTimingInfo;

8 k- v5 L* R9 ]( N, P7 A3 f! [这里箭头符号
->
用于结构体指针访问结构体成员,而 hNandCtrlInfo 也是一个结构体指针,可以继续访问其结构体成员 hNandTimingInfo。1 L+ x% E" F( b& {% _6 v) G

( Q6 w( k5 E1 E' Q- ]1 K这个语句也可以这样写:6 l( B1 o! O4 L0 }3 e
  1. ) `/ |' I4 R3 _% ?
  2. struct _NAND_CTRL_INFO_ *val1 = (EMIFANANDTimingInfo_t *) nandInfo->hNandCtrlInfo;" k* l8 z2 R" M4 N" x
  3. void *val2 = val1->hNandTimingInfo;
复制代码

作者: 希望缄默    时间: 2016-6-11 11:40
Jackindata 发表于 2016-6-8 17:11
) K7 j# f! ~+ J这里箭头符号用于结构体指针访问结构体成员,而 hNandCtrlInfo 也是一个结构体指针,可以继续访问其结构体 ...

8 }7 t: f7 j$ h7 _# j




欢迎光临 嵌入式开发者社区 (https://www.51ele.net/) Powered by Discuz! X3.4