TI中文支持网
TI专业的中文技术问题搜集分享网站

CC2640 I2C 读寄存器的值,官方驱动代码有点没弄懂,我读寄存器的值,在读代码这块打的断点,但是运行中没有进这里面

/* Start transfer in Receive mode */
else {
/* Specify the I2C slave address */
I2CMasterSlaveAddrSet(hwAttrs->baseAddr,
object->currentTransaction->slaveAddress, true);

/* Update the I2C mode */
object->mode = I2CCC26XX_READ_MODE;

/* Check bus status, return with error if busy */
if (I2CMasterBusBusy(hwAttrs->baseAddr)) {
return I2C_STATUS_ERROR;
}

if (object->readCountIdx < 2) {
/* Start the I2C transfer in master receive mode */
I2CMasterControl(hwAttrs->baseAddr,
I2C_MASTER_CMD_BURST_SEND_START);

Log_print1(Diags_USER2,
"I2C:(%p) I2CCC26XX_IDLE_MODE: -> I2CCC26XX_READ_MODE; "
"Reading w/ NACK",
hwAttrs->baseAddr);
}
else {
/* Start the I2C transfer in master receive mode */
I2CMasterControl(hwAttrs->baseAddr,
I2C_MASTER_CMD_BURST_RECEIVE_START);

Log_print1(Diags_USER2,
"I2C:(%p) I2CCC26XX_IDLE_MODE: -> I2CCC26XX_READ_MODE; "
"Reading w/ ACK",
hwAttrs->baseAddr);
}
}

Viki Shi:

具体哪句没弄懂?

user6477475:

回复 Viki Shi:

就是我在读寄存器值的时候,应该会跳转到object->mode = I2CCC26XX_READ_MODE;这行代码处吧,但是没跳转到。。。下面是我调用的过程。
static Bool HalSensorRWReg(uint8_t addr, uint8_t *pWriteBuf, uint8_t WriteBytes, uint8_t *pReadBuf, uint8_t ReadBytes, uint8_t slaveAddress)
{
uint8_ttmp[32];//receiver buffermemcpy(tmp, txBuffer, WriteBytes);txBuffer[0] = addr;//address is device IDmemcpy(txBuffer+1, tmp, WriteBytes);
// Initialize master I2C transaction structurei2cTrans.writeCount= 1+WriteBytes;i2cTrans.writeBuf= txBuffer;i2cTrans.readCount= ReadBytes;i2cTrans.readBuf= rxBuffer;i2cTrans.slaveAddress = slaveAddress;I2C_transfer(handle, &i2cTrans);return true;
}

HalSensorRWReg(0x7E,txBuffer,0, rxBuffer, 3, 0x44);

user6477475:

回复 Viki Shi:

就是我在读传感器寄存器值的时候,代码按道理来说是应该运行到object->mode = I2CCC26XX_READ_MODE;的,但是打断点没运行到这里。
我具体调用的过程如下:
HalSensorRWReg(0x7E,txBuffer,0, rxBuffer, 3, 0x44);

static Bool HalSensorRWReg(uint8_t addr, uint8_t *pWriteBuf, uint8_t WriteBytes, uint8_t *pReadBuf, uint8_t ReadBytes, uint8_t slaveAddress)
{
uint8_ttmp[32];//receiver buffermemcpy(tmp, txBuffer, WriteBytes);txBuffer[0] = addr;//address is device IDmemcpy(txBuffer+1, tmp, WriteBytes);// Initialize master I2C transaction structure
i2cTrans.writeCount= 1+WriteBytes;i2cTrans.writeBuf= txBuffer;i2cTrans.readCount= ReadBytes;i2cTrans.readBuf= rxBuffer;i2cTrans.slaveAddress = slaveAddress;
I2C_transfer(handle, &i2cTrans);
return true;
}

Viki Shi:

回复 user6477475:

是如下链接的相关问题吗?讨论已搬移到那边:e2echina.ti.com/…/607927

YiKai Chen:

回复 user6477475:

可以參考
sunmaysky.blogspot.com/…/basic-example-to-use-opt3001-on-cc2650.html
sunmaysky.blogspot.com/…/basic-example-to-use-hdc1080-on-cc2650.html

赞(0)
未经允许不得转载:TI中文支持网 » CC2640 I2C 读寄存器的值,官方驱动代码有点没弄懂,我读寄存器的值,在读代码这块打的断点,但是运行中没有进这里面
分享到: 更多 (0)