求高人详细解释C语言i2cxbase = (*(uint32_t*)&(I2Cx));FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx,uint32_t I2C_FLAG){...__IO uint32_t i2creg = 0,i2cxbase = 0;.../* Get the I2Cx peripheral base address */i2cxbase = (*(uint32_t*)&(I2Cx));...i

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/17 05:34:01
求高人详细解释C语言i2cxbase=(*(uint32_t*)&(I2Cx));FlagStatusI2C_GetFlagStatus(I2C_TypeDef*I2Cx,uint32_tI2C_FL

求高人详细解释C语言i2cxbase = (*(uint32_t*)&(I2Cx));FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx,uint32_t I2C_FLAG){...__IO uint32_t i2creg = 0,i2cxbase = 0;.../* Get the I2Cx peripheral base address */i2cxbase = (*(uint32_t*)&(I2Cx));...i
求高人详细解释C语言i2cxbase = (*(uint32_t*)&(I2Cx));
FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx,uint32_t I2C_FLAG)
{
...
__IO uint32_t i2creg = 0,i2cxbase = 0;
...
/* Get the I2Cx peripheral base address */
i2cxbase = (*(uint32_t*)&(I2Cx));
...
if(((*(__IO uint32_t *)i2cxbase) & I2C_FLAG) = (uint32_t)RESET)
...
}
这I2Cx本身就是结构体指针(即指向外设I2C寄存器首地址),&(I2Cx),寄存器地址的地址?;(uint32_t *)&(I2Cx)再把二级指针转换为uint32_t型指针?;
(*(uint32_t *)&(I2Cx))变为一级指针,即还是结构体指针?我知道这个程序的目的是要得到I2C外设的寄存器地址,可是不知哪里理解错了.
这个是STM32F10X的库中的函数

求高人详细解释C语言i2cxbase = (*(uint32_t*)&(I2Cx));FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx,uint32_t I2C_FLAG){...__IO uint32_t i2creg = 0,i2cxbase = 0;.../* Get the I2Cx peripheral base address */i2cxbase = (*(uint32_t*)&(I2Cx));...i
做个记号,学习一下.
刚才利用
int * pInt = (int *)malloc(sizeof(int) * 32);
double *pDouble = (double *)&(pInt);
然后跟踪得到的运算过程应该是
7:double * pDouble = (double*)&(pInt);
0040EA18 lea eax,[ebp-4]
0040EA1B mov dword ptr [ebp-8],eax
不过最后的时候觉得pInt和pDouble的值(也就是指向的地址)是不一样的