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.

[参考译文] LAUNCHXL-CC2640R2:无法获取 I2C 资源?

Guru**** 2563550 points


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

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/586236/launchxl-cc2640r2-unable-to-acquire-i2c-resource

器件型号:LAUNCHXL-CC2640R2

您好!

  我移植了一个 sensortag 示例程序、用于 CC2640R2 Launchpad。 我已经对此进行了测试、它正在工作。 我正在连接 I2C LIS3SDH 加速计传感器。 我正在调试我的代码步进、它在下面的 Semaphore_pend 代码行挂起。 我已设置正确的 I2C 引脚。 它为什么在 Semaphore_pend()代码行挂起可能是什么原因?

文件名:lis3dh.h

#define SENSOR_SELECT() SensorI2C_SELECT (SENSOR_I2C_1、LIS3DH_ADDRESS) 

文件名:SensorI2C.c

bool SensorI2C_select (uint8_t newInterface、uint8_t address)
{
//获取 I2C 资源
if (!Semaphore_pend (Semaphore_handle (&mutex)、MS_2_ticks (I2C_TIMEOUT))))
{
返回 false;
}

//存储新的从地址
slaveAddr =地址;

//接口已更改?
if (newInterface!=接口)
{
//存储新接口
接口= newInterface;

//关闭 RTOS 驱动程序
I2C_Close (i2cHandle);

//将定制设置为 NULL,选择 I2C 接口0
I2C_Params_init (&i2cParams);

//根据所选的 I2C 接口1分配 I2C 数据/时钟引脚
IF (接口= SENSOR_I2C_1)
{
i2cParams.custom=(void *)&pinCfg1;
}

//重新打开具有新总线引脚分配的 RTOS 驱动程序
i2cHandle = I2C_open (Board_I2C0、&i2cParams);
}

返回 i2cHandle != NULL;
} 

-克尔

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    不用介意这篇文章,我忘记在初始化时调用 SensorI2C_open()。
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    很高兴您能解决这个问题!