This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] RTOS/CC2650:CC2650 I2C txbuffer 问题

Guru**** 2409450 points
Other Parts Discussed in Thread: HDC1080

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/637213/rtos-cc2650-cc2650-i2c-txbuffer-issue

器件型号:CC2650
主题中讨论的其他器件:HDC1080

工具/软件:TI-RTOS

您好!  

我在网上找到了一个示例代码,但我不确定我是否理解以下代码。如果 有人能解释 txBuffer 地址应该是什么,我将不胜感激。

//读取 HDC1080器件 ID

  TxBuffer[0]= 0xFF;

  TxBuffer[1]= 0x10;

  TxBuffer[2]= 0x00;

  i2cTransaction.slaveAddress = 0x64;//HDC1080 ADDR;

  i2cTransaction.writeBuf = txBuffer;

  i2cTransaction.writeCount = 1;

  i2cTransaction.readBuf = rxBuffer;

  i2cTransaction.ReadCount = 2;

  if (I2C_transfer (i2c、&i2cTransaction)){

    System_printf ("设备 ID:%x%x\n"、rxBuffer[0]、rxBuffer[1]);

  }否则{

    System_printf ("设备 ID 失败!\n");

  }

  if (I2C_transfer (i2c、&i2cTransaction)){

    System_printf ("设备 ID:%x%x\n"、rxBuffer[0]、rxBuffer[1]);

  }否则{

    System_printf ("设备 ID 失败!\n");

  }

非常感谢。  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    您是否已查看 HDC1080的数据表? 它介绍了通信协议。 txBuffer 是一个无符号字符数组、包含您要在传感器上访问的寄存器地址、后跟额外数据。  i2cTransaction.writeCount 指定传输 txBuffer 的字节数量。

    如果您使用的是 TI-RTOS 2.21 SDK、我建议查看文件夹中的驱动程序 特别是 SensorHdc1000驱动程序。